-
-
Notifications
You must be signed in to change notification settings - Fork 938
Open
Labels
Milestone
Description
Bug report
If a loop has no exit condition in the regular place, but a custom exit condition with if()..break, then phpstan fails to see a variable as defined that is defined inside the exit condition conditional block.
Similar to:
This problem might have the same technical cause, but it is a different test case, and hence it deserves its own issue - I think.
Code snippet that reproduces the problem
https://phpstan.org/r/1b3c4c9e-643a-4a50-90a9-875ad27af465
function foo(int $max): void {
$i = 0;
while (true) {
if ($i > $max) {
$result = 'done';
break;
}
++$i;
}
print $result; // Variable $result might not be defined.
}Expected output
No inspection warning.
Did PHPStan help you today? Did it make you happy in any way?
No response
Reactions are currently unavailable