sirbrillig/phpcs-variable-analysis
PHPCS plugin that analyzes variable usage: warns on undefined variables (including in unset), unused variables, and use of $this/self/static outside class scope. Works with PHPCS 3.13.5+ and PHP 5.4+.
$_GET variables, misplaced $this references).$unused placeholders).$_SESSION) in view layers while enforcing rules in business logic.Adopt if:
$this outside classes).Look elsewhere if:
For Executives:
"This package plugs into our existing PHPCS tooling to automatically catch variable-related bugs—like undefined variables in critical paths or unused function arguments—that slow down development and increase post-launch fixes. For example, it would’ve caught [X] production incidents last quarter where undefined $_GET variables caused silent failures. It’s low-cost (open-source, minimal setup) and integrates with our CI/CD pipelines to block bad code early. Similar tools at companies like [Competitor] reduce technical debt by 20%."
For Engineers: *"VariableAnalysis adds 4 key PHPCS sniffs to our toolkit:
$user used before assignment).$temp = [] never read).$this/static (e.g., $this->method() outside a class).$_GET or template globals).
It’s 2x faster than the old version (v3.0+) and works with our existing PHPCS config. Setup is as simple as composer require --dev sirbrillig/phpcs-variable-analysis and adding <rule ref="VariableAnalysis"/> to phpcs.xml. No runtime overhead—just static checks during dev/test."*For PMs: *"This is a force-multiplier for our code quality goals:
$_POST vars).How can I help you explore Laravel packages today?