Skip to content

Detect not looping loops #3277

@canvural

Description

@canvural

Feature request

I'm not sure if this is a bug or really not supported. But going with feature request for now.

For the given code:

<?php declare(strict_types = 1);

for($i = 5; $i < 4; $i++) {
	loop();
}

function loop() : void {
    echo 'Looping';
}

https://phpstan.org/r/75344213-23a7-4c4d-9ac1-bb84d3f69b8e

No error is detected. But it'd be nice to detect that this loop does not actually loop.

(As a side note, when strict rules is enabled (https://phpstan.org/r/57404348-51b1-484e-958c-a2f1be351f68) there is a strange error message. Only numeric types are allowed in post-increment, string given.)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions