packagist phpcompatibility/php-compatibility 10.0.0-alpha1
10.0.0-alpha1 - 2025-10-21

latest release: 10.0.0-alpha2
one month ago

IMPORTANT: This release contains breaking changes. Please read and follow the Upgrade guide in the wiki carefully before upgrading!

If you use any of the framework/CMS/polyfill specific rulesets, please use the corresponding release for that package.

Highlighted Changes

  • Policy change: As of this release, PHPCompatibility will no longer support a wide range of PHP_CodeSniffer versions.
    The minimum supported PHP_CodeSniffer version will be raised anytime syntax support for a new PHP feature is added to PHP_CodeSniffer and this syntax support is needed for the PHPCompatibility sniffs.
  • Policy change: As of this release, the only supported manner of installation of PHPCompatibility will be via Composer.
    Installation using git clones or with the PHP_CodeSniffer PHAR files is still possible, but no support will be provided for this.
  • New runtime dependencies:
    • The Composer plugin to register the standard with PHP_CodeSniffer.
    • PHPCSUtils, a library of utility function for PHP_CodeSniffer.
  • All PHPCompatibility sniffs are now final classes.
    • This prevents issues with sniff autoloading.
  • All sniffs are now compatible with PHP_CodeSniffer 3.x as well as 4.0.

Changelog for version 10.0.0-alpha1

See all related issues and PRs in the 10.0.0-alpha1 milestone and in the CHANGELOG file.

Added

  • New dependencies:
  • PHP cross-version:
    • 🌟 New PHPCompatibility.Classes.RemovedClasses sniff. #1062, #1705
  • PHP 5.3:
  • PHP 5.4:
    • 🌟 New PHPCompatibility.ParameterValues.ChangedObStartEraseFlags sniff. #1027, #1371, #1876
    • 🌟 New PHPCompatibility.ParameterValues.NewNumberFormatMultibyteSeparators sniff. #1139, #1380, #1679, #1680
  • PHP 7.0:
    • 🌟 New PHPCompatibility.Numbers.RemovedHexadecimalNumericStrings sniff. #1004, #1366. Fixes #1345
    • 🌟 New PHPCompatibility.ParameterValues.NewAssertCustomException sniff. #1029. Partially fixes #908
    • 🌟 New PHPCompatibility.Syntax.NewNestedStaticAccess sniff. #963, #1262. Fixes #946
  • PHP 7.2:
    • 🌟 New PHPCompatibility.ParameterValues.ForbiddenSessionModuleNameUser sniff. #1138, #1373
    • 🌟 New PHPCompatibility.ParameterValues.RemovedAssertStringAssertion sniff. #1028, #1282. Partially fixes #908
  • PHP 7.4:
    • 🌟 New PHPCompatibility.Numbers.NewNumericLiteralSeparator sniff. #984
    • 🌟 New PHPCompatibility.ParameterValues.RemovedProprietaryCSVEscaping sniff. #1787
  • PHP 8.0:
    • 🌟 New PHPCompatibility.Attributes.NewAttributes sniff. #1279, #1480, #1730, #1926
    • 🌟 New PHPCompatibility.Classes.ForbiddenExtendingFinalPHPClass sniff. #1486, #1739
    • 🌟 New PHPCompatibility.Classes.NewConstructorPropertyPromotion sniff. #1417
    • 🌟 New PHPCompatibility.ControlStructures.NewNonCapturingCatch sniff. #1151
    • 🌟 New PHPCompatibility.FunctionDeclarations.ForbiddenFinalPrivateMethods sniff. #1201
    • 🌟 New PHPCompatibility.FunctionDeclarations.NewTrailingComma sniff. #1164, #1190
    • 🌟 New PHPCompatibility.FunctionDeclarations.RemovedCallingDestructAfterConstructorExit sniff. #1200, #1227, #1283
    • 🌟 New PHPCompatibility.FunctionDeclarations.RemovedOptionalBeforeRequiredParam sniff. #1165, #1206, #1692, #1699, #1886
    • 🌟 New PHPCompatibility.FunctionUse.NewNamedParameters sniff. #1423, #1806, #1807
    • 🌟 New PHPCompatibility.ParameterValues.ChangedIntToBoolParamType sniff. #1232, #1370
    • 🌟 New PHPCompatibility.ParameterValues.ForbiddenGetClassNoArgsOutsideOO sniff. #1602
    • 🌟 New PHPCompatibility.ParameterValues.RemovedGetDefinedFunctionsExcludeDisabledFalse sniff. #1150, #1162, #1386, #1880
    • 🌟 New PHPCompatibility.ParameterValues.RemovedSplAutoloadRegisterThrowFalse sniff. #1181, #1391, #1882
    • 🌟 New PHPCompatibility.Syntax.InterpolatedStringDereferencing sniff. #1242
    • 🌟 New PHPCompatibility.Syntax.NewMagicConstantDereferencing sniff. #1233
  • PHP 8.1:
    • 🌟 New PHPCompatibility.Classes.NewFinalConstants sniff. #1317, #1496, #1629
    • 🌟 New PHPCompatibility.Classes.NewReadonlyProperties sniff. #1426
    • 🌟 New PHPCompatibility.FunctionDeclarations.RemovedReturnByReferenceFromVoid sniff. #1316, #1560
    • 🌟 New PHPCompatibility.InitialValue.NewNewInDefine sniff. #1465
    • 🌟 New PHPCompatibility.InitialValue.NewNewInInitializers sniff. #1464
    • 🌟 New PHPCompatibility.Interfaces.RemovedSerializable sniff. #1330
    • 🌟 New PHPCompatibility.Numbers.NewExplicitOctalNotation sniff. #1420
    • 🌟 New PHPCompatibility.ParameterValues.NewArrayMergeRecursiveWithGlobalsVar sniff. #1488
    • 🌟 New PHPCompatibility.ParameterValues.NewHTMLEntitiesFlagsDefault sniff. #1419
    • 🌟 New PHPCompatibility.ParameterValues.RemovedMbCheckEncodingNoArgs sniff. #1315
    • 🌟 New PHPCompatibility.ParameterValues.RemovedVersionCompareOperators sniff. #1418
    • 🌟 New PHPCompatibility.Syntax.NewFirstClassCallables sniff. #1425, #1807
    • 🌟 New PHPCompatibility.Variables.RemovedIndirectModificationOfGlobals sniff. #1487
  • PHP 8.2:
    • 🌟 New PHPCompatibility.Classes.NewReadonlyClasses sniff. #1453, #1686
    • 🌟 New PHPCompatibility.Constants.NewConstantsInTraits sniff. #1443
    • 🌟 New PHPCompatibility.ParameterValues.RemovedGetClassNoArgss sniff. #1614
    • 🌟 New PHPCompatibility.ParameterValues.RemovedLdapConnectSignatures sniff. #1620, #1671, #1881
    • 🌟 New PHPCompatibility.ParameterValues.RemovedMbStrimWidthNegativeWidth sniff. #1615
    • 🌟 New PHPCompatibility.TextStrings.RemovedDollarBraceStringEmbeds sniff. #1424
  • PHP 8.3:
    • 🌟 New PHPCompatibility.Classes.NewTypedConstants sniff. #1808
    • 🌟 New PHPCompatibility.Generators.NewYieldFromComment sniff. #1792, #1812
  • PHP 8.4:
    • 🌟 New PHPCompatibility.Classes.ForbiddenClassNameUnderscore sniff. #1742
    • 🌟 New PHPCompatibility.Classes.NewAbstractProperties sniff. #1901
    • 🌟 New PHPCompatibility.Classes.NewFinalProperties sniff. #1815
    • 🌟 New PHPCompatibility.FunctionDeclarations.RemovedImplicitlyNullableParam sniff. #1689, #1694, #1897
    • 🌟 New PHPCompatibility.Interfaces.NewPropertiesInInterfaces sniff. #1814
    • 🌟 New PHPCompatibility.ParameterValues.NewExitAsFunctionCall sniff. #1807, #1923
    • 🌟 New PHPCompatibility.ParameterValues.RemovedDbaKeySplitNullFalse sniff. #1745, #1879
    • 🌟 New PHPCompatibility.ParameterValues.RemovedTriggerErrorLevel sniff. #1741
    • 🌟 New PHPCompatibility.ParameterValues.RemovedXmlSetHandlerCallbackUnset sniff. #1744
    • 🌟 New PHPCompatibility.Syntax.NewClassMemberAccessWithoutParentheses sniff. #1903
  • PHPCompatibility.Constants.NewMagicClassConstant: detection of $obj::class as allowed since PHP 8.0. #1166
  • PHPCompatibility.Operators.NewOperators: detection of the PHP 8.0 nullsafe object operator. #1210
  • ⭐ All "list based" sniffs, like NewFunctions, RemovedIniDirectives, ForbiddenNames etc, have received updates to account for more new/deprecated/removed PHP classes, constants, functions, function parameters, hash algorithms, interfaces, ini directives, reserved keywords and type casts.
    The listed information in these sniffs has also received general accuracy and completeness updates.
  • ⭐ All type declaration related sniffs have received updates to account for new type keywords (like mixed and never) and new type syntaxes (union, intersection and DNF types) introduced in PHP.
  • ⭐ A number of Helper classes and traits (for internal use only - see #1484).
  • 📚 Documentation for the following sniffs:
    • PHPCompatibility.Classes.NewConstVisibility #1323
    • PHPCompatibility.FunctionNameRestrictions.RemovedPHP4StyleConstructors #1292
    • PHPCompatibility.FunctionNameRestrictions.ReservedFunctionNames #1293
    • PHPCompatibility.FunctionUse.ArgumentFunctionsReportCurrentValue #1294
    • PHPCompatibility.ParameterValues.RemovedPCREModifiers #1295
    • PHPCompatibility.UseStatements.NewGroupUseDeclarations #1470
    • PHPCompatibility.UseStatements.NewUseConstFunction #1470
    • PHPCompatibility.Variables.NewUniformVariableSyntax #1539
    • Additionally, nearly all newly added sniffs include documentation.

Changed

  • 💕 All sniffs are now cross-version compatibility with both PHP_CodeSniffer 3.x as well as 4.x. #1911
  • 🔥 All PHPCompatibility sniffs are now final classes. #1261, #1273, #1875. Fixes #608, #638, #793, #1042
    Sniffs extending other sniffs can cause problems with the autoloading in PHP_CodeSniffer, leading to "class already declared" errors.
  • 🔀 The PHPCompatibility.Classes.ForbiddenAbstractPrivateMethods sniff has been renamed to PHPCompatibility.FunctionDeclarations.AbstractPrivateMethods and now also detects the PHP 8.0 change to allow abstract private methods in traits. #1149
  • 🔀 The PHPCompatibility.Miscellaneous.ValidIntegers has been moved to the Numbers category and is now called PHPCompatibility.Numbers.ValidIntegers. #1004
  • 🔀 The check for the PHP 7.0 change in how hexadecimal numeric strings are handled, has been removed from the PHPCompatibility.Miscellaneous.ValidIntegers sniff and now lives in a dedicated sniff, called PHPCompatibility.Numbers.RemovedHexadecimalNumericStrings. #1004
  • 🔀 PHPCompatibility.FunctionDeclarations.NewParamTypeDeclarations: the InvalidTypeHintFound error code has been split into two error codes. #1727. Fixes #1726
    • The InvalidTypeHintFound error code remains in effect for types which are invalid in a parameter context.
    • The new InvalidLongTypeFound error code will now warn about the use of "long" types, which are likely typos, but could be valid class names.
  • 🔀 PHPCompatibility.Classes.NewTypedProperties: the InvalidType error code has been split into two error codes. #1728
    • The InvalidType error code remains in effect for types which are invalid in a property context.
    • The new InvalidLongType error code will now warn about the use of "long" types, which are likely typos, but could be valid class names.
  • 💚 PHPCompatibility.Upgrade.LowPHP: the minimum recommended PHP version is now 7.2.0. #1550
  • 📌 The testVersion configuration variable will now also be recognized when provided in lowercase (testversion). #969
  • 📌 Passing an invalid testVersion will now result in either an InvalidTestVersion or an InvalidTestVersionRange Exception being thrown. #1548
  • 📌 A lot of the sniffs have had updates to handle various new PHP syntaxes and features.
    ⚠️ Note: this task is not yet complete, so some sniffs may still throw false positives/negatives when confronted with modern PHP.
  • 📌 MiscHelper::isUseOfGlobalConstant() will no longer recognize constant declarations as "use of". #1888
  • 📌 Both the PHPCompatibility.Constants.NewConstants as well as the PHPCompatibility.Constants.RemovedConstants sniffs now special case the handling of the T_BAD_CHARACTER constant, which was removed from PHP in PHP 7.0, but then re-introduced in PHP 7.4. #1586. Fixes #1351
  • 📌 PHPCompatibility.Classes.RemovedOrphanedParent the $classScopeTokens property is now private, it should never have been public in the first place. #983
  • 📌 PHPCompatibility.Classes.RemovedOrphanedParent will now also flag parent when used as a type declaration in an interface. #1499
  • 📌 PHPCompatibility.ControlStructures.NewExecutionDirectives now more accurately determines whether the value of a directive is valid. #1416
  • 📌 PHPCompatibility.FunctionDeclarations.NonStaticMagicMethods will now also flag incorrect modifiers for the __wakeup() method, as enforced by PHP since PHP 8.0. #1821
  • 📌 PHPCompatibility.FunctionNameRestrictions.RemovedPHP4StyleConstructors will not report on PHP-4 style constructors if the minimum supported PHP version, as indicated via testVersion, is PHP 8.0 or higher, as on PHP 8.0 the concept of PHP-4 style constructors no longer exists in PHP. #1563
  • 📌 PHPCompatibility.FunctionNameRestrictions.ReservedFunctionNames will now bow out for the PHP 7.4 __serialize() and __unserialize() magic methods. #1142
  • 📌 PHPCompatibility.FunctionNameRestrictions.ReservedFunctionNames will now ignore deprecated functions more consistently. #1564
  • 📌 PHPCompatibility.FunctionUse.ArgumentFunctionsReportCurrentValue will now throw an error, instead of a warning, when a passed parameter is unset(). #1286
  • 📌 PHPCompatibility.FunctionUse.ArgumentFunctionsReportCurrentValue will now recognize and handle numeric $options being passed to the target function calls. #1892
  • 📌 PHPCompatibility.FunctionUse.ArgumentFunctionsReportCurrentValue will now warn against the use of debug_*backtrace() as a PHP 8.1+ first class callable. #1892
  • 📌 PHPCompatibility.Interfaces.InternalInterfaces will now also flag internal interfaces which cannot be extended when used in an extends clause. #1566
  • 📌 PHPCompatibility.Interfaces.NewInterfaces will now detect interfaces used in catch conditions. #968. Fixes #967
  • 📌 PHPCompatibility.Interfaces.NewInterfaces will now also detect new interfaces when used in an extends clause. #1259
  • 📌 PHPCompatibility.Keywords.ForbiddenNames will no longer report on reserved keywords being used in a namespace name as allowed since PHP 8.0 (reporting depends on the testVersion passed). #1402
  • 📌 PHPCompatibility.Keywords.ForbiddenNames will now strictly only flag forbidden names at the point of declaration. #1368
  • 📌 PHPCompatibility.Keywords.ForbiddenNames will now also check for declarations using "other" and soft reserved keywords. #1399
    This was previously checked via the PHPCompatibility.Keywords.ForbiddenNamesAsDeclared sniff (now removed).
  • 📌 PHPCompatibility.Keywords.ForbiddenNames will not flag keywords, introduced in PHP 7.0 or later, when used as method or OO constant names, as this is not a compatibility issue. #1633, #1641
  • 📌 PHPCompatibility.Keywords.ForbiddenNames will not flag keywords, introduced in PHP 8.0 or later, when used in a namespace name, as this is not a compatibility issue. #1641
  • 📌 PHPCompatibility.ParameterValues.NewHTMLEntitiesEncodingDefault: will now also sniff for affected function calls to get_html_translation_table(). #1041
  • 📌 PHPCompatibility.Syntax.NewFunctionCallTrailingComma will now also detect trailing commas in exit/die as function calls (PHP 8.4+). #1807
  • ✏️ Various sniffs which would warn for the use of a deprecated feature have been updated to throw an error for PHP 8.0 having removed these features.
  • ✏️ The error messages of various sniffs have been improved.
    In some cases, the line on which the error is thrown may have changed to flag the problematic code with higher precision.
  • ✏️ The error levels (warning vs error) used in all sniffs have been reviewed and made consistent. #1282. Fixes #1163
    PHP deprecations should translate to a warning from PHPCompatibility, PHP removals and new features should translate to an error.
    This also impacts some of the error codes as detailed in the upgrade guide.
  • ✏️ The error codes of various (modular) warnings/errors have changed in light of parameter name renames done in PHP Core to support named arguments in PHP 8.0.
  • ✏️ Various sniffs no longer get confused over comments in unexpected places.
  • ✏️ Various sniffs now have improved parse error/live coding tolerance.
  • 🔧 Composer: a replace directive has been added to discourage use of the old package name. #976
  • 🔧 Composer: The package will now identify itself as a static analysis tool. #1346
  • 🔧 ☔ Various housekeeping, including general maintenance, improvements to speed up the sniffs, improvements to CI, the tests and documentation.

Removed

  • 🚫 Support for PHP 5.3. #956. Fixes #835
  • 🚫 Support for PHP_CodeSniffer < 3.13.3. #956, #1352, #1355, #1662, #1686, #1714, #1806, #1900. Fixes #835, #1347
  • 🚫 PHPCompatibility.Keywords.ForbiddenNamesAsInvokedFunctions sniff. #1367. Fixes #105, #1024
  • 🚫 PHPCompatibility.Keywords.ForbiddenNamesAsDeclared sniff. #1399. Fixes #1024
  • 🚫 PHPCompatibility.Upgrade.LowPHPCS sniff. #1549
  • 🚫 PHPCompatibility\PHPCSHelper class in favour of PHPCSUtils. #979
  • 🚫 PHPCompatibility\AbstractComplexVersionSniff class in favour of internal Helper traits. #1406
  • 🚫 PHPCompatibility\AbstractNewFeatureSniff class in favour of internal Helper traits. #1406
  • 🚫 PHPCompatibility\AbstractRemovedFeatureSniff class in favour of internal Helper traits. #1406
  • 🚫 PHPCompatibility\ComplexVersionInterface class in favour of internal Helper traits. #1406
  • 🚫 PHPCompatibility\Sniff::addMessage() in favour of PHPCSUtils. #1363
  • 🚫 PHPCompatibility\Sniff::arrayKeysToLowercase(). Use the PHP native array_change_key_case() function instead. #979
  • 🚫 PHPCompatibility\Sniff::determineNamespace() in favour of PHPCSUtils. #979
  • 🚫 PHPCompatibility\Sniff::doesFunctionCallHaveParameters() in favour of PHPCSUtils. #979
  • 🚫 PHPCompatibility\Sniff::getCompleteTextString() in favour of PHPCSUtils. #979
  • 🚫 PHPCompatibility\Sniff::getDeclaredNamespaceName() in favour of PHPCSUtils. #979
  • 🚫 PHPCompatibility\Sniff::getFQClassNameFromDoubleColonToken() in favour of an internal Helper class. #1571
  • 🚫 PHPCompatibility\Sniff::getFQClassNameFromNewToken() in favour of an internal Helper class. #1571
  • 🚫 PHPCompatibility\Sniff::getFQExtendedClassName() in favour of an internal Helper class. #1571
  • 🚫 PHPCompatibility\Sniff::getFQName() in favour of an internal Helper class. #1571
  • 🚫 PHPCompatibility\Sniff::getFunctionCallParameter() in favour of PHPCSUtils. #979
  • 🚫 PHPCompatibility\Sniff::getFunctionCallParameters() in favour of PHPCSUtils. #979
  • 🚫 PHPCompatibility\Sniff::getFunctionCallParameterCount() in favour of PHPCSUtils. #979
  • 🚫 PHPCompatibility\Sniff::getHashAlgorithmParameter() in favour of an internal Helper trait. #1250
  • 🚫 PHPCompatibility\Sniff::getReturnTypeHintName() in favour of PHPCSUtils. #1448
  • 🚫 PHPCompatibility\Sniff::getReturnTypeHintToken() in favour of PHPCSUtils. #1448
  • 🚫 PHPCompatibility\Sniff::getTypeHintsFromFunctionDeclaration() in favour of PHPCSUtils. #1448
  • 🚫 PHPCompatibility\Sniff::inClassScope() in favour of PHPCSUtils. #1429
  • 🚫 PHPCompatibility\Sniff::isClassProperty() in favour of PHPCSUtils. #979
  • 🚫 PHPCompatibility\Sniff::isClassConstant() in favour of PHPCSUtils. #979
  • 🚫 PHPCompatibility\Sniff::isNamespaced() without replacement. #1551
  • 🚫 PHPCompatibility\Sniff::isNegativeNumber() in favour of an internal Helper class. #1493, #1567
  • 🚫 PHPCompatibility\Sniff::isNumber() in favour of an internal Helper class. #1493, #1567
  • 🚫 PHPCompatibility\Sniff::isNumericCalculation() in favour of an internal Helper class. #1568
  • 🚫 PHPCompatibility\Sniff::isPositiveNumber() in favour of an internal Helper class. #1493, #1567
  • 🚫 PHPCompatibility\Sniff::isShortList() in favour of PHPCSUtils. #979
  • 🚫 PHPCompatibility\Sniff::isShortTernary() in favour of PHPCSUtils. #979
  • 🚫 PHPCompatibility\Sniff::isUnaryPlusMinus() in favour of PHPCSUtils. #979
  • 🚫 PHPCompatibility\Sniff::isUseOfGlobalConstant() in favour of an internal Helper class. #1572
  • 🚫 PHPCompatibility\Sniff::isVariable() in favour of an internal Helper class. #1570
  • 🚫 PHPCompatibility\Sniff::stringToErrorCode() in favour of PHPCSUtils. #1363
  • 🚫 PHPCompatibility\Sniff::stripQuotes() in favour of PHPCSUtils. #979
  • 🚫 PHPCompatibility\Sniff::stripVariables() in favour of PHPCSUtils. #1398
  • 🚫 PHPCompatibility\Sniff::supportsAbove() in favour of an internal Helper class. #1237, #1555
  • 🚫 PHPCompatibility\Sniff::supportsBelow() in favour of an internal Helper class. #1237, #1555
  • 🚫 PHPCompatibility\Sniff::tokenHasScope() in favour of PHPCSUtils. #979
  • 🚫 PHPCompatibility\Sniff::validDirectScope() in favour of PHPCSUtils. #979
  • 🚫 PHPCompatibility\Sniff::$iniFunctions without replacement. #1251
  • 🚫 PHPCompatibility\Sniff::$hashAlgoFunctions in favour of an internal Helper trait. #1250
  • 🚫 PHPCompatibility\Sniff::$superglobals in favour of PHPCSUtils. #1018
  • 🚫 PHPCompatibility\Sniff::REGEX_COMPLEX_VARS in favour of PHPCSUtils. #1398

Fixed

  • 🐛 Deprecation notice in testVersion handling when running on PHP 8.1+. #1276
  • 🐛 Sniffs looking for function calls will now determine more accurately if whatever is being looked at, is actually a (non-namespaced) function call. #962, related to #961
  • 🐛 Various sniffs explicitly looking for/ignoring null/true/false could get confused over fully qualified and/or non-lowercase use of these keywords. #1877, #1902, #1906
  • 🐛 PHPCompatibility.Classes.NewClasses will no longer throw false positives for imported namespaced classes with a class name overlapping one of the new global PHP classes. #1695. Fixes #1291
  • 🐛 PHPCompatibility.Classes.NewClasses and PHPCompatibility.Classes.RemovedClasses did not always correctly correlate the class name from self. #1893
  • 🐛 PHPCompatibility.Classes.NewLateStaticBinding did not flag instanceof static or `new static. #957
  • 🐛 PHPCompatibility.Classes.NewTypedProperties PHP native build-in types should be handled case-insensitively. #1205
  • 🐛 PHPCompatibility.Classes.NewTypedProperties false negative for edge case where a property declaration would be closed via a PHP close tag. #1703
  • 🐛 PHPCompatibility.Classes.RemovedClasses will no longer throw false positives for imported namespaced classes with a class name overlapping one of the new global PHP classes. #1924
  • 🐛 PHPCompatibility.Classes.RemovedOrphanedParent could get confused over an upstream tokenizer issue when a function declared to return by reference would be called "parent". #1499. Fixes #1489
  • 🐛 PHPCompatibility.Constants.NewConstants and PHPCompatibility.Constants.RemovedConstants will throw fewer false positives for constructs which are not a global constant, but mirror the name of a PHP constant. #1888
  • 🐛 PHPCompatibility.Constants.NewMagicClassConstant would incorrectly flag static function calls to a method called class. #1500
  • 🐛 PHPCompatibility.ControlStructures.NewExecutionDirectives: directive names should be handled case-insensitively. #1416
  • 🐛 PHPCompatibility.ControlStructures.NewExecutionDirectives: multi-directive statements were not analyzed correctly. #1416
  • 🐛 PHPCompatibility.FunctionDeclarations.ForbiddenParametersWithSameName did not examine abstract methods or interface methods. #991
  • 🐛 PHPCompatibility.FunctionDeclarations.NewClosure could get confused over $this and self being used in nested closed structures in the body of the closure. #1928
  • 🐛 PHPCompatibility.FunctionDeclarations.NewParamTypeDeclarations did not examine nested function declarations. #996
  • 🐛 PHPCompatibility.FunctionDeclarations.NewParamTypeDeclarations PHP native build-in types should be handled case-insensitively. #1203
  • 🐛 PHPCompatibility.FunctionDeclarations.NewParamTypeDeclarations would incorrectly throw the OutsideClassScopeFound error for PHP < 5.2. #1203
  • 🐛 PHPCompatibility.FunctionDeclarations.NewReturnTypeDeclarations PHP native build-in types should be handled case-insensitively. #1204
  • 🐛 PHPCompatibility.FunctionDeclarations.NonStaticMagicMethods would incorrectly flag non-public __destruct() methods as having the wrong visibility. #1543. Fixes #1542
  • 🐛 PHPCompatibility.FunctionNameRestrictions.RemovedNamespacedAssert did not handle nested function declarations correctly. #1169
  • 🐛 PHPCompatibility.FunctionNameRestrictions.ReservedFunctionNames did not handle nested function declarations correctly. #1142
  • 🐛 PHPCompatibility.FunctionUse.ArgumentFunctionsUsage: TypeError when run on PHP 8.0+. #1213
  • 🐛 PHPCompatibility.FunctionUse.ArgumentFunctionsUsage would throw false positives for namespaced functions mirroring a name of a target function of the sniff. #1890
  • 🐛 PHPCompatibility.FunctionUse.ArgumentFunctionsUsage could get confused over a method declared to return by reference. #1890
  • 🐛 PHPCompatibility.FunctionUse.ArgumentFunctionsReportCurrentValue: prevent false positive when passed parameter is used in a return, exit or throw statement. #1208, #1286. Fixes #1207
  • 🐛 PHPCompatibility.FunctionUse.ArgumentFunctionsReportCurrentValue: prevent false positive when passed parameter is used in isset() or empty(). #1286
  • 🐛 PHPCompatibility.FunctionUse.ArgumentFunctionsReportCurrentValue: prevent false positive when passed parameter is only assigned to another variable in a "simple assignment". #1286. Fixes #1240
  • 🐛 PHPCompatibility.FunctionUse.ArgumentFunctionsReportCurrentValue would incorrectly ignore function calls when passed a namespaced constant mirroring the global DEBUG_BACKTRACE_IGNORE_ARGS constant. #1892
  • 🐛 PHPCompatibility.FunctionUse.ArgumentFunctionsReportCurrentValue will now check for calls to array_slice()/array_splice() case-insensitively and will prevent false negatives if a namespaced function is encountered mirroring the global PHP function we're looking for. #1892
  • 🐛 PHPCompatibility.FunctionUse.ArgumentFunctionsReportCurrentValue now recognizes and handles negative offsets passed to array_slice()/array_splice() correctly. #1892
  • 🐛 PHPCompatibility.FunctionUse.ArgumentFunctionsReportCurrentValue now recognizes and handles the $length parameter if passed to array_slice()/array_splice(). #1892
  • 🐛 PHPCompatibility.FunctionUse.ArgumentFunctionsReportCurrentValue did not handle (parameter overrides via) list assignments correctly. #1892
  • 🐛 PHPCompatibility.FunctionUse.ArgumentFunctionsReportCurrentValue will now more often recognize when a parameter is touched, but not changed when the parameter is used in a control structure condition. #1892
  • 🐛 PHPCompatibility.Interfaces.InternalInterfaces will no longer throw false positives for imported namespaced classes with a class name overlapping one of the new global PHP classes. #1700. Fixes #1649
  • 🐛 PHPCompatibility.Interfaces.NewInterfaces did not handle nested function declarations correctly. #1259
  • 🐛 PHPCompatibility.Interfaces.NewInterfaces will no longer throw false positives for imported namespaced classes with a class name overlapping one of the new global PHP classes. #1700
  • 🐛 PHPCompatibility.InitialValue.NewConstantArraysUsingDefine could get confused over namespaced function calls and class instantiations. #1518
  • 🐛 PHPCompatibility.InitialValue.NewConstantArraysUsingDefine could fail to detect array values in a compound parameter. #1518
  • 🐛 PHPCompatibility.InitialValue.NewConstantArraysUsingDefine could throw false positives for constants with a closure/arrow function callback as its value. #1518
  • 🐛 PHPCompatibility.Keywords.ForbiddenNames did not handle nested function declarations correctly. #1368
  • 🐛 PHPCompatibility.Keywords.ForbiddenNames did not always flag keywords used in a namespace name correctly. #1368
  • 🐛 PHPCompatibility.Keywords.ForbiddenNames did not always flag aliases in import multi-use, group use and trait use statements correctly. #1368
  • 🐛 PHPCompatibility.Lists.ForbiddenEmptyListAssignment: false positive for a hard-coded empty (sub-)array in a foreach iterable expression. #1401. Fixes #1341
  • 🐛 PHPCompatibility.ParameterValues.NewFopenModes could throw false positives for dynamically generated parameter values. #1045
  • 🐛 PHPCompatibility.ParameterValues.NewIconvMbstringCharsetDefault now examines each array item in the $options parameter individually to prevent false negatives. #1588
  • 🐛 PHPCompatibility.ParameterValues.NewIconvMbstringCharsetDefault would throw false positives for the $encoding parameter not being explicitly passed on functions which didn't exist in PHP 5.6 (when the default value of the parameter was changed). #1779. Fixes #1777
  • 🐛 PHPCompatibility.ParameterValues.NewPackFormat could throw false positives for dynamically generated parameter values. #1044. Fixes #1043
  • 🐛 PHPCompatibility.ParameterValues.NewPasswordAlgoConstantValues could throw false positives for dynamically generated parameter values. #1531
  • 🐛 PHPCompatibility.ParameterValues.NewPCREModifiers and PHPCompatibility.ParameterValues.RemovedPCREModifiers could throw false positives for dynamically generated parameter values. #1764
  • 🐛 PHPCompatibility.ParameterValues.NewProcOpenCmdArray could fail to warn about the use of escapeshellarg() when the PHP 7.4 array format for the $command parameter is used, if the function call was not in lowercase. #1878
  • 🐛 PHPCompatibility.ParameterValues.RemovedIconvEncoding: TypeError when run on PHP 8.0+. #1212
  • 🐛 PHPCompatibility.ParameterValues.RemovedMbstringModifiers could throw false positives for dynamically generated parameter values. #1046
  • 🐛 PHPCompatibility.ParameterValues.RemovedMbStrrposEncodingThirdParam could throw both false positives as well as have false negatives for dynamically generated parameter values. #1722. Fixes #1721
  • 🐛 PHPCompatibility.ParameterValues.RemovedNonCryptoHashSniff did not handle a fully qualified HASH_HMAC constant as a parameter value correctly. #1532
  • 🐛 PHPCompatibility.ParameterValues.RemovedSetlocaleString could throw false positives for dynamically generated parameter values. #1047
  • 🐛 PHPCompatibility.Syntax.ForbiddenCallTimePassByReference was not recognized for anonymous class instantiations and class instantiations using hierarchy keywords. #1912
  • 🐛 PHPCompatibility.Syntax.NewFlexibleHeredocNowdoc the ClosingMarkerNoNewLine error code was inadvertently used for two different errors. This error code has now been split into ClosingMarkerNoNewLine and CloserFoundInBody. #1697. Fixes #1696
  • 🐛 PHPCompatibility.Syntax.NewFunctionCallTrailingComma would throw a false positive for a trailing comma in a function declaration if the function was declared to return by reference. #1534
  • 🐛 PHPCompatibility.Syntax.NewFunctionCallTrailingComma false negative on trailing comma in class instantiations. #1534
  • 🐛 PHPCompatibility.Syntax.NewShortArray would incorrectly also flag short lists. #1010
  • 🐛 PHPCompatibility.Syntax.RemovedCurlyBraceArrayAccess did not flag curly brace array access on a namespaced constant. #1889
  • 🐛 PHPCompatibility.UseDeclarations.NewUseConstFunction could throw false positive in some parse error edge cases. #1537
  • 🐛 PHPCompatibility.Variables.ForbiddenThisUseContexts false positive for use of $this in unset(), while $this is not the variable being unset. #1670. Fixes #1666
  • 🐛 PHPCompatibility.Variables.NewUniformVariableSyntax did not handle static access using the hierarchy keywords correctly. #1013
  • 🐛 PHPCompatibility.Variables.RemovedPredefinedGlobalVariables false positive on static access to class property shadowing the name of one of the removed global variables. #1014
  • 🐛 PHPCompatibility.Variables.RemovedPredefinedGlobalVariables did not correctly limit the scope of the token walking to determine whether $php_errormsg was the deprecated global variable. #1014

Credits

Thanks go out to @afilina, @bebehr, @diedexx, @elazar, @Flyingmana, @fredden, @GaryJones, @hugovk, @kporras07, @MarkMaldaba, @magikstm, @rdss-sknott, @stevegrunwell, @stronk7 and @zeriyoshi for their contributions to this version. 👏

Additionally thanks go out to everyone who has been testing the develop branch and has reported issues to help us get to where we are now.

Don't miss a new php-compatibility release

NewReleases is sending notifications on new releases.