Problem/Motivation
The sniff DrupalPractice.CodeAnalysis.VariableAnalysis.UnusedVariable fails on settings.php files, since they often declare variables such as $databases. We might all agree that settings.php is indeed a bit wrong in the way it handles variables, but given that it's the convention it seems like Coder shouldn't throw false positives on it.
Example where I believe this is failing inappropriately:
Steps to reproduce
Declare any variable such as $databases in settings.php and run phpcs on it with DrupalPractice ruleset.
Proposed resolution
Either exclude settings.php from this sniff somehow, or document a recommended workaround. Individuals can add // phpcs:ignore on their own but this seems hacky.
Remaining tasks
User interface changes
API changes
Data model changes
Comments
Comment #2
danepowell commentedComment #3
danepowell commentedAhah... I think I figured out what's going on here. If you modify an existing array variable it works fine, it's only if you declare a new variable that the sniff complains, and I think everything you'd want to modify in settings.php is an array.
So instead of:
... one should instead do:
Comment #4
danepowell commented