-
-
Notifications
You must be signed in to change notification settings - Fork 947
Nested while loop errors #8643
Copy link
Copy link
Closed
Description
Bug report
PHPStan reports errors for nested while loops.
PHPStan 1.9.2 (and older) does not produce this error, but PHPStan 1.9.3 to 1.9.6 does.
Code snippet that reproduces the problem
https://phpstan.org/r/e7e6df1c-ba29-4fd0-82e7-788f2a202177
<?php declare(strict_types = 1);
$x = 0;
while ($x < 4) { // Comparison operation "<" between 0 and 4 is always true.
$y = 0;
while ($y < 6) {
$y += 1;
}
$x += 1;
}
echo 'done'; // Unreachable statement - code above always terminates.
This code produces no errors:
<?php declare(strict_types = 1);
$x = 0;
while ($x < 4) {
$x += 1;
}
echo 'done';
Expected output
PHPStan should report no errors, but reports two:
Comparison operation "<" between 0 and 4 is always true.
Unreachable statement - code above always terminates.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels