Returning from a for loop with empty condition is not recognized #9374
Closed
Description
Bug report
This gives error Function bar() should return string but return statement is missing..
function bar(): string {
for ($i = 0; ; ++$i)
return "";
}
Although, using while
works as expected.
function bar(): string {
while (true)
return "";
}
Code snippet that reproduces the problem
https://phpstan.org/r/4afb0fc0-a96f-44b2-9de1-d112e78f4871
Expected output
No errors.
Did PHPStan help you today? Did it make you happy in any way?
PHPStan is great! ❤️