PackageTrack
Sign in Get early access

sirbrillig/phpcs-variable-analysis

A PHPCS sniff to detect problems with variables.

v3.0.0 55M downloads/mo #576 most downloaded on Packagist sirbrillig/phpcs-variable-analysis

What this package is like to depend on

Last release 27 days ago

27 Jul 2026

Ships fairly regularly

a new release about every 3 months

Nearly every release is documented

notes for 55 of 57 stable releases

Nothing withdrawn

no release was ever pulled

9 years old

74 releases · first in 2017

4 releases in the last 12 months

see the full history below

Release timeline

70 releases · Nov 2017 to Jul 2026
2018 2019 2020 2021 2022 2023 2024 2025 2026
Release Pre-release

Releases

latest 60 of 74
  1. v3.0.0 27 Jul 2026
    Release notes

    What's Changed

    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)

    • Simplify getUseIndexForUseImport using findContainingOpeningBracket() (948d77f)
    • Replace findFunctionCallArguments custom loop with PassedParameters::getParameters() (3a0b6e4)
    • Replace isConstructorPromotion manual scan with FunctionDeclarations::getParameters() (5b97e89)
    • Replace areAnyConditionsAClass manual loop with Conditions::hasCondition() (f4ac147)
    • Simplify getListAssignments using Lists::getAssignments (75768da)
    • Replace findContainingOpeningBracket with phpcsutils equivalent (6b1bdda)
    • Replace isVariableInsideUnset/isVariableInsideIssetOrEmpty with phpcsutils equivalents (6a30e89)
    • Simplify arrow function detection by relying on T_FN (9da451f)
    • Remove unnecessary isArrowFunction block in getScopeCloseForScopeOpen (4cc7f35)

    Full Changelog: v2.13.0...v3.0.0

    Open source →
  2. v3.0.0-beta.10 26 Apr 2026 pre-release
    Release notes
    • Restore version and dependabot updates from 2.x branch (711a32c)

    Full Changelog: v3.0.0-beta.9...v3.0.0-beta.10

    Open source →
    Release notes
    • Restore version and dependabot updates from the 2.x branch.
    Open source →
  3. v3.0.0-beta.9 21 Apr 2026 pre-release
    Release notes

    What's Changed

    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

    • Add phpcsutils as a dependency
    • Bump minimum phpcs version from 3.5.7 to 3.13.5 (8683965)

    Refactoring (using phpcsutils)

    • Simplify getUseIndexForUseImport using findContainingOpeningBracket() (948d77f)
    • Replace findFunctionCallArguments custom loop with PassedParameters::getParameters() (3a0b6e4)
    • Replace isConstructorPromotion manual scan with FunctionDeclarations::getParameters() (5b97e89)
    • Replace areAnyConditionsAClass manual loop with Conditions::hasCondition() (f4ac147)
    • Simplify getListAssignments using Lists::getAssignments (75768da)
    • Replace findContainingOpeningBracket with phpcsutils equivalent (6b1bdda)
    • Replace isVariableInsideUnset/isVariableInsideIssetOrEmpty with phpcsutils equivalents (6a30e89)
    • Simplify arrow function detection by relying on T_FN (9da451f)
    • Remove unnecessary isArrowFunction block in getScopeCloseForScopeOpen (4cc7f35)

    Full Changelog: v2.13.0...v3.0.0-beta.9

    Open source →
    Release notes

    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

    • Add PHPCSUtils as a dependency.
    • Bump minimum PHPCS version from 3.5.7 to 3.13.5.

    Refactoring (using PHPCSUtils)

    • Simplify getUseIndexForUseImport using findContainingOpeningBracket().
    • Replace findFunctionCallArguments custom loop with PassedParameters::getParameters().
    • Replace isConstructorPromotion manual scan with FunctionDeclarations::getParameters().
    • Replace areAnyConditionsAClass manual loop with Conditions::hasCondition().
    • Simplify getListAssignments using Lists::getAssignments.
    • Replace findContainingOpeningBracket with the PHPCSUtils equivalent.
    • Replace isVariableInsideUnset/isVariableInsideIssetOrEmpty with PHPCSUtils equivalents.
    • Simplify arrow function detection by relying on T_FN.
    • Remove unnecessary isArrowFunction block in getScopeCloseForScopeOpen.
    Open source →
  4. v3.0.0-beta.8 23 Nov 2020 pre-release

    Nothing published for this version

  5. v3.0.0-beta.7 10 Sep 2020 pre-release

    Nothing published for this version

  6. v3.0.0-beta.6 02 Sep 2020 pre-release

    Nothing published for this version

  7. v3.0.0-beta.5 24 Aug 2020 pre-release

    Nothing published for this version

  8. v3.0.0-beta.4 18 Aug 2020 pre-release

    Nothing published for this version

  9. v3.0.0-beta.3 11 Jul 2020 pre-release

    Nothing published for this version

  10. v3.0.0-beta.2 10 Jul 2020 pre-release

    Nothing published for this version

  11. v3.0.0-beta.1 12 May 2020 pre-release

    Nothing published for this version

  12. v2.13.0 30 Sep 2025
    Release notes

    What's Changed

    Full Changelog: v2.12.0...v2.13.0

    Open source →
    Release notes
    • Ruleset: update schema URL (#353).
    • Update for PHPCS 4.0.0 (#356).
    Open source →
  13. v2.12.0 17 Mar 2025
    Release notes

    What's Changed

    • GH Actions: use the xmllint-validate action runner by @jrfnl in #350
    • Accept namespaces in sitePassByRefFunctions by @sirbrillig in #351

    Full Changelog: v2.11.22...v2.12.0

    Open source →
    Release notes
    • Accept namespaces in sitePassByRefFunctions (#351).
    • GH Actions: use the xmllint-validate action runner (#350).
    Open source →
  14. v2.11.22 06 Jan 2025
    Release notes

    What's Changed

    New Contributors

    Full Changelog: v2.11.21...v2.11.22

    Open source →
    Release notes
    • Allow finding arrow function variables when the arrow function is in file scope (#347).
    • Add perf-guard GitHub workflow (#345).
    • Improve PHPStan configuration (#344).
    Open source →
  15. v2.11.21 02 Dec 2024
    Release notes

    What's Changed

    • Only search for nested arrow functions if necessary by @sirbrillig in #342

    Full Changelog: v2.11.20...v2.11.21

    Open source →
    Release notes
    • Only search for nested arrow functions if necessary (#342).
    Open source →
  16. v2.11.20 01 Dec 2024
    Release notes

    What's Changed

    • Support nested arrow functions by @sirbrillig in #334
    • Simplify detecting class properties to improve detection for anonymous classes by @sirbrillig in #337
    • Handle compact inside arrow functions by @sirbrillig in #339
    • Support constructor promotion with namespaced and union typehints by @sirbrillig in #333

    Minor Changes

    • Composer: prevent a lock file from being created by @jrfnl in #326
    • Composer: psalm 5 is out of beta by @jrfnl in #327
    • Tests: allow for running on PHPUnit 10/11 by @jrfnl in #328
    • GH Actions: PHP 8.4 has been released by @jrfnl in #336
    • Run static-analysis Github action on PHP 8.1 by @sirbrillig in #338

    Full Changelog: v2.11.19...v2.11.20

    Open source →
    Release notes
    • Support nested arrow functions (#334).
    • Simplify detecting class properties to improve detection for anonymous classes (#337).
    • Handle compact inside arrow functions (#339).
    • Support constructor promotion with namespaced and union typehints (#333).
    • Various housekeeping: prevent a Composer lock file (#326), Psalm 5 (#327), PHPUnit 10/11 support (#328), PHP 8.4 in CI (#336), and run static analysis on PHP 8.1 (#338).
    Open source →
  17. v2.11.19 26 Jun 2024
    Release notes

    What's Changed

    • GH Actions: work around intermittent apt-get errors by @jrfnl in #322
    • fix: Process variable before the end of scope by @biinari in #324

    New Contributors

    Full Changelog: v2.11.18...v2.11.19

    Open source →
    Release notes
    • Fix: process variable before the end of scope (#324).
    • GH Actions: work around intermittent apt-get errors (#322).
    Open source →
  18. v2.11.18 13 Apr 2024
    Release notes

    What's Changed

    • Switch to PHPCSStandards/PHP_CodeSniffer by @jrfnl in #315
    • Make sure that recursive search of list assignments stays inside them by @sirbrillig in #318
    • Fix nullable constructor promotion detection by @sirbrillig in #321

    Full Changelog: v2.11.17...v2.11.18

    Open source →
    Release notes
    • Switch to PHPCSStandards/PHP_CodeSniffer (#315).
    • Make sure that recursive search of list assignments stays inside them (#318).
    • Fix nullable constructor promotion detection (#321).
    Open source →
  19. v2.11.18-beta.2 no date pre-release

    Nothing published for this version

  20. v2.11.18-beta.1 24 Mar 2024 pre-release

    Nothing published for this version

  21. v2.11.17 05 Aug 2023
    Release notes
    • Do not close scope of ref reassignment when inside else (#306).
    Open source →
  22. v2.11.16 31 Mar 2023
    Release notes
    • Allow newlines in arrow functions (#301).
    Open source →
  23. v2.11.15 31 Mar 2023
    Release notes
    • Fix scope closer detection in arrow function detection (#298).
    Open source →
  24. v2.11.14 30 Mar 2023
    Release notes
    • Use custom logic for finding arrow function scope (#296).
    Open source →
  25. v2.11.13 30 Mar 2023
    Release notes
    • Support readonly constructor promotion (#294).
    Open source →
  26. v2.11.12 13 Mar 2023
    Release notes
    • Allow non-enum tokens called 'enum' (#293).
    Open source →
  27. v2.11.11 12 Mar 2023
    Release notes
    • Add support for enum methods (#289).
    Open source →
  28. v2.11.10 05 Jan 2023
    Release notes
    • Composer: allow for the 1.0.0 version of the Composer PHPCS plugin (#287).
    Open source →
  29. v2.11.9 05 Oct 2022
    Release notes
    • Prevent detecting static closures when looking for static variables (#281).
    Open source →
  30. v2.11.8 08 Sep 2022
    Release notes
    • Fix function call detection to exclude non-function tokens (#279).
    Open source →
  31. v2.11.7 16 Aug 2022
    Release notes
    • Place static arrow function body outside of scope on static declaration check (#276). Fixes a static variable regression from #267.
    Open source →
  32. v2.11.6 15 Aug 2022
    Release notes

    Bug fix release for two regressions caused by the new static function variable scanning added in #267.

    • Ignore function call arguments on static declarations processing (#273).
    • Fix scanning for static variables near start of file (#274).
    Open source →
  33. v2.11.5 13 Aug 2022
    Release notes
    • Allow for loop increment expression to use a variable defined inside the loop (#262).
    • Support constructor promotion (#266).
    • Improve static declaration checks (#267).
    • Handle inline if list destructure (#268).
    • Remove php_errormsg from superglobals list (#269).
    • Ignore unused parameters when a function in an abstract class is empty (#270).
    Open source →
  34. v2.11.4 13 Jun 2022
    Release notes
    • Fix a deprecation notice in PHP 8.2 (#248), plus internal housekeeping.
    Open source →
  35. v2.11.3 21 Feb 2022
    Release notes
    • Update for Composer 2.2 (#242).
    Open source →
  36. v2.11.2 06 Jul 2021
    Release notes
    • Respect ignoring undefined variables in else blocks (#239).
    Open source →
  37. v2.11.1 18 Jun 2021
    Release notes
    • Allow parsing mixed HTML and PHP (#234, #236).
    • Ignore double assignment by reference if the second is inside a condition (#235).
    Open source →
  38. v2.11.0 09 Mar 2021
    Release notes
    • Start inline block scope at end of condition rather than at keyword (#230).
    • Add allowUnusedVariablesInFileScope option (#229).
    Open source →
  39. v2.10.3-beta.1 no date pre-release

    Nothing published for this version

  40. v2.10.2 08 Jan 2021
    Release notes
    • Treat writing to a by-reference foreach loop variable as a read (#221).
    • Properly detect variables used in quotes inside arrow functions (#222).
    Open source →
  41. v2.10.2-beta.1 30 Dec 2020 pre-release

    Nothing published for this version

  42. v2.10.1 12 Dec 2020
    Release notes
    • Performance: only check one parent for recursive list assignment (#218). In at least one example file this brought the speed from 7 minutes down to 0.3 seconds.
    Open source →
  43. v2.10.0 23 Nov 2020
    Release notes

    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:

    • Fix array_walk pass-by-reference in 2.x (#216).
    • Support for PHP 7.4 arrow functions (#179).
    • Rewritten and more accurate scope detection.
    • Allow undefined variables inside isset and empty (#204).
    • Fix error in closures with namespace separators (#197).
    • Fix complex default arguments (#198).
    • Handle inline if/else (#199).
    • Add allowUndefinedVariablesInFileScope option (#193).
    • Add allowUnusedVariablesBeforeRequire option (#196).
    • Support global scope (#190).
    • Add validUndefinedVariableRegexp option (#173).
    • Refactor and clean up reference variables (#187).
    • Add special cases for variables used in 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).

    Open source →
  44. v2.10.0-beta.3 no date pre-release

    Nothing published for this version

  45. v2.10.0-beta.1 10 Nov 2020 pre-release

    Nothing published for this version

  46. v2.9.0 07 Oct 2020
    Release notes

    Backports some 3.x features to the 2.x line.

    • Add allowUnusedVariablesBeforeRequire option (originally #196).
    • Add allowUndefinedVariablesInFileScope option (originally #193).
    Open source →
  47. v2.8.3 11 Jul 2020
    Release notes
    • Downgrade requirements from PHP 5.6 to 5.4 (#191, backported to 2.x).
    Open source →
  48. v2.8.2 25 May 2020
    Release notes

    A backport of the bugfixes from 3.0.0-beta.1 into the 2.x version without any of the PHPCSUtils changes.

    • Fix comment tolerance for many sniffs.
    • Clean up package structure.
    • Only allow unused values in associative foreach loops with option (#167).
    • Fix unused-before-used detection (#171).
    Open source →
  49. v2.8.2-beta.1 no date pre-release

    Nothing published for this version

  50. v2.8.1 11 Feb 2020
    Release notes

    A small bug fix release with test and package clean-up.

    • Make assignment of a reference variable be considered a use (#128).
    • Bug fix: false negative unused var (#120).
    • Bug fix: $this in nested function declaration (#119).
    • Bug fix: recognize use of self/static within an anonymous class (#110).
    • PHPStan: document run parameters in project ruleset (#122).
    • Composer: update PHPCS Composer plugin dependency (#121), move PHPCS dependency to require (#106), update DealerDirect Composer plugin requirement (#112).
    • Documentation: minor fixes (#123).
    • Tests: simplify the PHPCS setup method (#115), allow them to work cross-platform (#108), add testsuite name to PHPUnit config (#113).
    • Remove stray composer.lock file (#117).
    • Composer: make the PHPUnit requirements more flexible (#114).
    • PHPCS: document run parameters in project ruleset (#107).
    Open source →
  51. v2.8.0 10 Oct 2019
    Release notes
    • Add apcu_* functions to getPassByReferenceFunctions (#103).
    • Add sniff codes to README (#100).
    • Mention phpcs-changed in README (#97).
    • Update README to include PHPStan and linting (#96).
    • Refactor methods to have nullable return types (#95).
    • Tests: make sure fixtures are valid PHP.
    Open source →
  52. v2.7.0 24 Jun 2019
    Release notes
    • Consider get_defined_vars() to be a read (#92).
    • Use static analysis to remove edge case bugs (#94).
    Open source →
  53. v2.6.4 10 May 2019
    Release notes
    • Recognize that variable variables are not assignments (#88).
    Open source →
  54. v2.6.3 10 May 2019
    Release notes
    • Downgrade CircleCI image to PHP 5.6 (#86). Fixes a PHP 5.6 regression introduced in 2.6.2 and corrects the Composer minimum PHP version.
    Open source →
  55. v2.6.2 22 Apr 2019
    Release notes
    • Allow global var assignment to count as a read (#83).
    Open source →
  56. v2.6.1 01 Apr 2019
    Release notes
    • Improve check for static var defs inside functions (#80).
    • Allow self and static references in a trait (#76).
    • Add checks for class properties (#77).
    Open source →
  57. v2.6.0 15 Feb 2019
    Release notes
    • Enable allowUnusedForeachVariables and allowUnusedCaughtExceptions (#73).
    Open source →
  58. v2.5.0 08 Feb 2019
    Release notes
    • Add ignore unused foreach option (#66).
    • Allow self within class method closures (#70).
    • Add allowWordPressPassByRefFunctions option (#69).
    • Document site pass by ref (#71).
    Open source →
  59. v2.4.0 02 Jan 2019
    Release notes
    • Handle variable class static refs (#63).
    • Ignore numeric variables (#61).
    • Make allowUnusedParametersBeforeUsed default to true (#59).
    Open source →
  60. v2.3.0 21 Dec 2018
    Release notes
    • Add allowUnusedParametersBeforeUsed option (#58).
    Open source →

Every package, every release, already written down.

The archive is open and free. Watching your own project is what we are building next.

Browse the archive