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

Clousure: wrong variable scope, if same varname is used. #6473

Closed
verfriemelt-dot-org opened this issue Jan 27, 2022 · 2 comments
Closed

Clousure: wrong variable scope, if same varname is used. #6473

verfriemelt-dot-org opened this issue Jan 27, 2022 · 2 comments
Labels
Milestone

Comments

@verfriemelt-dot-org
Copy link
Contributor

Bug report

phpstan 1.4.2

i have a foreach loop with a variablename $p and within a closure with the same variablename and type. phpstan seem to access wrong scope here for analysis. it should honor the scope of the closure. i know this can and should be resolved with better names, but i was confused about the error reported and think there might be some other issues burried under this false positive.

Code snippet that reproduces the problem

https://phpstan.org/r/c736dc1c-3df9-414d-8a58-8189d13af840

Expected output

no complaints, as in this snipped: https://phpstan.org/r/69eb5d37-c8e1-42d4-b044-93121bf79d8b

Did PHPStan help you today? Did it make you happy in any way?

yes, because we successfully introduced phpstan in our huge legacy codebase at work to keep improving our sourcecode! 🎉 thank you so much for this project!

@ondrejmirtes ondrejmirtes added this to the Easy fixes milestone Feb 1, 2022
@ondrejmirtes
Copy link
Member

Thank you for your kind words! :)

Fixed: phpstan/phpstan-src@af38f03

@github-actions
Copy link

github-actions bot commented Mar 5, 2022

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 Mar 5, 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

2 participants