Closed Wirone closed 5 months ago
This is a feature, not a bug of strict-rules. You can turn it off with this setting https://phpstan.org/config-reference#pollutescopewithloopinitialassignments
phpstan-strict-rules mimics how other stricter languages act with loop-scoped variables.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
I believe strict rules falsely report this. Assignment is always done, and then condition is checked so it can escape the loop early, but
$i
is there, right? This is the fix, but it does not look good to move initial assignments before the for loop.