sirbrillig / phpcs-variable-analysis

Find undefined and unused variables with the PHP Codesniffer static analysis tool.
Other
136 stars 14 forks source link

Prevent detecting static closures when looking for static variables #281

Closed sirbrillig closed 2 years ago

sirbrillig commented 2 years ago

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 https://github.com/sirbrillig/phpcs-variable-analysis/issues/280