NewYour coding agent can read the release notes before it upgrades.Set up the MCP server →
Packagist
Packagist, #584 most downloaded on Packagist
A PHPCS sniff to detect problems with variables.
Latest stable
v3.0.0
Last release 3 months ago
27 Jul 2026
Ships fairly regularly
a new release about every 3 months
Nearly every release is documented
notes for 56 of 57 stable releases
Nothing withdrawn
no release was ever pulled
9 years old
74 releases · first in 2017
Drag across the ruler to compare, or tap a release to open it.
This is a large refactor which greatly increases the speed and accuracy of phpcs-variable-analysis by adding a dependency on phpcsutils.
This is a large refactor which greatly increases the speed and accuracy of phpcs-variable-analysis by adding a dependency on phpcsutils.
Dependencies
Refactoring (using phpcsutils)
getUseIndexForUseImport using findContainingOpeningBracket() (948d77f)findFunctionCallArguments custom loop with PassedParameters::getParameters() (3a0b6e4)isConstructorPromotion manual scan with FunctionDeclarations::getParameters() (5b97e89)areAnyConditionsAClass manual loop with Conditions::hasCondition() (f4ac147)getListAssignments using Lists::getAssignments (75768da)findContainingOpeningBracket with phpcsutils equivalent (6b1bdda)isVariableInsideUnset/isVariableInsideIssetOrEmpty with phpcsutils equivalents (6a30e89)T_FN (9da451f)isArrowFunction block in getScopeCloseForScopeOpen (4cc7f35)Full Changelog: https://github.com/sirbrillig/phpcs-variable-analysis/compare/v2.13.0...v3.0.0
Your coding agent can read these notes before it upgrades. Set up the MCP server →
Restore version and dependabot updates from 2.x branch
Full Changelog: https://github.com/sirbrillig/phpcs-variable-analysis/compare/v3.0.0-beta.9...v3.0.0-beta.10
This is preparing for a major 3.0 release which adds a dependency on PHPCSUtils. The new version should have the same functionality, fix some subtle b
This is preparing for a major 3.0 release which adds a dependency on PHPCSUtils. The new version should have the same functionality, fix some subtle bugs, and increase performance by over 2x.
Dependencies
Refactoring (using phpcsutils)
getUseIndexForUseImport using findContainingOpeningBracket() (948d77f)findFunctionCallArguments custom loop with PassedParameters::getParameters() (3a0b6e4)isConstructorPromotion manual scan with FunctionDeclarations::getParameters() (5b97e89)areAnyConditionsAClass manual loop with Conditions::hasCondition() (f4ac147)getListAssignments using Lists::getAssignments (75768da)findContainingOpeningBracket with phpcsutils equivalent (6b1bdda)isVariableInsideUnset/isVariableInsideIssetOrEmpty with phpcsutils equivalents (6a30e89)T_FN (9da451f)isArrowFunction block in getScopeCloseForScopeOpen (4cc7f35)Full Changelog: https://github.com/sirbrillig/phpcs-variable-analysis/compare/v2.13.0...v3.0.0-beta.9
This is preparing for a major 3.0 release which adds a dependency on PHPCSUtils. The new version should have the same functionality, fix some subtle bugs, and increase performance by over 2x.
getUseIndexForUseImport using findContainingOpeningBracket().findFunctionCallArguments custom loop with PassedParameters::getParameters().isConstructorPromotion manual scan with FunctionDeclarations::getParameters().areAnyConditionsAClass manual loop with Conditions::hasCondition().getListAssignments using Lists::getAssignments.findContainingOpeningBracket with the PHPCSUtils equivalent.isVariableInsideUnset/isVariableInsideIssetOrEmpty with PHPCSUtils equivalents.T_FN.isArrowFunction block in getScopeCloseForScopeOpen.Fix array_walk pass-by-reference in 2.x
Allow undefined variables inside isset and empty
isset and empty (#204)Fix performance issues around scope close detection
Fix error in closures with namespace separators
Downgrade requirements from PHP 5.6 to 5.4
## Changelog - Support global scope
Added property validUndefinedVariableRegexp to VariableAnalysisSniff
else blocks (#189) <Payton Swick>This is a beta release of 3.0. The breaking change is that we now require an external library which is installed by composer. Before release we'll nee…
This is a beta release of 3.0. The breaking change is that we now require an external library which is installed by composer. Before release we'll need to update the documentation about how to do a stand-alone install (see #160) and ideally add support for PHP 7.4 (see #165).
Ruleset: update schema URL by @jrfnl in https://github.com/sirbrillig/phpcs-variable-analysis/pull/353
Full Changelog: https://github.com/sirbrillig/phpcs-variable-analysis/compare/v2.12.0...v2.13.0
GH Actions: use the xmllint-validate action runner by @jrfnl in https://github.com/sirbrillig/phpcs-variable-analysis/pull/350
Full Changelog: https://github.com/sirbrillig/phpcs-variable-analysis/compare/v2.11.22...v2.12.0
sitePassByRefFunctions (#351).Improve phpstan configuration by @szepeviktor in https://github.com/sirbrillig/phpcs-variable-analysis/pull/344
Full Changelog: https://github.com/sirbrillig/phpcs-variable-analysis/compare/v2.11.21...v2.11.22
Only search for nested arrow functions if necessary by @sirbrillig in https://github.com/sirbrillig/phpcs-variable-analysis/pull/342
Full Changelog: https://github.com/sirbrillig/phpcs-variable-analysis/compare/v2.11.20...v2.11.21
Support nested arrow functions by @sirbrillig in https://github.com/sirbrillig/phpcs-variable-analysis/pull/334
Full Changelog: https://github.com/sirbrillig/phpcs-variable-analysis/compare/v2.11.19...v2.11.20
compact inside arrow functions (#339).GH Actions: work around intermittent apt-get errors by @jrfnl in https://github.com/sirbrillig/phpcs-variable-analysis/pull/322
Full Changelog: https://github.com/sirbrillig/phpcs-variable-analysis/compare/v2.11.18...v2.11.19
Switch to PHPCSStandards/PHP_CodeSniffer by @jrfnl in https://github.com/sirbrillig/phpcs-variable-analysis/pull/315
Full Changelog: https://github.com/sirbrillig/phpcs-variable-analysis/compare/v2.11.17...v2.11.18
Fix nullable constructor promotion detection
This release is going out as a beta first because I am traveling and if I break something I won't be around to fix it for a while, but it probably wil
This release is going out as a beta first because I am traveling and if I break something I won't be around to fix it for a while, but it probably will be fine.
Do not close scope of ref reassignment when inside else
Arrow function scope just keeps going.
Arrow function scope just keeps going.
Fix scope closer detection in arrow function detection
Use custom logic for finding arrow function scope
Support readonly constructor promotion (#294).
Allow non-enum tokens called 'enum'
## Changelog - Add support for enum methods
Composer: allow for the 1.0.0 version of the Composer PHPCS plugin
Prevent detecting static closures when looking for static variables
Fix function call detection to exclude non-function tokens
Another bug fix for a static variable regression caused by https://github.com/sirbrillig/phpcs-variable-analysis/pull/267.
Another bug fix for a static variable regression caused by https://github.com/sirbrillig/phpcs-variable-analysis/pull/267.
static variable regression from #267.This is a bug fix release for two regressions caused by the new static function variable scanning added in #267.
This is a bug fix release for two regressions caused by the new static function variable scanning added in #267.
Allow for loop increment expression to use variable defined inside loop
for loop increment expression to use a variable defined inside the loop (#262).if list destructure (#268).php_errormsg from superglobals list (#269).Mostly a bunch of housekeeping changes internal to the codebase, but this does include a fix for a deprecation notice in PHP 8.2.
Mostly a bunch of housekeeping changes internal to the codebase, but this does include a fix for a deprecation notice in PHP 8.2.
## Changelog - Update for Composer 2.2
Respect ignoring undefined variables in else blocks
Allow parsing mixed HTML and PHP (#234 and #236)
Start inline block scope at end of condition rather than at keyword
Start inline block scope at end of condition rather than at keyword
Treat writing to a by-reference foreach loop variable as a read (#221) (props to @MPParsley for finding this bug!)
Treat writing to a by-reference foreach loop variable as a read (#221) (props to @MPParsley for finding this bug!)
This is just a performance enhancement for certain nested list detection. In at least one example file, this brings the speed from 7 minutes down to 0
This is just a performance enhancement for certain nested list detection. In at least one example file, this brings the speed from 7 minutes down to 0.3 seconds. 😱
Changes that this _does not_ include (since they are breaking changes):
This is a pretty large release which backports nearly all the improvements that have been made to the 3.0 branch back to the 2.x line, with the major exception of adding phpcsutils as a dependency (which will still be done in 3.0 and will improve accuracy and reduce the amount of code needed by this sniff when it is released).
Notable changes from 2.9 include:
Changes that this does not include (since they are breaking changes):
A large release that backports nearly all the improvements made on the 3.0 branch to the 2.x line, with the major exception of adding PHPCSUtils as a dependency.
Notable changes since 2.9:
array_walk pass-by-reference in 2.x (#216).isset and empty (#204).if/else (#199).allowUndefinedVariablesInFileScope option (#193).allowUnusedVariablesBeforeRequire option (#196).validUndefinedVariableRegexp option (#173).else blocks (#189).Note: this release intentionally excludes breaking changes from the 3.0 branch, namely replacing UnusedVariable with UnusedParameter for parameters (#195) and adding sniff codes for the array assignment shortcut (#205).
Fix array_walk pass-by-reference in 2.x
Changes that this _does not_ include (since they are breaking changes):
This is a pretty large release which backports nearly all the improvements that have been made to the 3.0 branch back to the 2.x line, with the major exception of adding phpcsutils as a dependency (which will still be done in 3.0 and will improve accuracy and reduce the amount of code needed by this sniff when it is released).
Notable changes from 2.9 include:
Changes that this does not include (since they are breaking changes):
This release backports some 3.x features back to the 2.x line.
This release backports some 3.x features back to the 2.x line.
Backports some 3.x features to the 2.x line.
allowUnusedVariablesBeforeRequire option (originally #196).allowUndefinedVariablesInFileScope option (originally #193).Downgrade requirements from PHP 5.6 to 5.4 #191 (backported to 2.x).
This is a backport of the bugfixes from 3.0.0-beta.1 into the 2.x version without any of the PHPCSUtils changes.
This is a backport of the bugfixes from 3.0.0-beta.1 into the 2.x version without any of the PHPCSUtils changes.
This is a backport of the bugfixes in 3.0.0-beta.1 into the 2.x version without any of the PHPCSUtils changes. Because of the nature of a backport, th
This is a backport of the bugfixes in 3.0.0-beta.1 into the 2.x version without any of the PHPCSUtils changes. Because of the nature of a backport, this is a test release to make sure everything works properly before I do a proper release of 2.8.2.
This is a small bug fix release with a bunch of test and package clean-up from brave contributors @jrfnl and @alexpott. Thanks, friends! ❤️
This is a small bug fix release with a bunch of test and package clean-up from brave contributors @jrfnl and @alexpott. Thanks, friends! ❤️
composer.lock file (#117)require (#106)A small bug fix release with test and package clean-up.
$this in nested function declaration (#119).self/static within an anonymous class (#110).require (#106), update DealerDirect Composer plugin requirement (#112).composer.lock file (#117).Add apcu_* functions to getPassByReferenceFunctions
apcu_* functions to getPassByReferenceFunctions (#103).Consider get_defined_vars() to be a read
get_defined_vars() to be a read (#92)Recognize that variable vars are not assignments
v2.6.2 added a regression for PHP 5.6, which was intended to be the minimum version for this package. The composer config incorrectly listed PHP 5.4 a
v2.6.2 added a regression for PHP 5.6, which was intended to be the minimum version for this package. The composer config incorrectly listed PHP 5.4 as the minimum version, so that has also been updated.
Allow global var assignment to count as a read #83 (thanks @aeisenberg for finding it!)
Improve check for static var defs inside functions (#80) (props @Rolige for finding it)
self and static references in a trait (#76).Enable allowUnusedForeachVariables and allowUnusedCaughtExceptions
allowUnusedForeachVariables and allowUnusedCaughtExceptions (#73).Add ignore unused foreach option
foreach option (#66).self within class method closures (#70).allowWordPressPassByRefFunctions option (#69).Handle variable class static refs
Add allowUnusedParametersBeforeUsed option
One column per quarter.