Bug report
Combining dependent types with a for loop causes PHPStan to falsely report an error.
In the linked code, $foo is guaranteed to be defined, when $flag is truthy.
Code snippet that reproduces the problem
https://phpstan.org/r/79ccd56f-c164-4389-8ed4-2e593b350449
Expected output
PHPStan should not report an error. Just like the same code without a loop: https://phpstan.org/r/45d91429-2383-4127-9f84-6b3e96eaa9be
Did PHPStan help you today? Did it make you happy in any way?
Yes, every other day it finds possible bugs :)