Closed greg0ire closed 1 year ago
This is expected. Strict rules disallow use of variables from loops outside loops. You can turn off this behaviour (enabled by strict rules) by this config option https://phpstan.org/config-reference#pollutescopewithloopinitialassignments to false true (edited)
Thanks @MartinMystikJonas !
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.
Bug report
With strict rules turned on PHPStan reports that a variable will always be overwritten if followed by a
for
loop that uses it in the assignment part, and that's great: https://phpstan.org/r/244ed1d0-003c-492f-99d2-ce5a075ae515If you attempt to fix that though, you run into a contradictory error:
Code snippet that reproduces the problem
https://phpstan.org/r/030872ba-acba-4a27-b267-1f30156b1417
Expected output
No errors
Did PHPStan help you today? Did it make you happy in any way?
Yes, it helps me make it easier to spot errors in data providers