You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
while-true-if-break: Variable might not be defined #11545
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.
Activity
MacGritsch commentedon Jan 5, 2025
Same issue with foreach
https://phpstan.org/r/00f146fe-cca5-4dc7-8677-20546a68386e
Add regression tests for #11545, #10245, #5919, #5477
Fix variable definedness after always-iterating loops with break
Add regression tests for #11545, #10245, phpstan#5919, phpstan#5477
VincentLanglet commentedon Mar 2, 2026
Just remove
strict-rulesoptionhttps://phpstan.org/r/2e89a4eb-02a0-49be-8cd0-bcdb160bdd97
Same for the for Loop.
It's about the polluteScopeWithLoopInitialAssignments and polluteScopeWithAlwaysIterableForeach options.
Other cases will be handled by phpstan/phpstan-src#5118
Add regression tests for #11545, #10245, phpstan#5919, phpstan#5477
phpstan-bot commentedon Mar 3, 2026
Closed via merging phpstan/phpstan-src#5118
github-actions commentedon Apr 4, 2026
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.