Skip to content
New issue

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

Infinite for loop vars not seen as defined #2806

Closed
muglug opened this issue Jan 4, 2020 · 3 comments
Closed

Infinite for loop vars not seen as defined #2806

muglug opened this issue Jan 4, 2020 · 3 comments

Comments

@muglug
Copy link
Contributor

muglug commented Jan 4, 2020

for (;;) {
  $a = "hello";
  break;
}

echo $a;

Expected: No issue
Actual: Variable $a might not be defined.

https://phpstan.org/r/19b1ac30-50b8-404b-9da8-9b1a3b6f90b1

@muglug
Copy link
Contributor Author

muglug commented Jan 4, 2020

The equivalent while(true) code works fine: https://phpstan.org/r/3dfa4f4f-a9c5-4d73-b29a-a98ebbfd8680

@ondrejmirtes ondrejmirtes added this to the NodeScopeResolver bugs milestone Jan 4, 2020
@phpstan-bot
Copy link
Contributor

@muglug After the latest commit in dev-master, PHPStan now reports different result with your code snippet:

@@ @@
-8: Variable $a might not be defined.
+No errors

@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 13, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

3 participants