Skip to content

Prevent detecting static closures when looking for static variables #281

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

Merged
merged 6 commits into from
Oct 5, 2022

Conversation

sirbrillig
Copy link
Owner

@sirbrillig sirbrillig commented Oct 5, 2022

When looking for a static variable declaration, we look backwards in the file from the variable to the start of the statement to see if it has the static keyword. Unfortunately, this can also find syntax like static function() { }, $foo... and incorrectly assume that means that the variable is static.

This PR updates the static declaration detection to explicitly ignore static closure definitions.

Fixes #280

@sirbrillig sirbrillig marked this pull request as ready for review October 5, 2022 16:41
@sirbrillig sirbrillig merged commit 6273088 into 2.x Oct 5, 2022
@sirbrillig sirbrillig deleted the fix/another-static-var-detection branch October 5, 2022 23:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Incorrect warning about redeclaration of function parameter as static variable
1 participant