Bug report
If I have foreach loop in try/catch block, I got false positive error: Variable might not be defined. for the iterated value in the catch block.
Why I think it's false positive:
- If collection is empty, catch block is never triggered
- If collection is not empty
$file variable is always set in the catch block
Code snippet that reproduces the problem
https://phpstan.org/r/0271c658-e5d5-421f-a88c-f955eae727c6
Expected output
No error
Did PHPStan help you today? Did it make you happy in any way?
Yep, it helped me to find some issues after updating code to php8
Bug report
If I have foreach loop in try/catch block, I got false positive error:
Variable might not be defined.for the iterated value in the catch block.Why I think it's false positive:
$filevariable is always set in the catch blockCode snippet that reproduces the problem
https://phpstan.org/r/0271c658-e5d5-421f-a88c-f955eae727c6
Expected output
No error
Did PHPStan help you today? Did it make you happy in any way?
Yep, it helped me to find some issues after updating code to php8