A set of sniffs for PHP_CodeSniffer that checks for PHP version compatibility.

(standards, compatibility, phpcs)

Critical or Security advisories for 8.1.0

This version doesn't have any advisory. Want to report one?

Changelog for 8.1.0

See all related issues and PRs in the 8.1.0 milestone.


  • :star2: New NewConstants and RemovedConstants sniffs to detect usage of new/removed PHP constants for all PHP versions from PHP 5 up. #526, #551, #566. Fixes #263.
  • :star2: New MagicAutoloadDeprecation sniff to detect deprecated __autoload() functions as deprecated in PHP 7.2. #540
  • :star2: New OptionalRequiredFunctionParameter sniff to check for missing function call parameters which were required and only became optional in a later PHP version. #524
  • :star2: New DynamicAccessToStatic sniff to detect dynamic access to static methods and properties, as well as class constants, prior to PHP 5.3. #535. Fixes #534.
  • :star: DeprecatedFunctions sniff: recognize yet more PHP 7.2 deprecated functions. #561, #566
  • :star: DeprecatedIniDirectives sniff: recognize the last of the PHP 7.2 deprecated ini directives. #566, #567
  • :star: NewFunctions : detection of all new PHP 7.2 functions added. #522, #545, #551, #565
  • :star: RemovedExtensions : report on usage of the mcrypt extension which has been removed in PHP 7.2. #566
  • :star: RemovedGlobalVariables : detection of the use of $php_errormsg with track_errors which has been deprecated in PHP 7.2. #528
  • :books: Documentation : added reporting usage instructions. #533, #552


  • :pushpin: NewClosures : downgraded "$this found in closure outside class" to warning. #536. Fixes #527.
  • :pushpin: ForbiddenGlobalVariableVariable : the sniff will now throw an error for each variable in a global statement which is no longer supported and show the variable found to make it easier to fix this. Previously only one error would be thrown per global statement. #564
  • :pushpin: ForbiddenGlobalVariableVariable : the sniff will now throw warnings for non-bare variables used in a global statement as those are discouraged since PHP 7.0. #564
  • :rewind: NewLanguageConstructs : updated the version number for T_COALESCE_EQUAL. #523
  • :pencil2: Sniff::getTestVersion() : simplified regex logic. #520
  • :green_heart: Travis : build tests are now being run against PHP 7.2 as well. #511
  • :wrench: Improved check for superfluous whitespaces in files. #542
  • :wrench: Build/PHPCS : stabilized the exclude patterns. #529
  • :wrench: Build/PHPCS : added array indentation check. #538
  • :white_check_mark: PHPCS cross-version compatibility : sync FindExtendedClassname() method with upstream. #507
  • :wrench: The minimum version for the recommended DealerDirect/phpcodesniffer-composer-installer Composer plugin has been upped to 0.4.3. #548


  • :bug: ForbiddenCallTimePassByReference : a false positive was being thrown when a global constant was followed by a bitwise and. #562. Fixes #39.
  • :bug: ForbiddenGlobalVariableVariable : the sniff was overzealous and would also report on global in combination with variable variables which are still supported. #564. Fixes #537.
  • :bug: ForbiddenGlobalVariableVariable : variables interspersed with whitespace and/or comments were not being reported. #564
  • :rewind: ForbiddenNamesAsInvokedFunctions : improved recognition of function invocations using forbidden words and prevent warnings for keywords which are no longer forbidden as method names in PHP 7.0+. #516. Fixes #515
  • :bug: VariableVariables : variables interspersed with whitespace and/or comments were not being reported. #563
  • :umbrella: Fixed some unintentional syntax errors in test files. #539
  • :umbrella: Tests : fixed case numbering error. #525
  • :books: Tests : added missing test skip explanation. #521
  • :wrench: Fixed PHPCS whitespaces. #543
  • :wrench: Fixed code test coverage verification. #550. Fixes #549.


Thanks go out to Juliette Reinders Folmer and Jonathan Van Belle for their contributions to this version. :clap:

Dependencies for 8.1.0

Name Requirement Status
^4.0 || ^5.0 || ^6.0

^2.2 || ^3.0.2

My projects using wimg/php-compatibility

Name Locked version Requirement
You should be logged in to see which of your projects use wimg/php-compatibility.