sirbrillig / phpcs-variable-analysis

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

Nested destructured assignment reported as unused/undefined #130

Closed sirbrillig closed 4 years ago

sirbrillig commented 4 years ago

Same issue as this one in VIPCS: https://github.com/Automattic/VIP-Coding-Standards/issues/458

jrfnl commented 4 years ago

@sirbrillig If you'd consider adding PHPCSUtils as a dependency, it contains a Lists::getAssignments() utility method which would be very helpful to solve this: https://github.com/PHPCSStandards/PHPCSUtils/blob/a9ee9e0afffca398df6f997b44628440aa838d41/PHPCSUtils/Utils/Lists.php#L221-L277

I created this utility method so sniffs like the WPCS PrefixAllGlobals and GlobalVariablesOverride will be able to detect variable assignments in lists more easily.

sirbrillig commented 4 years ago

I'd be happy to add that as a dependency. Thanks for all the work you've done there. I just need to find the time...

sirbrillig commented 4 years ago

Added phpcsutils in #129. Very helpful!

jrfnl commented 4 years ago

@sirbrillig :+1: Nice! I'm travelling for a conference at the moment, but will have a look at it when I can ;-)

Note: PHPCSUtils is on an alpha release at this moment, so some implementation details may still change before the final 1.0.0 release, though I will make sure that if they do they will be annotated well in the changelog.