-
-
Notifications
You must be signed in to change notification settings - Fork 947
Detect not looping loops #3277
Copy link
Copy link
Closed
phpstan/phpstan-src
#1646Labels
Description
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.)
Reactions are currently unavailable