We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Version being used: PHPStan - PHP Static Analysis Tool 0.12.3
<?php for ($i = 1; $i < 2; $i++) { for ($j = 1; $j < 2; $j++) { } } echo $i * $j;
+------------------------------------------+ | Line | test.php | +------------------------------------------+ | 8 | Variable $j might not be defined. | +------------------------------------------+ [ERROR] Found 1 error
[OK] No errors
The text was updated successfully, but these errors were encountered:
I just implemented this in Psalm – you could presumably PR something similar for PHPStan, though it may require #2806 to be fixed.
Sorry, something went wrong.
This is the place that needs fixing in PHPStan: https://github.com/phpstan/phpstan-src/blob/master/src/Analyser/NodeScopeResolver.php#L781-L846
The while loop handling already looks at the condition so it knows when it iterates at least once: https://github.com/phpstan/phpstan-src/blob/master/src/Analyser/NodeScopeResolver.php#L701-L702
This one is already fixed.
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.
No branches or pull requests
PHPStan doesn't detect variables in nested loop which will surely be initialized.
Version being used:
PHPStan - PHP Static Analysis Tool 0.12.3
Code snippet that reproduces the problem
Output
Expected output
The text was updated successfully, but these errors were encountered: