phpcompatibility/php-compatibility
PHPCompatibility is a PHP_CodeSniffer ruleset that scans PHP code for cross-version compatibility issues. Check support for specific PHP versions, detect deprecated/removed features, and audit projects when upgrading or maintaining multi-version support.
IMPORTANT: This release contains breaking changes. Please read and follow the [Upgrade guide in the wiki][wiki-upgrade-to-10.0] carefully before upgrading!
This release includes all improvements and bugfixes from PHPCompatibility [10.0.0-alpha1].
See all related issues and PRs in the [10.0.0-alpha2 milestone].
PHP cross-version:
PHP 8.3:
PHP 8.5:
PHPCompatibility.Classes.NewStaticAvizProperties sniff. #1950:star: PHPCompatibility.Classes.NewClasses sniff: recognize the new DateTime and SQLite extension related error and exception classes as introduced in PHP 8.3. #1936, #1937
:star: PHPCompatibility.Constants.NewConstants sniff: recognize various constants from the Mhash extension. #1938
:star: PHPCompatibility.ParameterValues.ChangedIntToBoolParamType sniff: detect the Zlib $use_include_path parameter type change as per PHP 8.5. #1949
:star: The "list based" sniffs, like NewFunctions, RemovedIniDirectives, ForbiddenNames etc, have received updates to account for new/deprecated/removed PHP classes, constants, functions, function parameters, ini directives, reserved namespaces and type casts as per PHP 8.5.
#1941, #1942, #1943, #1944, #1945, #1946, #1947, #1953, #1954, #1955, #1956, #1957, #1958, #1959, #1960, #1961, #1962, #1963, #1965, #1966, #1967, #1968, #1969, #1970, #1971
:books: Documentation for the following sniffs:
:twisted_rightwards_arrows: PHPCompatibility.TypeCasts.RemovedTypeCasts has new error codes. #1941
t_unset_castDeprecatedRemoved has been changed to unsetDeprecatedRemoved.t_double_castDeprecatedRemoved has been changed to realDeprecatedRemoved.:pushpin: PHPCompatibility.Keywords.ForbiddenNames will now also detect incompatible use of the "other" reserved keywords parent and self. #1940
:wrench: :umbrella: Various housekeeping, including general maintenance, improvements to speed up the sniffs, improvements to CI, the tests and documentation.
#1934, #1939, #1964, #1973, #1976, #1983, #1984, #1993, #1995, #1998, #1999
Thanks go out to [Anna Filina] and [Shota Okunaka] for their contributions to this version. :clap:
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.
final classes.
See all related issues and PRs in the [10.0.0-alpha1 milestone].
New dependencies:
PHP cross-version:
PHP 5.3:
PHP 5.4:
PHP 7.0:
PHP 7.2:
PHP 7.4:
PHP 8.0:
PHPCompatibility.Attributes.NewAttributes sniff. #1279, #1480, #1730, #1926PHPCompatibility.Classes.ForbiddenExtendingFinalPHPClass sniff. #1486, #1739PHPCompatibility.Classes.NewConstructorPropertyPromotion sniff. #1417PHPCompatibility.ControlStructures.NewNonCapturingCatch sniff. #1151PHPCompatibility.FunctionDeclarations.ForbiddenFinalPrivateMethods sniff. #1201PHPCompatibility.FunctionDeclarations.NewTrailingComma sniff. #1164, #1190PHPCompatibility.FunctionDeclarations.RemovedCallingDestructAfterConstructorExit sniff. #1200, #1227, #1283PHPCompatibility.FunctionDeclarations.RemovedOptionalBeforeRequiredParam sniff. #1165, #1206, #1692, #1699, #1886PHPCompatibility.FunctionUse.NewNamedParameters sniff. #1423, #1806, #1807PHPCompatibility.ParameterValues.ChangedIntToBoolParamType sniff. #1232, #1370PHPCompatibility.ParameterValues.ForbiddenGetClassNoArgsOutsideOO sniff. #1602PHPCompatibility.ParameterValues.RemovedGetDefinedFunctionsExcludeDisabledFalse sniff. #1150, #1162, #1386, #1880PHPCompatibility.ParameterValues.RemovedSplAutoloadRegisterThrowFalse sniff. #1181, #1391, #1882PHPCompatibility.Syntax.InterpolatedStringDereferencing sniff. #1242PHPCompatibility.Syntax.NewMagicConstantDereferencing sniff. #1233PHP 8.1:
PHPCompatibility.Classes.NewFinalConstants sniff. #1317, #1496, #1629PHPCompatibility.Classes.NewReadonlyProperties sniff. #1426PHPCompatibility.FunctionDeclarations.RemovedReturnByReferenceFromVoid sniff. #1316, #1560PHPCompatibility.InitialValue.NewNewInDefine sniff. #1465PHPCompatibility.InitialValue.NewNewInInitializers sniff. #1464PHPCompatibility.Interfaces.RemovedSerializable sniff. #1330PHPCompatibility.Numbers.NewExplicitOctalNotation sniff. #1420PHPCompatibility.ParameterValues.NewArrayMergeRecursiveWithGlobalsVar sniff. #1488PHPCompatibility.ParameterValues.NewHTMLEntitiesFlagsDefault sniff. #1419PHPCompatibility.ParameterValues.RemovedMbCheckEncodingNoArgs sniff. #1315PHPCompatibility.ParameterValues.RemovedVersionCompareOperators sniff. #1418PHPCompatibility.Syntax.NewFirstClassCallables sniff. #1425, #1807PHPCompatibility.Variables.RemovedIndirectModificationOfGlobals sniff. #1487PHP 8.2:
PHPCompatibility.Classes.NewReadonlyClasses sniff. #1453, #1686PHPCompatibility.Constants.NewConstantsInTraits sniff. #1443PHPCompatibility.ParameterValues.RemovedGetClassNoArgss sniff. #1614PHPCompatibility.ParameterValues.RemovedLdapConnectSignatures sniff. #1620, #1671, #1881PHPCompatibility.ParameterValues.RemovedMbStrimWidthNegativeWidth sniff. #1615PHPCompatibility.TextStrings.RemovedDollarBraceStringEmbeds sniff. #1424PHP 8.3:
PHP 8.4:
PHPCompatibility.Classes.ForbiddenClassNameUnderscore sniff. #1742PHPCompatibility.Classes.NewAbstractProperties sniff. #1901PHPCompatibility.Classes.NewFinalProperties sniff. #1815PHPCompatibility.FunctionDeclarations.RemovedImplicitlyNullableParam sniff. #1689, #1694, #1897PHPCompatibility.Interfaces.NewPropertiesInInterfaces sniff. #1814PHPCompatibility.ParameterValues.NewExitAsFunctionCall sniff. #1807, #1923PHPCompatibility.ParameterValues.RemovedDbaKeySplitNullFalse sniff. #1745, #1879PHPCompatibility.ParameterValues.RemovedTriggerErrorLevel sniff. #1741PHPCompatibility.ParameterValues.RemovedXmlSetHandlerCallbackUnset sniff. #1744PHPCompatibility.Syntax.NewClassMemberAccessWithoutParentheses sniff. #1903:star: PHPCompatibility.Constants.NewMagicClassConstant: detection of $obj::class as allowed since PHP 8.0. #1166
:star: PHPCompatibility.Operators.NewOperators: detection of the PHP 8.0 nullsafe object operator. #1210
:star: 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.
#985, #1031, #1032, #1033, #1034, #1035, #1036, #1037, #1038, #1039, #1040, #1048, #1049, #1050, #1051, #1052, #1053, #1054, #1055, #1056, #1057, #1058, #1059, #1060, #1061, #1062, #1063, #1064, #1065, #1066, #1067, #1068, #1069, #1070, #1071, #1072, #1073, #1074, #1075, #1076, #1077, #1078, #1079, #1080, #1081, #1082, #1083, #1084, #1085, #1086, #1087, #1088, #1089, #1090, #1091, #1092, #1093, #1094, #1095, #1096, #1097, #1098, #1099, #1100, #1101, #1102, #1103, #1104, #1105, #1106, #1107, #1108, #1109, #1110, #1111, #1112, #1113, #1114, #1115, #1116, #1117, #1118, #1119, #1120, #1121, #1122, #1123, #1124, #1125, #1126, #1127, #1128, #1129, #1130, #1131, #1132, #1133, #1134, #1135, #1153, #1161, #1182, #1183, #1184, #1185, #1186, #1187, #1191, #1195, #1196, #1197, #1198, #1199, #1202, #1210, #1211, #1228, #1229, #1230, #1231, #1234, #1235, #1241, #1246, #1247, #1248, #1278, #1319, #1320, #1321, #1322, #1324, #1325, #1326, #1327, #1328, #1329, #1368, #1415, #1430, #1432, #1593, #1594, #1595, #1597, #1598, #1599, #1600, #1601, #1603, #1604, #1605, #1606, #1607, #1609, #1610, #1611, #1612, #1613, #1616, #1617, #1618, #1619, #1621, #1622, #1623, #1624, #1625, #1626, #1627, #1628, #1631, #1632, #1637, #1638, #1639, #1640, #1642, #1643, #1644, #1657, #1667, #1672, #1673, #1674, #1676, #1677, #1729, #1732, #1733, #1734, #1735, #1736, #1737, #1738, #1740, #1743, #1748, #1749, #1750, #1751, #1752, #1753, #1754, #1755, #1756, #1757, #1758, #1760, #1761, #1763, #1765, #1766, #1767, #1768, #1769, #1770, #1771, #1772, #1773, #1774, #1775, #1776, #1781, #1782, #1783, #1784, #1785, #1786, #1788, #1789, #1809
:star: 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.
:star: A number of Helper classes and traits (for internal use only - see #1484).
#1237, #1250, #1252, #1261, #1406, #1452, #1493, #1555, #1556, #1557, #1567, #1568, #1570, #1571, #1572, #1575, #1576
:books: Documentation for the following sniffs:
:two_hearts: All sniffs are now cross-version compatibility with both PHP_CodeSniffer 3.x as well as 4.x. #1911
:fire: 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.
:twisted_rightwards_arrows: 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
:twisted_rightwards_arrows: The PHPCompatibility.Miscellaneous.ValidIntegers has been moved to the Numbers category and is now called PHPCompatibility.Numbers.ValidIntegers. #1004
:twisted_rightwards_arrows: 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
:twisted_rightwards_arrows: PHPCompatibility.FunctionDeclarations.NewParamTypeDeclarations: the InvalidTypeHintFound error code has been split into two error codes. #1727. Fixes #1726
InvalidTypeHintFound error code remains in effect for types which are invalid in a parameter context.InvalidLongTypeFound error code will now warn about the use of "long" types, which are likely typos, but could be valid class names.:twisted_rightwards_arrows: PHPCompatibility.Classes.NewTypedProperties: the InvalidType error code has been split into two error codes. #1728
InvalidType error code remains in effect for types which are invalid in a property context.InvalidLongType error code will now warn about the use of "long" types, which are likely typos, but could be valid class names.:green_heart: PHPCompatibility.Upgrade.LowPHP: the minimum recommended PHP version is now 7.2.0. #1550
:pushpin: The testVersion configuration variable will now also be recognized when provided in lowercase (testversion). #969
:pushpin: Passing an invalid testVersion will now result in either an InvalidTestVersion or an InvalidTestVersionRange Exception being thrown. #1548
:pushpin: A lot of the sniffs have had updates to handle various new PHP syntaxes and features. :warning: Note: this task is not yet complete, so some sniffs may still throw false positives/negatives when confronted with modern PHP.
#986, #988, #990, #991, #995, #996, #997, #1000, #1004, #1239, #1249, #1259, #1261, #1310, #1318, #1331, #1343, #1364, #1369, #1372, #1374, #1375, #1376, #1377, #1378, #1379, #1381, #1382, #1383, #1384, #1385, #1387, #1388, #1389, #1390, #1392, #1393, #1394, #1395, #1396, #1405, #1407, #1422, #1430, #1431, #1432, #1433, #1434, #1439, #1440, #1446, #1447, #1448, #1449, #1474, #1475, #1478, #1494, #1495, #1496, #1498, #1499, #1512, #1515, #1564, #1565, #1566, #1569, #1573, #1588, #1596, #1683, #1688, #1704, #1705, #1706, #1715, #1716, #1717, #1724, #1725, #1746, #1791, #1807, #1823, #1858, #1859, #1860, #1861, #1862, #1867, #1888, #1890, #1891, #1892
:pushpin: MiscHelper::isUseOfGlobalConstant() will no longer recognize constant declarations as "use of". #1888
:pushpin: 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
:pushpin: PHPCompatibility.Classes.RemovedOrphanedParent the $classScopeTokens property is now private, it should never have been public in the first place. #983
:pushpin: PHPCompatibility.Classes.RemovedOrphanedParent will now also flag parent when used as a type declaration in an interface. #1499
:pushpin: PHPCompatibility.ControlStructures.NewExecutionDirectives now more accurately determines whether the value of a directive is valid. #1416
:pushpin: PHPCompatibility.FunctionDeclarations.NonStaticMagicMethods will now also flag incorrect modifiers for the __wakeup() method, as enforced by PHP since PHP 8.0. #1821
:pushpin: 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
:pushpin: PHPCompatibility.FunctionNameRestrictions.ReservedFunctionNames will now bow out for the PHP 7.4 __serialize() and __unserialize() magic methods. #1142
:pushpin: PHPCompatibility.FunctionNameRestrictions.ReservedFunctionNames will now ignore deprecated functions more consistently. #1564
:pushpin: PHPCompatibility.FunctionUse.ArgumentFunctionsReportCurrentValue will now throw an error, instead of a warning, when a passed parameter is unset(). #1286
:pushpin: PHPCompatibility.FunctionUse.ArgumentFunctionsReportCurrentValue will now recognize and handle numeric $options being passed to the target function calls. #1892
:pushpin: PHPCompatibility.FunctionUse.ArgumentFunctionsReportCurrentValue will now warn against the use of debug_*backtrace() as a PHP 8.1+ first class callable. #1892
:pushpin: PHPCompatibility.Interfaces.InternalInterfaces will now also flag internal interfaces which cannot be extended when used in an extends clause. #1566
:pushpin: PHPCompatibility.Interfaces.NewInterfaces will now detect interfaces used in catch conditions. #968. Fixes #967
:pushpin: PHPCompatibility.Interfaces.NewInterfaces will now also detect new interfaces when used in an extends clause. #1259
:pushpin: 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
:pushpin: PHPCompatibility.Keywords.ForbiddenNames will now strictly only flag forbidden names at the point of declaration. #1368
:pushpin: 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).
:pushpin: 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
:pushpin: 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
:pushpin: PHPCompatibility.ParameterValues.NewHTMLEntitiesEncodingDefault: will now also sniff for affected function calls to get_html_translation_table(). #1041
:pushpin: PHPCompatibility.Syntax.NewFunctionCallTrailingComma will now also detect trailing commas in exit/die as function calls (PHP 8.4+). #1807
:pencil2: 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.
#1154, #1155, #1156, #1157, #1158, #1159, #1180, #1281, #1599
:pencil2: 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.
#1006, #1009, #1012, #1015, #1142, #1171, #1172, #1173, #1174, #1177, #1178, #1179, #1188, #1210, #1254, #1257, #1258, #1259, #1261, #1368, #1399, #1416, #1448, #1452, #1495, #1514, #1515, #1722, #1810
:pencil2: 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.
:pencil2: 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.
:pencil2: Various sniffs no longer get confused over comments in unexpected places.
:pencil2: Various sniffs now have improved parse error/live coding tolerance.
:wrench: Composer: a replace directive has been added to discourage use of the old package name. #976
:wrench: Composer: The package will now identify itself as a static analysis tool. #1346
:wrench: :umbrella: Various housekeeping, including general maintenance, improvements to speed up the sniffs, improvements to CI, the tests and documentation.
#683, #964, #966, #970, #971, #973, #974, #977, #978, #980, #981, #982, #983, #987, #989, #992, #993, #994, #995, #997, #998, #999, #1000, #1001, #1002, #1003, #1004, #1005, #1007, #1008, #1011, #1014, #1017, #1019, #1021, #1030, #1140, #1141, #1142, #1143, #1144, #1145, #1146, #1147, #1148, #1160, #1167, #1168, #1169, #1171, #1174, #1175, #1176, #1179, #1188, #1189, #1193, #1194, #1205, #1209, #1214, #1215, #1216, #1218, #1219, #1220, #1221, #1222, #1225, #1245, #1253, #1255, #1256, #1258, #1259, #1260, #1261, #1264, #1266, #1268, #1270, #1271, #1273, #1274, #1277, #1280, #1286, #1288, #1289, #1290, #1297, #1302, #1307, #1313, #1314, #1333, #1334, #1335, #1336, #1350, #1354, #1356, #1357, #1359, #1360, #1365, #1368, #1400, #1403, #1408, #1414, #1416, #1421, #1427, #1428, #1435, #1436, #1438, #1439, #1442, #1444, #1445, #1448, #1451, #1455, #1457, #1461, #1462, #1463, #1469, #1476, #1477, #1479, #1482, #1483, #1485, #1493, #1497, #1499, #1500, #1501, #1502, #1503, #1504, #1505, #1506, #1507, #1508, #1509, #1510, #1511, #1512, #1513, #1514, #1515, #1516, #1517, #1518, #1519, #1520, #1521, #1522, #1523, #1524, #1525, #1526, #1527, #1528, #1529, #1530, #1531, #1532, #1533, #1534, #1535, #1536, #1537, #1538, #1539, #1544, #1545, #1546, #1547, #1552, #1553, #1554, #1558, #1559, #1560, #1561, #1562, #1563, #1564, #1565, #1569, #1573, #1574, #1575, #1576, #1577, #1579, #1580, #1582, #1584, #1587, #1588, #1590, #1591, #1619, #1634, #1635, #1636, #1645, #1646, #1647, #1655, #1656, #1658, #1659, #1660, #1661, #1662, #1668, #1684, #1692, #1693, #1701, #1702, #1708, #1709, #1710, #1719, #1723, #1729, #1736, #1737, #1747, #1759, #1762, #1791, #1793, #1794, #1796, #1797, #1798, #1803, #1805, #1806, #1811, #1813, #1816, #1817, #1818, #1819, #1820, #1822, #1824, #1825, #1826, #1827, #1828, #1829, #1830, #1831, #1832, #1833, #1834, #1835, #1836, #1837, #1838, #1839, #1840, #1841, #1842, #1843, #1844, #1845, #1846, #1847, #1848, #1850, #1851, #1853, #1854, #1855, #1856, #1857, #1863, #1864, #1865, #1866, #1868, #1869, #1870, #1871, #1872, #1873, #1874, #1883, #1885, #1887, #1888, #1890, #1892, #1893, #1894, #1895, #1896, #1898, #1899, #1904, #1905, #1907, #1908, #1909, #1910, #1913, #1915, #1916, #1919, #1920, #1921, #1922, #1925, #1927, #1929, #1930, #1931, #1932, #1933
PHPCompatibility.Keywords.ForbiddenNamesAsInvokedFunctions sniff. #1367. Fixes #105, #1024PHPCompatibility.Keywords.ForbiddenNamesAsDeclared sniff. #1399. Fixes #1024PHPCompatibility.Upgrade.LowPHPCS sniff. #1549PHPCompatibility\PHPCSHelper class in favour of PHPCSUtils. #979PHPCompatibility\AbstractComplexVersionSniff class in favour of internal Helper traits. #1406PHPCompatibility\AbstractNewFeatureSniff class in favour of internal Helper traits. #1406PHPCompatibility\AbstractRemovedFeatureSniff class in favour of internal Helper traits. #1406PHPCompatibility\ComplexVersionInterface class in favour of internal Helper traits. #1406PHPCompatibility\Sniff::addMessage() in favour of PHPCSUtils. #1363PHPCompatibility\Sniff::arrayKeysToLowercase(). Use the PHP native array_change_key_case() function instead. #979PHPCompatibility\Sniff::determineNamespace() in favour of PHPCSUtils. #979PHPCompatibility\Sniff::doesFunctionCallHaveParameters() in favour of PHPCSUtils. #979PHPCompatibility\Sniff::getCompleteTextString() in favour of PHPCSUtils. #979PHPCompatibility\Sniff::getDeclaredNamespaceName() in favour of PHPCSUtils. #979PHPCompatibility\Sniff::getFQClassNameFromDoubleColonToken() in favour of an internal Helper class. #1571PHPCompatibility\Sniff::getFQClassNameFromNewToken() in favour of an internal Helper class. #1571PHPCompatibility\Sniff::getFQExtendedClassName() in favour of an internal Helper class. #1571PHPCompatibility\Sniff::getFQName() in favour of an internal Helper class. #1571PHPCompatibility\Sniff::getFunctionCallParameter() in favour of PHPCSUtils. #979PHPCompatibility\Sniff::getFunctionCallParameters() in favour of PHPCSUtils. #979PHPCompatibility\Sniff::getFunctionCallParameterCount() in favour of PHPCSUtils. #979PHPCompatibility\Sniff::getHashAlgorithmParameter() in favour of an internal Helper trait. #1250PHPCompatibility\Sniff::getReturnTypeHintName() in favour of PHPCSUtils. #1448PHPCompatibility\Sniff::getReturnTypeHintToken() in favour of PHPCSUtils. #1448PHPCompatibility\Sniff::getTypeHintsFromFunctionDeclaration() in favour of PHPCSUtils. #1448PHPCompatibility\Sniff::inClassScope() in favour of PHPCSUtils. #1429PHPCompatibility\Sniff::isClassProperty() in favour of PHPCSUtils. #979PHPCompatibility\Sniff::isClassConstant() in favour of PHPCSUtils. #979PHPCompatibility\Sniff::isNamespaced() without replacement. #1551PHPCompatibility\Sniff::isNegativeNumber() in favour of an internal Helper class. #1493, #1567PHPCompatibility\Sniff::isNumber() in favour of an internal Helper class. #1493, #1567PHPCompatibility\Sniff::isNumericCalculation() in favour of an internal Helper class. #1568PHPCompatibility\Sniff::isPositiveNumber() in favour of an internal Helper class. #1493, #1567PHPCompatibility\Sniff::isShortList() in favour of PHPCSUtils. #979PHPCompatibility\Sniff::isShortTernary() in favour of PHPCSUtils. #979PHPCompatibility\Sniff::isUnaryPlusMinus() in favour of PHPCSUtils. #979PHPCompatibility\Sniff::isUseOfGlobalConstant() in favour of an internal Helper class. #1572PHPCompatibility\Sniff::isVariable() in favour of an internal Helper class. #1570PHPCompatibility\Sniff::stringToErrorCode() in favour of PHPCSUtils. #1363PHPCompatibility\Sniff::stripQuotes() in favour of PHPCSUtils. #979PHPCompatibility\Sniff::stripVariables() in favour of PHPCSUtils. #1398PHPCompatibility\Sniff::supportsAbove() in favour of an internal Helper class. #1237, #1555PHPCompatibility\Sniff::supportsBelow() in favour of an internal Helper class. #1237, #1555PHPCompatibility\Sniff::tokenHasScope() in favour of PHPCSUtils. #979PHPCompatibility\Sniff::validDirectScope() in favour of PHPCSUtils. #979PHPCompatibility\Sniff::$iniFunctions without replacement. [#1251]PHPCompatibility\Sniff::$hashAlgoFunctions in favour of an internal Helper trait. #1250PHPCompatibility\Sniff::$superglobals in favour of PHPCSUtils. #1018PHPCompatibility\Sniff::REGEX_COMPLEX_VARS in favour of PHPCSUtils. #1398testVersion handling when running on PHP 8.1+. #1276null/true/false could get confused over fully qualified and/or non-lowercase use of these keywords. #1877, #1902, #1906PHPCompatibility.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 #1291PHPCompatibility.Classes.NewClasses and PHPCompatibility.Classes.RemovedClasses did not always correctly correlate the class name from self. #1893PHPCompatibility.Classes.NewLateStaticBinding did not flag instanceof static or `new static. #957PHPCompatibility.Classes.NewTypedProperties PHP native build-in types should be handled case-insensitively. #1205PHPCompatibility.Classes.NewTypedProperties false negative for edge case where a property declaration would be closed via a PHP close tag. #1703PHPCompatibility.Classes.RemovedClasses will no longer throw false positives for imported namespaced classes with a class name overlapping one of the new global PHP classes. #1924PHPCompatibility.Classes.RemovedOrphanedParent could get confused over an upstream tokenizer issue when a function declared to return by reference would be called "parent". #1499. Fixes #1489PHPCompatibility.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. #1888PHPCompatibility.Constants.NewMagicClassConstant would incorrectly flag static function calls to a method called class. #1500PHPCompatibility.ControlStructures.NewExecutionDirectives: directive names should be handled case-insensitively. #1416PHPCompatibility.ControlStructures.NewExecutionDirectives: multi-directive statements were not analyzed correctly. #1416PHPCompatibility.FunctionDeclarations.ForbiddenParametersWithSameName did not examine abstract methods or interface methods. #991PHPCompatibility.FunctionDeclarations.NewClosure could get confused over $this and self being used in nested closed structures in the body of the closure. #1928PHPCompatibility.FunctionDeclarations.NewParamTypeDeclarations did not examine nested function declarations. #996PHPCompatibility.FunctionDeclarations.NewParamTypeDeclarations PHP native build-in types should be handled case-insensitively. #1203PHPCompatibility.FunctionDeclarations.NewParamTypeDeclarations would incorrectly throw the OutsideClassScopeFound error for PHP < 5.2. #1203PHPCompatibility.FunctionDeclarations.NewReturnTypeDeclarations PHP native build-in types should be handled case-insensitively. #1204PHPCompatibility.FunctionDeclarations.NonStaticMagicMethods would incorrectly flag non-public __destruct() methods as having the wrong visibility. #1543. Fixes #1542PHPCompatibility.FunctionNameRestrictions.RemovedNamespacedAssert did not handle nested function declarations correctly. #1169PHPCompatibility.FunctionNameRestrictions.ReservedFunctionNames did not handle nested function declarations correctly. #1142PHPCompatibility.FunctionUse.ArgumentFunctionsUsage: TypeError when run on PHP 8.0+. #1213PHPCompatibility.FunctionUse.ArgumentFunctionsUsage would throw false positives for namespaced functions mirroring a name of a target function of the sniff. #1890PHPCompatibility.FunctionUse.ArgumentFunctionsUsage could get confused over a method declared to return by reference. #1890PHPCompatibility.FunctionUse.ArgumentFunctionsReportCurrentValue: prevent false positive when passed parameter is used in a return, exit or throw statement. #1208, #1286. Fixes #1207PHPCompatibility.FunctionUse.ArgumentFunctionsReportCurrentValue: prevent false positive when passed parameter is used in isset() or empty(). #1286PHPCompatibility.FunctionUse.ArgumentFunctionsReportCurrentValue: prevent false positive when passed parameter is only assigned to another variable in a "simple assignment". #1286. Fixes #1240PHPCompatibility.FunctionUse.ArgumentFunctionsReportCurrentValue would incorrectly ignore function calls when passed a namespaced constant mirroring the global DEBUG_BACKTRACE_IGNORE_ARGS constant. #1892PHPCompatibility.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. #1892PHPCompatibility.FunctionUse.ArgumentFunctionsReportCurrentValue now recognizes and handles negative offsets passed to array_slice()/array_splice() correctly. #1892PHPCompatibility.FunctionUse.ArgumentFunctionsReportCurrentValue now recognizes and handles the $length parameter if passed to array_slice()/array_splice(). #1892PHPCompatibility.FunctionUse.ArgumentFunctionsReportCurrentValue did not handle (parameter overrides via) list assignments correctly. #1892PHPCompatibility.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. #1892PHPCompatibility.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 #1649PHPCompatibility.Interfaces.NewInterfaces did not handle nested function declarations correctly. #1259PHPCompatibility.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. #1368PHPCompatibility.Keywords.ForbiddenNames did not always flag keywords used in a namespace name correctly. #1368PHPCompatibility.Keywords.ForbiddenNames did not always flag aliases in import multi-use, group use and trait use statements correctly. #1368PHPCompatibility.Lists.ForbiddenEmptyListAssignment: false positive for a hard-coded empty (sub-)array in a foreach iterable expression. #1401. Fixes #1341PHPCompatibility.ParameterValues.NewFopenModes could throw false positives for dynamically generated parameter values. #1045PHPCompatibility.ParameterValues.NewIconvMbstringCharsetDefault now examines each array item in the $options parameter individually to prevent false negatives. #1588PHPCompatibility.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 #1777PHPCompatibility.ParameterValues.NewPackFormat could throw false positives for dynamically generated parameter values. #1044. Fixes #1043PHPCompatibility.ParameterValues.NewPasswordAlgoConstantValues could throw false positives for dynamically generated parameter values. #1531PHPCompatibility.ParameterValues.NewPCREModifiers and PHPCompatibility.ParameterValues.RemovedPCREModifiers could throw false positives for dynamically generated parameter values. #1764PHPCompatibility.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. #1878PHPCompatibility.ParameterValues.RemovedIconvEncoding: TypeError when run on PHP 8.0+. #1212PHPCompatibility.ParameterValues.RemovedMbstringModifiers could throw false positives for dynamically generated parameter values. #1046PHPCompatibility.ParameterValues.RemovedMbStrrposEncodingThirdParam could throw both false positives as well as have false negatives for dynamically generated parameter values. #1722. Fixes #1721PHPCompatibility.ParameterValues.RemovedNonCryptoHashSniff did not handle a fully qualified HASH_HMAC constant as a parameter value correctly. #1532PHPCompatibility.ParameterValues.RemovedSetlocaleString could throw false positives for dynamically generated parameter values. #1047PHPCompatibility.Syntax.ForbiddenCallTimePassByReference was not recognized for anonymous class instantiations and class instantiations using hierarchy keywords. #1912PHPCompatibility.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 #1696PHPCompatibility.Syntax.NewFunctionCallTrailingComma would throw a false positive for a trailing comma in a function declaration if the function was declared to return by reference. #1534PHPCompatibility.Syntax.NewFunctionCallTrailingComma false negative on trailing comma in class instantiations. #1534PHPCompatibility.Syntax.NewShortArray would incorrectly also flag short lists. #1010PHPCompatibility.Syntax.RemovedCurlyBraceArrayAccess did not flag curly brace array access on a namespaced constant. #1889PHPCompatibility.UseDeclarations.NewUseConstFunction could throw false positive in some parse error edge cases. #1537PHPCompatibility.Variables.ForbiddenThisUseContexts false positive for use of $this in unset(), while $this is not the variable being unset. #1670. Fixes #1666PHPCompatibility.Variables.NewUniformVariableSyntax did not handle static access using the hierarchy keywords correctly. #1013PHPCompatibility.Variables.RemovedPredefinedGlobalVariables false positive on static access to class property shadowing the name of one of the removed global variables. #1014PHPCompatibility.Variables.RemovedPredefinedGlobalVariables did not correctly limit the scope of the token walking to determine whether $php_errormsg was the deprecated global variable. #1014Thanks go out to [Anna Filina], [bebehr], [Dan Wallis], [Daniel Fahlke], [Diede Exterkate], [Eloy Lafuente], [Gary Jones], [Go Kudo], [Hugo van Kemenade], [Kevin Porras], [Mark Clements], [magikstm], [Matthew Turland], [Sebastian Knott], and [Steve Grunwell] for their contributions to this version. :clap:
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.
See all related issues and PRs in the [9.3.5 milestone].
PHPCompatibility.Classes.NewClasses sniff: recognize the new FFI extension related classes as introduced in PHP 7.4. #949PHPCompatibility.IniDirectives.NewIniDirectives sniff: detect use of the new FFI extension related ini directives as introduced in PHP 7.4. #949PHPCompatibility.Syntax.NewShortArray: improved clarity of the error message and made it consistent with other error messages in this standard. #934PHPCompatibility.Interfaces.NewInterfaces: updated the URL which is mentioned in select error messages. #942PHPCompatibility.Classes.NewClasses: two new PHP 7.4 classes were being checked as if they were Exceptions. #945Thanks go out to [William Entriken] for their contribution to this version. :clap:
See all related issues and PRs in the [9.3.3 milestone].
PHPCompatibility.Constants.NewConstants sniff: detection of yet more (undocumented) PHP 7.2 Sodium constants. #924PHPCompatibility.Keywords.ForbiddenNames sniff: detect the use of more reserved keywords which are not allowed to be used to name certain constructs. #923. Fixes #922PHPCompatibility.FunctionNameRestrictions.RemovedPHP4StyleConstructors: false positive detecting PHP4-style constructors when declared in interfaces. The class implementing the interface will not have the same name as the interface, so the actual method would not be regarded as a PHP4 style constructor. #921Thanks go out to [Nikhil] for their contribution to this version. :clap:
See all related issues and PRs in the [9.3.2 milestone].
PHPCompatibility.Constants.NewConstants sniff: detection of the PHP 7.2 SODIUM_CRYPTO_PWHASH_ALG_ARGON2ID13 constant. #915PHPCompatibility.FunctionNameRestrictions.RemovedPHP4StyleConstructors: minor efficiency fix to make the sniff faster. #912PHPCompatibility.FunctionNameRestrictions.ReservedFunctionNames: functions marked as [@deprecated](https://github.com/deprecated) in the function docblock will now be ignored by this sniff. #917. Fixes #911PHPCompatibility.FunctionDeclarations.ForbiddenToStringParameters: the $ooScopeTokens property is now protected, it should never have been public in the first place. #907PHPCompatibility.FunctionUse.OptionalToRequiredFunctionParameters: false positive when a class is instantiated which has the same name as one of the affected functions. #914. Fixes #913PHPCompatibility.FunctionUse.RequiredToOptionalFunctionParameters: false positive when a class is instantiated which has the same name as one of the affected functions. #914PHPCompatibility.MethodUse.NewDirectCallsToClone: false positive on calling __clone() from within the class being cloned #910. Fixes #629 (comment)PHPCompatibility.Miscellaneous.ValidIntegers: binary numbers using an uppercase B were not always recognized correctly. #909See all related issues and PRs in the [9.3.1 milestone].
PHPCompatibility.ParameterValues.RemovedImplodeFlexibleParamOrder: false positive when an array item in the second parameter contained a ternary. #891. Fixes #890PHPCompatibility.ParameterValues.RemovedImplodeFlexibleParamOrder: will now take array casts into account when determining which parameter is $pieces. #891.PHPCompatibility.ParameterValues.RemovedImplodeFlexibleParamOrder: hardening of the logic to not examine the second parameter when the first is just and only a text string ($glue). #891.See all related issues and PRs in the [9.3.0 milestone].
To keep informed of the progress of covering "everything PHP 7.4" in PHPCompatibility, please subscribe to issue [#808].
The next version of PHPCompatibility is expected to include a new external dependency.
In this same release, support for PHP < 5.4 and PHP_CodeSniffer < 2.6.0 will be dropped.
The 10.0.0 release is expected around the same time as the release of PHP 7.4 - end of November/beginning of December 2019.
PHPCompatibility.Miscellaneous.NewPHPOpenTagEOF sniff to detect a stand-alone PHP open tag at the end of a file, without trailing newline, as will be supported as of PHP 7.4. #843PHPCompatibility.ParameterValues.ForbiddenStripTagsSelfClosingXHTML sniff to detect calls to strip_tags() passing self-closing XHTML tags in the $allowable_tags parameter. This has not been supported since PHP 5.3.4. #866PHPCompatibility.ParameterValues.NewHTMLEntitiesEncodingDefault sniff to detect calls to html_entity_decode(), htmlentities() and htmlspecialchars() which are impacted by the change to the default value of the $encoding parameter in PHP 5.4. #862PHPCompatibility.ParameterValues.NewIconvMbstringCharsetDefault sniff to detect code impacted by the change in the default_charset value in PHP 5.6. #864 Fixes #839PHPCompatibility.ParameterValues.NewIDNVariantDefault sniff to detect calls to idn_to_ascii() and idn_to_utf8() impacted by the PHP 7.4 change in the default value for the $variant parameter. #861PHPCompatibility.ParameterValues.NewPasswordAlgoConstantValues sniff to detect calls to password_hash() and password_needs_rehash() impacted by the changed value of the PASSWORD_DEFAULT, PASSWORD_BCRYPT, PASSWORD_ARGON2I and PASSWORD_ARGON2ID constants in PHP 7.4. #865PHPCompatibility.ParameterValues.NewProcOpenCmdArray sniff to detect calls to proc_open() passing an array for the $cmd parameter as supported as of PHP 7.4. #869PHPCompatibility.ParameterValues.NewStripTagsAllowableTagsArray sniff to detect calls to strip_tags() passing an array for the $allowable_tags parameter as will be supported as of PHP 7.4. #867PHPCompatibility.ParameterValues.RemovedImplodeFlexibleParamOrder sniff to detect implode() being called with $glue and $pieces in reverse order from the documented argument order. This was previously allowed for historical reasons, but will be deprecated in PHP 7.4. #846PHPCompatibility.ParameterValues.RemovedMbStrrposEncodingThirdParam sniff to detect the $encoding being passed as the third, instead of the fourth parameter, to mb_strrpos() as has been soft deprecated since PHP 5.2 and will be hard deprecated as of PHP 7.4. #860PHPCompatibility.Syntax.RemovedCurlyBraceArrayAccess sniff to detect array and string offset access using curly braces as will be deprecated as of PHP 7.4. #855
PHPCompatibility.TextStrings.NewUnicodeEscapeSequence sniff to detect use of the PHP 7.0+ unicode codepoint escape sequences and issues with invalid sequences. #856PHPCompatibility.Upgrade.LowPHP sniff to give users of old PHP versions advance warning when support will be dropped in the near future. #838
At this moment, the intention is to drop support for PHP 5.3 by the end of this year.PHPCompatibility.Classes.NewClasses sniff: recognize the new WeakReference class as introduced in PHP 7.4. #857PHPCompatibility.Constants.NewConstants sniff: detection of new Curl constants as introduced in PHP 7.3.5. #878PHPCompatibility.Constants.NewConstants sniff: detection of the revived T_BAD_CHARACTER constant as re-introduced in PHP 7.4. #882PHPCompatibility.Constants.NewConstants sniff: detection of the new IMG_FILTER_SCATTER and PASSWORD_ARGON2_PROVIDER constants as introduced in PHP 7.4. #887PHPCompatibility.Constants.RemovedConstants sniff: detection of use of the CURLPIPE_HTTP1 constant which will be deprecated in PHP 7.4. #879PHPCompatibility.Constants.RemovedConstants sniff: detection of use of the FILTER_SANITIZE_MAGIC_QUOTES constant which will be deprecated in PHP 7.4. #845PHPCompatibility.Constants.RemovedConstants sniff: detection of use of the T_CHARACTER and T_BAD_CHARACTER constants which were removed in PHP 7.0. #882PHPCompatibility.FunctionDeclarations.NewMagicMethods sniff: recognize the new __serialize() and __unserialize() magic methods as introduced in PHP 7.4. #868PHPCompatibility.FunctionDeclarations.NewMagicMethods sniff: recognize the PHP 5.0 __construct() and __destruct() magic methods. #884PHPCompatibility.FunctionDeclarations.NonStaticMagicMethods sniff: recognize the new __serialize() and __unserialize() magic methods as introduced in PHP 7.4. #868PHPCompatibility.FunctionUse.NewFunctions sniff: recognize the new PHP 7.4 function imagecreatefromtga(). #873PHPCompatibility.FunctionUse.RemovedFunctionParameters sniff: recognize the deprecation of the $age parameter of the curl_version() function. #874PHPCompatibility.FunctionUse.RemovedFunctions sniff: recognize the PHP 7.4 deprecated convert_cyr_string()(), ezmlm_hash(), get_magic_quotes_gpc(), get_magic_quotes_runtime(), hebrevc(), is_real(), money_format() and restore_include_path() functions. #847PHPCompatibility.IniDirectives.NewIniDirectives sniff: detect use of the new PHP 7.4 zend.exception_ignore_args ini directive. #871PHPCompatibility.IniDirectives.RemovedIniDirectives sniff: detect use of the allow_url_include ini directive which is deprecated as of PHP 7.4. #870PHPCompatibility.IniDirectives.RemovedIniDirectives sniff: detection of use of the opcache.load_comments directive which was removed in PHP 7.0. #883PHPCompatibility.ParameterValues.NewHashAlgorithms: recognize use of the new PHP 7.4 crc32c hash algorithm. #872PHPCompatibility.TypeCasts.RemovedTypeCasts sniff: detect usage of the (real) type cast which will be deprecated in PHP 7.4. #844recode extension functionality which will be removed in PHP 7.4 (moved to PECL) in the RemovedExtensions and RemovedFunctions sniffs. #841OPcache extension functionality which was be introduced in PHP 5.5, but not yet fully accounted for in the NewFunctions and NewIniDirectives sniffs. #883getCompleteTextString() utility method to the PHPCompatibility\Sniff class. #856PHPCompatibility.Upgrade.LowPHPCS sniff.PHPCompatibility.ParameterValues.NewNegativeStringOffset, PHPCompatibility.ParameterValues.RemovedMbStringModifiers and sniffs. #876, #877CONTRIBUTING.md: Added a list of typical sources for information about changes to PHP. #875PHPCompatibility.FunctionDeclarations.NewExceptionsFromToString sniff: the sniff will now also examine the function docblock, if available, and will throw an error when a [@throws](https://github.com/throws) tag is found in the docblock. #880. Fixes #863PHPCompatibility.FunctionDeclarations.NonStaticMagicMethods sniff: will now also check the visibility and static (or not) requirements of the magic __construct(), __destruct(), __clone(), __debugInfo(), __invoke() and __set_state() methods. #885PHPCompatibility.Syntax.NewArrayStringDereferencing sniff: the sniff will now also recognize array string dereferencing using curly braces as was (silently) supported since PHP 7.0. #851
PHPCompatibility.Syntax.NewClassMemberAccess sniff: the sniff will now also recognize class member access on instantiation and cloning using curly braces as was (silently) supported since PHP 7.0. #852
PHPCompatibility.Syntax.NewFunctionArrayDereferencing sniff: the sniff will now also recognize function array dereferencing using curly braces as was (silently) supported since PHP 7.0. #853
PHPCompatibility.FunctionDeclarations.ForbiddenParametersWithSameName sniff: variable names are case-sensitive, so recognition of same named parameters should be done in a case-sensitive manner. #848PHPCompatibility.FunctionDeclarations.NewExceptionsFromToString sniff: Exceptions thrown within a try should not trigger the sniff. #880. Fixes #863PHPCompatibility.FunctionDeclarations.NewExceptionsFromToString sniff: the $ooScopeTokens property should never have been a public property. #880.PHPCompatibility.Operators.RemovedTernaryAssociativity sniff were not being run. #836See all related issues and PRs in the [9.2.0 milestone].
To keep informed of the progress of covering "everything PHP 7.4" in PHPCompatibility, please subscribe to issue #808.
PHPCompatibility.Classes.ForbiddenAbstractPrivateMethods sniff to detect methods declared as both private as well as abstract. This was allowed between PHP 5.0.0 and 5.0.4, but disallowed in PHP 5.1 as the behaviour of private and abstract are mutually exclusive. #822PHPCompatibility.Classes.NewTypedProperties sniff to detect PHP 7.4 typed property declarations. #801, #829PHPCompatibility.Classes.RemovedOrphanedParent sniff to detect the use of the parent keyword in classes without a parent (non-extended classes). This code pattern is deprecated in PHP 7.4 and will become a compile-error in PHP 8.0. #818PHPCompatibility.FunctionDeclarations.NewExceptionsFromToString sniff to detect throwing exceptions from __toString() methods. This would previously result in a fatal error, but will be allowed as of PHP 7.4. #814PHPCompatibility.FunctionDeclarations.ForbiddenToStringParameters sniff to detect __toString() function declarations expecting parameters. This was disallowed in PHP 5.3. #815PHPCompatibility.MethodUse.ForbiddenToStringParameters sniff to detect direct calls to __toString() magic methods passing parameters. This was disallowed in PHP 5.3. #830PHPCompatibility.Operators.ChangedConcatOperatorPrecedence sniff to detect code affected by the upcoming change in operator precedence for the concatenation operator. The concatenation operator precedence will be lowered in PHP 8.0, with deprecation notices for code affected being thrown in PHP 7.4. #805PHPCompatibility.Operators.RemovedTernaryAssociativity sniff to detect code relying on left-associativity of the ternary operator. This behaviour will be deprecated in PHP 7.4 and removed in PHP 8.0. #810PHPCompatibility.Syntax.NewArrayUnpacking sniff to detect the use of the spread operator to unpack arrays when declaring a new array, as introduced in PHP 7.4. #804PHPCompatibility.Classes.NewClasses sniff: recognize the new ReflectionReference class as introduced in PHP 7.4. #820PHPCompatibility.Constants.NewConstants sniff: detection of the new PHP 7.4 Core (Standard), MBString, Socket and Tidy constants. #821PHPCompatibility.FunctionUse.NewFunctions sniff: detect usage of the new PHP 7.4 get_mangled_object_vars(), mb_str_split(), openssl_x509_verify(), password_algos(), pcntl_unshare(), sapi_windows_set_ctrl_handler() and sapi_windows_generate_ctrl_event() functions. #811, #819, #827PHPCompatibility.FunctionUse.NewFunctions sniff: recognize the new OCI functions as introduced in PHP 7.2.14 and PHP 7.3.1. #786PHPCompatibility.FunctionUse.RemovedFunctions sniff: recognize the PHP 7.4 deprecated ldap_control_paged_result_response() and ldap_control_paged_result() functions. #831PHPCompatibility.FunctionUse.RemovedFunctions sniff: recognize the Payflow Pro/pfpro functions as removed in PHP 5.1. #823PHPCompatibility.FunctionUse.RequiredToOptionalFunctionParameters sniff: account for the parameters for array_merge() and array_merge_recursive() becoming optional in PHP 7.4. #817PHPCompatibility.IniDirectives.RemovedIniDirectives sniff: recognize the Payflow Pro/pfpro ini directives as removed in PHP 5.1. #823interbase/Firebird extension functionality which will be removed in PHP 7.4 (moved to PECL) in the RemovedConstants, RemovedExtensions, RemovedFunctions and RemovedIniDirectives sniffs. #807wddx extension functionality which will be removed in PHP 7.4 (moved to PECL) in the RemovedExtensions and RemovedFunctions sniffs. #826isShortTernary() and isUnaryPlusMinus() utility methods to the PHPCompatibility\Sniff class. #810, #805PHPCompatibility.Extensions.RemovedExtensions sniff will now only report on the removed Payflow Pro extension when a function uses pfpro_ as a prefix. Previously, it used the pfpro prefix (without underscore) for detection. #812T_ELLIPSIS token, i.e. the spread operator, is detected. #803
PHP 7.4 adds a third use-case for the spread operator. The adjusted error message accounts for this.PHPCompatibility.FunctionDeclarations.NewParamTypeDeclarations is now also tested with parameters using the splat operator. #802PHP_CodeSniffer as the canonical entry point for PHP_CodeSniffer. Previously, it would point to the PEAR package. #788PHPCompatibility/PHPCompatibility repo and no longer to the (deprecated) wimg/PHPCompatibility repo. #828DealerDirect/phpcodesniffer-composer-installer Composer plugin has been upped to 0.5.0. #791PHPCompatibility.Extensions.RemovedExtensions sniff contained a typo in the alternative recommended for the removed mcve extension. #806PHPCompatibility.Extensions.RemovedExtensions sniff listed the wrong removal version number for the Payflow Pro/pfpro extension (PHP 5.3 instead of the correct 5.1). #823Thanks go out to [Yılmaz] and [Tim Millwood] for their contribution to this version. :clap:
See all related issues and PRs in the [9.1.0 milestone].
PHPCompatibility.FunctionUse.ArgumentFunctionsReportCurrentValue sniff to detect code which could be affected by the PHP 7.0 change in the values reported by func_get_arg(), func_get_args(), debug_backtrace() and exception backtraces. #750. Fixes #585.PHPCompatibility.MethodUse.NewDirectCallsToClone sniff to detect direct call to a __clone() magic method which wasn't allowed prior to PHP 7.0. #743. Fixes #629.PHPCompatibility.Variables.ForbiddenThisUseContext sniff to detect most of the inconsistencies surrounding the use of the $this variable, which were removed in PHP 7.1. #762, #771. Fixes #262 and #740.NewClasses: detection of more native PHP Exceptions. #743, #753NewConstants : detection of the new PHP 7.3 Curl, Stream Crypto and LDAP constants and some more PHP 7.0 Tokenizer constants. #752, #767, #778NewFunctions sniff: recognize (more) new LDAP functions as introduced in PHP 7.3. #768NewFunctionParameters sniff: recognize the new $serverctrls parameter which was added to a number of LDAP functions in PHP 7.3. #769NewIniDirectives sniff: recognize the new imap.enable_insecure_rsh ini directive as introduced in PHP 7.1.25, 7.2.13 and 7.3.0. #770NewInterfaces sniff: recognize two more Session related interfaces which were introduced in PHP 5.5.1 and 7.0 respectively. #748findStartOfStatement() method to the PHPCompatibility\PHPCSHelper class to allow for PHPCS cross-version usage of that method. #750RemovedPHP4StyleConstructors: will now also detect PHP4-style constructors when declared in interfaces. #751Sniff::validDirectScope(): the return value of this method has changed. Previously it would always be a boolean. It will stil return false when no valid direct scope has been found, but it will now return the stackPtr to the scope token if a valid direct scope was encountered. #758NewOperators : updated the version number for T_COALESCE_EQUAL. #746Tokenizer regarding binary type casts. #760InternalInterfaces: false negative for implemented/extended interfaces prefixed with a namespace separator. #775NewClasses: the introduction version of various native PHP Exceptions has been corrected. #743, #753NewInterfaces: false negative for implemented/extended interfaces prefixed with a namespace separator. #775RemovedPHP4StyleConstructors: the sniff would examine methods in nested anonymous classes as if they were methods of the higher level class. #751RemovedPHP4StyleConstructors: the sniff will no longer throw false positives for the first method in an anonymous class when used in combination with PHPCS 2.3.x. #751ReservedFunctionNames: fixed incorrect error message text for methods in anonymous classes when used in combination with PHPCS 2.3.x. #755ReservedFunctionNames: prevent duplicate errors being thrown for methods in nested anonymous classes. #755PHPCSHelper::findEndOfStatement(): minor bug fix. #749Sniff::isClassProperty(): class properties for classes nested in conditions or function calls were not always recognized as class properties. #758Thanks go out to [Jonathan Champ] for his contribution to this version. :clap:
IMPORTANT: This release contains breaking changes. Please read and follow the Upgrade guide in the wiki carefully before upgrading!
All sniffs have been placed in meaningful categories and a number of sniffs have been renamed to have more consistent, meaningful and future-proof names.
Both the PHPCompatibilityJoomla [[GH][gh-phpcompat-joomla] | [Packagist][packagist-phpcompat-joomla]] as well as the PHPCompatibilityWP [[GH][gh-phpcompat-wp] | [Packagist][packagist-phpcompat-wp]] rulesets have already been adjusted for this change and have released a new version which is compatible with this version of PHPCompatibility.
Aside from those CMS-based rulesets, this project now also offers a number of polyfill-library specific rulesets, such as PHPCompatibilityPasswordCompat [[GH][gh-phpcompat-passwordcompat] | [Packagist][packagist-phpcompat-passwordcompat]] for @ircmaxell's password_compat libary, PHPCompatibilityParagonieRandomCompat and PHPCompatibilityParagonieSodiumCompat [[GH][gh-phpcompat-paragonie] | [Packagist][packagist-phpcompat-paragonie]] for the Paragonie polyfills and a number of rulesets related to various polyfills offered by the Symfony project [[GH][gh-phpcompat-symfony] | [Packagist][packagist-phpcompat-symfony]].
If your project uses one of these polyfills, please consider using these special polyfill rulesets to prevent false positives.
Also as of this version, [Juliette Reinders Folmer] is now officially a co-maintainer of this package.
See all related issues and PRs in the [9.0.0 milestone].
PHPCompatibility.ControlStructures.NewForeachExpressionReferencing sniff to detect referencing of $value within a foreach() when the iterated array is not a variable. This was not supported prior to PHP 5.5. #664PHPCompatibility.ControlStructures.NewListInForeach sniff to detect unpacking nested arrays into separate variables via the list() construct in a foreach() statement. This was not supported prior to PHP 5.5. #657PHPCompatibility.FunctionNameRestrictions.RemovedNamespacedAssert sniff to detect declaring a function called assert() within a namespace. This has been deprecated as of PHP 7.3. #735. Partially fixes #718.PHPCompatibility.Lists.AssignmentOrder sniff to detect list() constructs affected by the change in assignment order in PHP 7.0. #656PHPCompatibility.Lists.NewKeyedList sniff to detect usage of keys in list(), support for which was added in PHP 7.1. #655. Fixes #252.PHPCompatibility.Lists.NewListReferenceAssignment sniff to detect reference assignments being used in list() constructs, support for which has been added in PHP 7.3. #731PHPCompatibility.Lists.NewShortList sniff to detect the shorthand array syntax [] being used for symmetric array destructuring as introduced in PHP 7.1. #654. Fixes #248.PHPCompatibility.Operators.NewOperators sniff which checks for usage of the pow, pow equals, spaceship and coalesce (equals) operators. #738
These checks were previously contained within the PHPCompatibility.LanguageConstructs.NewLanguageConstructs sniff.PHPCompatibility.ParameterValues.ForbiddenGetClassNull sniff to detect null being passed to get_class(), support for which has been removed in PHP 7.2 #659. Fixes #557.PHPCompatibility.ParameterValues.NewArrayReduceInitialType sniff to detect non-integers being passed as the $initial parameter to the array_reduce() function, which was not supported before PHP 5.3. #666. Fixes #649PHPCompatibility.ParameterValues.NewFopenModes sniff to examine the $mode parameter passed to fopen() for modes not available in older PHP versions. #658PHPCompatibility.ParameterValues.NewNegativeStringOffset sniff to detect negative string offsets being passed to string manipulation functions which was not supported before PHP 7.1. #662. Partially fixes #253.PHPCompatibility.ParameterValues.NewPackFormats sniff to examine the $format parameter passed to pack() for formats not available in older PHP versions. #665PHPCompatibility.ParameterValues.RemovedIconvEncoding sniff to detect the PHP 5.6 deprecated encoding $types being passed to iconv_set_encoding(). #660. Fixes #475.PHPCompatibility.ParameterValues.RemovedNonCryptoHashes sniff to detect non-cryptographic hash algorithms being passed to various hash_*() functions. This is no longer accepted as of PHP 7.2. #663. Fixes #559PHPCompatibility.ParameterValues.RemovedSetlocaleString sniff to detect string literals being passed to the $category parameter of the setlocale() function. This behaviour was deprecated in PHP 4.2 and support has been removed in PHP 7.0. #661PHPCompatibility.Syntax.NewFlexibleHeredocNowdoc sniff to detect the new heredoc/nowdoc format as allowed as of PHP 7.3. #736. Fixes #705.
Note: This sniff is only supported in combination with PHP_CodeSniffer 2.6.0 and higher.PHPCompatibility.Classes.NewClasses sniff: recognize the new CompileError and JsonException classes as introduced in PHP 7.3. #676PHPCompatibility.Constants.NewConstants sniff: recognize new constants which are being introduced in PHP 7.3. #678PHPCompatibility.Constants.RemovedConstants sniff: recognize constants which have been deprecated or removed in PHP 7.3. #710. Partially fixes #718.PHPCompatibility.FunctionUse.NewFunctions sniff: recognize various new functions being introduced in PHP 7.3. #679PHPCompatibility.FunctionUse.NewFunctions sniff: recognize the sapi_windows_*(), hash_hkdf() and pcntl_signal_get_handler() functions as introduced in PHP 7.1. #728PHPCompatibility.FunctionUse.RemovedFunctionParameters sniff: recognize the deprecation of the $case_insensitive parameter for the define() function in PHP 7.3. #706PHPCompatibility.FunctionUse.RemovedFunctions sniff: recognize the PHP 7.3 deprecation of the image2wbmp(), fgetss() and gzgetss() functions, as well as the deprecation of undocumented Mbstring function aliases. #681, #714, #720. Partially fixes #718.PHPCompatibility.FunctionUse.RequiredToOptionalFunctionParameters sniff: account for the second parameter for array_push() and array_unshift() becoming optional in PHP 7.3, as well as for the $mode parameter for a range of ftp_*() functions becoming optional. #680PHPCompatibility.IniDirectives.NewIniDirectives sniff: recognize new syslog and session ini directives as introduced in PHP 7.3. #702, #719, #730PHPCompatibility.IniDirectives.NewIniDirectives sniff: recognize some more ini directives which were introduced in PHP 7.1. #727PHPCompatibility.IniDirectives.RemovedIniDirectived sniff: recognize ini directives removed in PHP 7.3. #677, #717. Partially fixes #718.isNumericCalculation() and isVariable() utility methods to the PHPCompatibility\Sniff class. #664, #666Contributing file. #738BaseSniffTest::sniffFile() method has been adjusted to match. The signature of this method has changed. Where it previously expected a relative path to the unit test case file, it now expects an absolute path.PHPCompatibility\Sniff class have been moved to a new PHPCompatibility\Util\Tests\Core subdirectory.phpunit-bootstrap.php.PHPCompatibility.LanguageConstructs.NewLanguageConstructs sniff has been split into two sniffs. #738
The PHPCompatibility.LanguageConstructs.NewLanguageConstructs sniff now contains just the checks for the namespace separator and the ellipsis.
The new PHPCompatibility.Operators.NewOperators sniff now contains the checks regarding the pow, pow equals, spaceship and coalesce (equals) operators.PHPCompatibility.ParameterValues.RemovedMbstringModifiers sniff will now also recognize removed regex modifiers when used within a function call to one of the undocumented Mbstring function aliases for the Mbstring regex functions. #715PHPCompatibility\Sniff::getFunctionCallParameter() utility method now allows for closures called via a variable. #723PHPCompatibility.Upgrade.LowPHPCS: the minimum supported PHPCS version is now 2.3.0. #699PHPCompatibility.FunctionNameRestrctions.RemovedMagicAutoload sniff. #716\PHPCompatibility\Sniff::inUseScope() method has been removed as it is no longer needed now support for PHPCS 1.x has been dropped. #699autoload section has been removed from the composer.json file. #738. Fixes #568.
Autoloading for this library is done via the PHP_CodeSniffer default mechanism, enhanced with our own autoloader, so the Composer autoloader shouldn't be needed and was causing issues in a particular use-case.PHPCompatibility.FunctionUse.NewFunctionParameters sniff: The new $mode parameter of the php_uname() function was added in PHP 4.3, not in PHP 7.0 as was previously being reported.
The previous implementation of this check was based on an error in the PHP documentation. The error in the PHP documentation has been rectified and the sniff has followed suit. #711PHPCompatibility.Generators.NewGeneratorReturn sniff: The sniff would throw false positives for return statements in nested constructs and did not correctly detect the scope which should be examined. #725. Fixes #724.PHPCompatibility.Keywords.NewKeywords sniff: PHP magic constants are case _in_sensitive. This sniff now accounts for this. #707PHPCompatibility.Syntax.ForbiddenCallTimePassByReference sniff #723:
Thanks go out to [Jonathan Champ] for his contribution to this version. :clap:
See all related issues and PRs in the [8.2.0 milestone].
As of July 13 2018, the PHPCompatibility repository has moved from the personal account of Wim Godden wimg to its own organization PHPCompatibility.
Composer users are advised to update their composer.json. The dependency is now called phpcompatibility/php-compatibility.
Within this new organization, hosting will be offered for framework/CMS specific PHPCompatibility rulesets.
The first two such repositories have been created and are now available for use:
If you want to make sure you have all PHPCompatibility rulesets available at any time, you can use the PHPCompatibilityAll package [GitHub][gh-phpcompat-all]|[Packagist][packagist-phpcompat-all].
For more information, see the [Readme][README-framework-rulesets] and [Contributing guidelines][CONTRIBUTING-framework-rulesets].
The next version of PHPCompatibility will include a major directory layout restructuring which means that the sniff codes of all sniffs will change.
In this same release, support for PHP_CodeSniffer 1.5.x will be dropped. The new minimum supported PHPCS version will be 2.3.0.
For more information about these upcoming changes, please read the announcement.
The 9.0.0 release is expected to be ready later this summer.
ArgumentFunctionsUsage sniff to detect usage of the func_get_args(), func_get_arg() and func_num_args() functions and the changes regarding these functions introduced in PHP 5.3. #596. Fixes #372.DiscouragedSwitchContinue sniff to detect continue targetting a switch control structure for which E_WARNINGS will be thrown as of PHP 7.3. #687NewClassMemberAccess sniff to detect class member access on instantiation as added in PHP 5.4 and class member access on cloning as added in PHP 7.0. #619. Fixes #53.NewConstantScalarExpressions sniff to detect PHP 5.6 scalar expression in contexts where PHP previously only allowed static values. #617. Fixes #399.NewGeneratorReturn sniff to detect return statements within generators as introduced in PHP 7.0. #618PCRENewModifiers sniff to initially detect the new J regex modifier as introduced in PHP 7.2. #600. Fixes #556.ReservedFunctionNames sniff to report on double underscore prefixed functions and methods. This was previously reported via an upstream sniff. #581NewTrailingComma sniff to detect trailing commas in function calls, method calls, isset() and unset() as will be introduced in PHP 7.3. #632Upgrade/LowPHPCS sniff to give users of old PHP_CodeSniffer versions advance warning when support will be dropped in the near future. #693NewClasses sniff: check for some 40+ additional PHP native classes added in various PHP versions. #573NewClosure sniff: check for usage of self/parent/static:: being used within closures, support for which was only added in PHP 5.4. #669. Fixes #668.NewConstants sniff: recognize constants added by the PHP 5.5+ password extension. #626NewFunctionParameters sniff: recognize a number of additional function parameters added in PHP 7.0, 7.1 and 7.2. #602NewFunctions sniff: recognize the PHP 5.1 SPL extension functions, the PHP 5.1.1 hash_hmac() function, the PHP 5.6 pg_lo_truncate() function, more PHP 7.2 Sodium functions and the new PHP 7.3 is_countable() function. #606, #625, #640, #651NewHashAlgorithms sniff: recognize the new hash algorithms which were added in PHP 7.1. #599NewInterfaces sniff: check for the PHP 5.0 Reflector interface. #572OptionalRequiredFunctionParameters sniff: detect missing $salt parameter in calls to the crypt() function (PHP 5.6+). #605RequiredOptionalFunctionParameters sniff: recognize that the $varname parameter of getenv() and the $scale parameter of bcscale() have become optional as of PHP 7.1 and 7.3 respectively. #598, #612AbstractFunctionCallParameterSniff to be used as a basis for sniffs examining function call parameters. #636getReturnTypeHintName() utility method to the PHPCompatibility\Sniff class. #578, #642isNumber(), isPositiveNumber() and isNegativeNumber() utility methods to the PHPCompatibility\Sniff class. #610, #650isShortList() utility method to the PHPCompatibility\Sniff class. #635getCommandLineData() method to the PHPCompatibility\PHPCSHelper class to provide PHPCS cross-version compatible access to command line info at run time. #693findEndOfStatement() method to the PHPCompatibility\PHPCSHelper class to allow for PHPCS cross-version usage of that method. #614PHPCompatibility\Sniff::isUseOfGlobalConstant() method handles multi-constant declarations correctly. #587PHPCompatibility\Sniff::isClassProperty() method handles multi-property declarations correctly. #583testVersion in a custom ruleset to be overruled by the command-line. #607phpcompatibility/php-compatibility.getReturnTypeHintToken() utility method has been made compatible with the changes in the PHPCS tokenizer which were introduced in PHP_CodeSniffer 3.3.0. #642. Fixes #639.ConstantArrayUsingConst: improved handling of multi-constant declarations. #593NewHeredocInitialize: improved handling of constant declarations using the const keyword.
The sniff will now also report on multi-declarations for variables, constants and class properties and on using heredoc as a function parameter default. #641ForbiddenEmptyListAssignment: this sniff will now also report on empty list assignments when the PHP 7.1 short list syntax is used. #653ForbiddenNegativeBitshift sniff would previously only report on "bitshift right". As of this version, "bitshift left" and bitshift assignments will also be recognized. #614NewClasses and NewInterfaces sniffs will now also report on new classes/interfaces when used as return type declarations. [#578NewScalarTypeDeclarations sniff will now recognize parent as a valid type declaration.
The sniff will now also throw an error about using self and parent when PHP < 5.2 needs to be supported as PHP 5.1 and lower would presume these to be class names instead of keywords. #595PregReplaceEModifier sniff - and the PCRENewModifiers sniff by extension - will now correctly examine and report on modifiers in regexes passed via calls to preg_replace_callback_array(). #600, #636getReturnTypeHintToken() utility method: improved support for interface methods and abstract function declarations. [#652]findExtendedClassName(), findImplementedInterfaceNames(), getMethodParameters() utility methods which are duplicates of upstream PHPCS methods, have been moved from the PHPCompatibility\Sniff class to the PHPCompatibility\PHPCSHelper class and have become static methods. #613getReturnTypeHintToken() utility method: align returned $stackPtr with native PHPCS behaviour by returning the last token of the type declaration. #575getMethodParameters() method with improved upstream version. #643MbstringReplaceEModifier, PregReplaceEModifier and the PregReplaceEModifier sniffs now extend the new AbstractFunctionCallParameterSniff class. This should yield more accurate results when checking whether one of the target PHP functions was called. #636DeprecatedNewReference sniff: minor change to the error text and code - was Forbidden, now Removed -. Custom rulesets which explicitly excluded this error code will need to be updated. #594NewScalarTypeDeclarations sniff: minor change to the error message text.#644PHP. #634roave/security-advisories, allowing for PHPUnit 7.x. #604, #616, #622, #646composer.json file, validation of the framework specific rulesets. #570, #571, #579, #621, #631Generic.NamingConventions.CamelCapsFunctionName. Double underscore prefixed function names are now being reported on by a new dedicated sniff. #581Generic.NamingConventions.CamelCapsFunctionName sniff was included in PHPCompatibility. Some error codes of this sniff were excluded, as well as some error messages changed (via the ruleset).
If/when PHPCompatibility would be used in combination with a code style-type ruleset, this could inadvertently lead to underreporting of issues which the CS-type ruleset intends to have reported - i.e. the error codes excluded by PHPCompatibility -. This has now been fixed. #581ForbiddenNegativeBitshift sniff would incorrectly throw an error when a bitshift was based on a calculation which included a negative number, but would not necessarily result in a negative number. #614. Fixes #294, #466.NewClosure sniff would report the same issue twice when the issue was encountered in a nested closure. #669NewKeywords sniff would underreport on non-lowercase keywords. #627NewKeywords sniff would incorrectly report on the use of class constants and class properties using the same name as a keyword. #627NewNullableTypes sniff would potentially underreport when comments where interspersed in the (return) type declarations. #577Sniff::getFunctionCallParameters() utility method would in rare cases return incorrect results when it encountered a closure as a parameter. #682Sniff::getReturnTypeHintToken() utility method would not always return a $stackPtr. #645PHPCompatibility\Tests\BaseClass\MethodTestFrame::getTargetToken() could potentially not find the correct token to run a test against. #588Thanks go out to [Michael Babker] and [Juliette Reinders Folmer] for their contributions to this version. :clap:
See all related issues and PRs in the [8.1.0 milestone].
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.MagicAutoloadDeprecation sniff to detect deprecated __autoload() functions as deprecated in PHP 7.2. #540OptionalRequiredFunctionParameter sniff to check for missing function call parameters which were required and only became optional in a later PHP version. #524DynamicAccessToStatic sniff to detect dynamic access to static methods and properties, as well as class constants, prior to PHP 5.3. #535. Fixes #534.DeprecatedFunctions sniff: recognize yet more PHP 7.2 deprecated functions. #561, #566DeprecatedIniDirectives sniff: recognize the last of the PHP 7.2 deprecated ini directives. #566, #567NewFunctions : detection of all new PHP 7.2 functions added. #522, #545, #551, #565RemovedExtensions : report on usage of the mcrypt extension which has been removed in PHP 7.2. #566RemovedGlobalVariables : detection of the use of $php_errormsg with track_errors which has been deprecated in PHP 7.2. #528NewClosures : downgraded "$this found in closure outside class" to warning. #536. Fixes #527.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. #564ForbiddenGlobalVariableVariable : the sniff will now throw warnings for non-bare variables used in a global statement as those are discouraged since PHP 7.0. #564NewLanguageConstructs : updated the version number for T_COALESCE_EQUAL. #523Sniff::getTestVersion() : simplified regex logic. #520FindExtendedClassname() method with upstream. #507DealerDirect/phpcodesniffer-composer-installer Composer plugin has been upped to 0.4.3. #548ForbiddenCallTimePassByReference : a false positive was being thrown when a global constant was followed by a bitwise and. #562. Fixes [#39].ForbiddenGlobalVariableVariable : the sniff was overzealous and would also report on global in combination with variable variables which are still supported. #564. Fixes #537.ForbiddenGlobalVariableVariable : variables interspersed with whitespace and/or comments were not being reported. #564ForbiddenNamesAsInvokedFunctions : 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 #515VariableVariables : variables interspersed with whitespace and/or comments were not being reported. #563Thanks go out to [Juliette Reinders Folmer] and [Jonathan Van Belle] for their contributions to this version. :clap:
See all related issues and PRs in the [8.0.1 milestone].
DeprecatedTypeCasts sniff to detect deprecated and removed type casts, such as the (unset) type cast as deprecated in PHP 7.2. #498NewTypeCasts sniff to detect type casts not present in older PHP versions such as the (binary) type cast as added in PHP 5.2.1. #497NewGroupUseDeclaration: Detection of PHP 7.2 trailing commas in group use statements. #504DeprecatedFunctions sniff: recognize some more PHP 7.2 deprecated functions. #501DeprecatedIniDirectives sniff: recognize more PHP 7.2 deprecated ini directives. #500ForbiddenNames sniff: recognize object as a forbidden keyword since PHP 7.2. #499NewReturnTypeDeclarations sniff: recognize generic parent, PHP 7.1 iterable and PHP 7.2 object return type declarations. #505, #499NewScalarTypeDeclarations sniff: recognize PHP 7.2 object type declarion. #499Thanks go out to [Juliette Reinders Folmer] for her contributions to this version. :clap:
IMPORTANT: This release contains a breaking change. Please read and follow the Upgrade guide in the wiki carefully before upgrading!
The directory layout of the PHPCompatibility standard has been changed for improved compatibility with Composer.
This means that the PHPCompatibility standard no longer extends from the root directory of the repository, but now lives in its own subdirectory /PHPCompatibility.
This release also bring compatibility with PHPCS 3.x to the PHPCompatibility standard.
See all related issues and PRs in the [8.0.0 milestone].
functionWhitelist property for the PHPCompatibility.PHP.RemovedExtensions sniff is now only supported in combination with PHP CodeSniffer 2.6.0 or higher (due to an upstream bug which was fixed in PHPCS 2.6.0). #482composer.json file. #446, #482, #486--prefer-source or by checking out a git clone of the repository. #494.dist extensions or moved for easier access. #478, #479, #483, #493Thanks go out to [Gary Jones] and [Juliette Reinders Folmer] for their contributions to this version. :clap:
See all related issues and PRs in the [7.1.5 milestone].
NewKeywords sniff will now also sniff for yield from which was introduced in PHP 7.0. #477. Fixes #476NewExecutionDirectives sniff will now also report on execution directives when used in combination with PHPCS 2.0.0-2.3.3. #451getMethodParameters() utility method will no longer break when used with PHPCS 1.5.x < 1.5.6. This affected a number of sniffs. #452inUseScope() utility method will no longer break when used with PHPCS 2.0.0 - 2.2.0. This affected a number of sniffs. #454DefaultTimeZoneRequired sniff. This sniff was checking server settings rather than code. #458. Fixes #457NewMagicClassConstant sniff as introduced in v 7.1.4 contained two additional checks for not strictly compatibility related issues. One of these was plainly wrong, the other opinionated. Both have been removed. #442. Fixes #436NewClasses sniff: was reporting an incorrect introduction version number for a few of the Exception classes. #441. Fixes #440.ForbiddenBreakContinueVariableArguments sniff: was incorrectly reporting an error if the break or continue was followed by a PHP closing tag (breaking out of PHP). #462. Fixes #460ForbiddenGlobalVariableVariable sniff: was incorrectly reporting an error if the global statement was followed by a PHP closing tag (breaking out of PHP). #463.DeprecatedFunctions sniff: was reporting false positives for classes using the same name as a deprecated function. #465. Fixes #464Thanks go out to [Juliette Reinders Folmer] and [Mark Clements] for their contributions to this version. :clap:
See all related issues and PRs in the [7.1.4 milestone].
CaseSensitiveKeywords sniff to detect use of non-lowercase self, static and parent keywords which could cause compatibility issues pre-PHP 5.5. #382ConstantArraysUsingConst sniff to detect constants defined using the const keyword being assigned an array value which was not supported prior to PHP 5.6. #397ForbiddenClosureUseVariableNames sniff to detect PHP 7.1 forbidden variable names in closure use statements. #386. Fixes #374NewArrayStringDereferencing sniff to detect array and string literal dereferencing as introduced in PHP 5.5. #388NewHeredocInitialize sniff to detect initialization of static variables and class properties/constants using the heredoc syntax which is supported since PHP 5.3. #391. Fixes #51NewMagicClassConstant sniff to detect use of the magic ::class constant as introduced in PHP 5.5. #403. Fixes #364.NewUseConstFunction sniff to detect use statements importing constants and functions as introduced in PHP 5.6. #401DeprecatedFunctions sniff: recognize PHP 7.2 deprecated GD functions. #392DeprecatedIniDirectives sniff: recognize PHP 7.2 deprecated mbstring.func_overload directive. #377NewClasses sniff: check for the PHP 5.1 libXMLError class. #412NewClasses sniff: recognize all native PHP Exception classes. #418NewClosure sniff: check for closures being declared as static and closures using $this. Both of which was not supported pre-PHP 5.4. #389. Fixes #24.NewFunctionParameters sniff: recognize new exclude_disabled parameter for the get_defined_functions() function as introduced in PHP 7.0.15. #375NewFunctions sniff: recognize new PHP 7.2 socket related functions. #376NewInterfaces sniff: check for some more PHP native interfaces. #411isClassProperty(), isClassConstant() and validDirectScope() utility methods to the PHPCompatibility_Sniff class. #393, #391.getTypeHintsFromFunctionDeclaration() utility method to the PHPCompatibility_Sniff class. #414.NewMagicMethods sniff. #381getTestVersion() utility method. #405, #430installed_paths via a custom ruleset. #407Changelog.md file containing a record of notable changes since the first tagged release. #421ForbiddenNamesAsDeclared sniff will now emit warnings for soft reserved keywords. #406, #370.ForbiddenNames sniff will now allow for the more liberal rules for usage of reserved keywords as of PHP 7.0. #417InternalInterfaces, NewClasses, NewConstVisibility, NewInterfaces, NewMagicMethods, NonStaticMagicMethods and RemovedGlobalVariables sniffs will now also sniff for and correctly report violations in combination with anonymous classes. #378, #383, #393, #394, #395, #396. Fixes #351 and #333.NewClasses and NewInterfaces sniffs will now also report on new classes/interfaces when used as type hints. #414, #416. Fixes #352NewClasses sniff will now also report on Exception classes when used in (multi-)catch statements. #418. Fixes #373.NewScalarTypeDeclarations sniff will now report on new type hints even when the type hint is nullable. #379NewNowdoc sniff has been renamed to NewNowdocQuotedHeredoc and will now also check for double quoted heredoc identifiers as introduced in PHP 5.3. #390NewClasses sniff will now also report anonymous classes which extend a new sniff when used in combination with PHPCS 2.4.0-2.8.0. #432. Fixes #334.NewFunctionParameter sniff: version number precision for two parameters. #384, #428ForbiddenClosureUseVariable sniff when run on PHPCS 2.5.1 as these cause an infinite loop due to an upstream bug. #408traits in combination with PHP < 5.4 and PHPCS < 2.4.0 as traits are not recognized in those circumstances. #431testVersion resulted in unreported errors when used with sniffs using the supportsBelow() method. This affected the results of approximately half the sniffs. #430ForbiddenNames sniff would throw false positives for use statements with the final modifier in traits. #402.ForbiddenNames sniff would fail to report on functions declared to return by reference using a reserved keyword as the function name. #413ForbiddenNames sniff would only examine the first part of a namespace and not report on reserved keywords used in subsequent parts of a nested namespace. #419ForbiddenNames sniff would not always correctly report on use statements importing constants or functions using reserved keywords. #420NewKeywords sniff would sometimes fail to report on the const keyword when used in a class, but not for a class constant. #424master branch to reflect this. This was causing the builds to fail. #422Thanks go out to [Juliette Reinders Folmer] and [Mark Clements] for their contributions to this version. :clap:
See all related issues and PRs in the [7.1.3 milestone].
testVersion config parameter now allows for specifying unbounded ranges.
For example: specifying -5.6 means: check for compatibility with all PHP versions up to and including PHP 5.6;
Specifying 7.0- means: check for compatibility with all PHP versions from PHP 7.0 upwards.
For more information about setting the testVersion, see [Using the compatibility sniffs][README-using-the-sniffs] in the readme.ShortArray sniff. #347supportsBelow(), supportsAbove() and getTestVersion() utility methods. #363Contributing.md file with information about reporting bugs, requesting features, making pull requests and running the unit tests. #350ForbiddenFunctionParametersWithSameName, NewScalarTypeDeclarations, ParameterShadowSuperGlobals sniff will now also sniff for and report violations in closures. #331nowdoc structure has been moved from the NewKeywords sniff to a new stand-alone NewNowdoc sniff which will now also recognize this structure when the sniffs are run on PHP 5.2. #335ForbiddenNames sniff will now also correctly recognize reserved keywords used in a declared namespace when run on PHP 5.2. #362testVersion settings and makes the unit tests run ~6 x faster.
Relevant additional unit tests have been added and others adjusted. #369LongArrays sniff. The checks it contained have been moved into the RemovedGlobalVariables sniff. Both sniffs essentially did the same thing, just for different PHP native superglobals. #354PregReplaceEModifier sniff would throw a false positive if a quote character was used as the regex delimiter. #357RemovedGlobalVariables sniff would report false positives for class properties shadowing the removed $HTTP_RAW_POST_DATA variables. #354.getFQClassNameFromNewToken() utility function could go into an infinite loop causing PHP to run out of memory when examining unfinished code (examination during live coding). #338, #342determineNamespace() utility method would in certain cases not break out a loop. #358Thanks go out to [Arthur Edamov], [Juliette Reinders Folmer], [Mark Clements] and [Tadas Juozapaitis] for their contributions to this version. :clap:
See all related issues and PRs in the [7.1.2 milestone].
VariableVariables sniff to detect variables variables for which the behaviour has changed in PHP 7.0. #310 Fixes #309.NewReturnTypeDeclarations sniff will now also sniff for non-scalar return type declarations, i.e. array, callable, self or a class name. #323NewLanguageConstructs sniff will now also sniff for the null coalesce equal operator ??=. This operator is slated to be introduced in PHP 7.2 and PHPCS already accounts for it. #340getReturnTypeHintToken() utility method to the PHPCompatibility_Sniff class to retrieve return type hints from function declarations in a cross-PHPCS-version compatible way. #323.stripVariables() utility method to the PHPCompatibility_Sniff class to strip variables from interpolated text strings. #314.MbstringReplaceEModifier, PregReplaceEModifier and NewExecutionDirectives sniffs will now also correctly interpret double quoted text strings with interpolated variables. #314, #324.NewNullableTypes sniff will now also report on nullable (return) type hints when used with closures. #323NewReturnTypeDeclarations sniff will now also report on return type hints when used with closures. #323inClassScope() utility method. #315NewScalarReturnTypeDeclarations sniff has been renamed to NewReturnTypeDeclarations. #323ForbiddenNames sniff will now also correctly ignore anonymous classes when used in combination with PHPCS < 2.3.4. #319NewAnonymousClasses sniff will now correctly recognize and report on anonymous classes when used in combination with PHPCS < 2.5.2. #325NewGroupUseDeclarations sniff will now correctly recognize and report on group use statements when used in combination with PHPCS < 2.6.0. #320NewNullableTypes sniff will now correctly recognize and report on nullable return types when used in combination with PHPCS < 2.6.0. #323NewReturnTypeDeclarations sniff will now correctly recognize and report on new return types when used in combination with PHPCS < 2.6.0. #323hasCondition() utility method where appropriate. #315[@group](https://github.com/group) annotations allowing for quicker/easier testing of a select group of tests/sniffs. #305[@covers](https://github.com/covers) annotations to improve code coverage reporting and remove bleed through of accidental coverage. #307ConstantArraysUsingDefine sniff would throw false positives if the value of the define() was retrieved via a function call and an array parameter was passed. #327ForbiddenCallTimePassByReference sniff would throw false positives on assign by reference within function calls or conditions. #302 Fixes the last two cases reported in #68ForbiddenGlobalVariableVariableSniff sniff would only examine the first variable in a global ... statement causing unreported issues if subsequent variables were variable variables. #316NewKeywords sniff would throw a false positive for the const keyword when encountered in an interface. #312NewNullableTypes sniff would not report on nullable return types for namespaced classnames used as a type hint. #323PregReplaceEModifier sniff would always consider the first parameter passed as a single regex, while it could also be an array of regexes. This led to false positives and potentially unreported use of the e modifier when an array of regexes was passed. #300PregReplaceEModifier sniff could misidentify the regex delimiter when the regex to be examined was concatenated together from various text strings taken from a compound parameter leading to false positives. #300Thanks go out to [Juliette Reinders Folmer] for her contributions to this version. :clap:
See all related issues and PRs in the [7.1.1 milestone].
ForbiddenNamesAsDeclared sniff: detection of the PHP 7.1 iterable and void reserved keywords when used to name classes, interfaces or traits. #298ForbiddenNamesAsInvokedFunctions sniff would incorrectly throw an error if the clone keyword was used with parenthesis. #299. Fixes #284Thanks go out to [Juliette Reinders Folmer] for her contributions to this version. :clap:
See all related issues and PRs in the [7.1.0 milestone].
stringToErrorCode(), arrayKeysToLowercase() and addMessage() utility methods to the PHPCompatibility_Sniff class. #291.RemovedExtensions sniff now verify that the correct alternative extension is being suggested. #291Thanks go out to [Juliette Reinders Folmer] for her contributions to this version. :clap:
See all related issues and PRs in the [7.0.8 milestone].
ForbiddenNamesAsDeclared sniff: detection of the other reserved keywords which are reserved as of PHP 7.0 (or higher). #287. Fixes #115.
These were previously sniffed for by the ForbiddenNames and ForbiddenNamesAsInvokedFunctions sniffs causing false positives as the rules for their reservation are different from the rules for "normal" reserved keywords.inUseScope() utility method to the PHPCompatibility_Sniff class which handles PHPCS cross-version compatibility when determining the scope of a use statement. #271.ForbiddenNames sniff. #271.warning. Removed or otherwise unavailable functionality should throw an error. This distinction was previously not consistently applied everywhere. #286
This change affects the following sniffs:
DeprecatedPHP4StyleConstructors will now throw a warning instead of an error for deprecated PHP4 style class constructors.ForbiddenCallTimePassByReference will now throw a warning if the testVersion is 5.3 and an error if the testVersion if 5.4 or higher.MbstringReplaceEModifier will now throw a warning instead of an error for usage of the deprecated e modifier.PregReplaceEModifier will now throw a warning if the testVersion is 5.5 or 5.6 and an error if the testVersion if 7.0 or higher. Fixes #290.TernaryOperators will now throw an error when the testVersion < 5.3 and the middle part has been omitted.ValidIntegers will now throw a warning when an invalid binary integer is detected.DeprecatedFunctions and DeprecatedIniDirectives sniffs: minor change in the sniff error message text. Use "removed" rather than the ominous "forbidden". #285
Also updated relevant internal variable names and documentation to match.ForbiddenNames sniff would throw false positives for use statements which changed the visibility of methods in traits. #271.ForbiddenNames sniff would not report reserved keywords when used in combination with use function or use const. #271.ForbiddenNames sniff would potentially - unintentionally - skip over tokens, thereby - potentially - not reporting all errors. #271.prefer-stable should be a root element of the json file. Fixes #277.Thanks go out to [Juliette Reinders Folmer] for her contributions to this version. :clap:
See all related issues and PRs in the [7.0.7 milestone].
ForbiddenBreakContinueOutsideLoop sniff: verify that break/continue is not used outside of a loop structure. This will cause fatal errors since PHP 7.0. #278. Fixes #275NewConstVisibility sniff: detect visibility indicators for class and interface constants as introduced in PHP 7.1. #280. Fixes #249NewHashAlgorithms sniff to check used hash algorithms against the PHP version in which they were introduced. #242NewMultiCatch sniff: detect catch statements catching multiple Exceptions as introduced in PHP 7.1. #281. Fixes #251NewNullableTypes sniff: detect nullable parameter and return type hints (only supported in PHPCS >= 2.3.4) as introduced in PHP 7.1. #282. Fixes #247DeprecatedIniDirectives sniff: recognize PHP 7.1 removed session ini directives. #256NewFunctions sniff: recognize new socket_export_stream() function as introduced in PHP 7.0.7. #264NewFunctions sniff: recognize new curl_...(), is_iterable(), pcntl_async_signals(), session_create_id(), session_gc() functions as introduced in PHP 7.1. #273NewFunctionParameters sniff: recognize new OpenSSL function parameters as introduced in PHP 7.1. #258NewIniDirectives sniff: recognize new session ini directives as introduced in PHP 7.1. #259NewScalarReturnTypeDeclarations sniff: recognize PHP 7.1 void return type hint. #250NewScalarTypeDeclarations sniff: recognize PHP 7.1 iterable type hint. #255mcrypt functionality in the RemovedExtensions, DeprecatedFunctions and DeprecatedIniDirectives sniffs. #257LongArrays sniff used to only throw warnings. It will now throw errors for PHP versions in which the long superglobals have been removed. #270NewIniDirectives sniff used to always throw an warning. Now it will throw an error when a new ini directive is used in combination with ini_set(). #246.RemovedHashAlgorithms sniff: also recognize removed algorithms when used with the PHP 5.5+ hash_pbkdf2() function. #240getMethodParameters() utility method. #282DeprecatedPHP4StyleConstructors sniff: minor error message text fix. #236NewIniDirectives sniff: improved precision for the introduction version numbers being reported. #246NewScalarReturnTypeDeclarations sniff. #250DeprecatedPHP4StyleConstructors sniff would not report errors when the case of the class name and the PHP4 constructor function name did not match. #236LongArrays sniff would report false positives for class properties shadowing removed PHP superglobals. #270. Fixes #268.NewClasses sniff would not report errors when the case of the class name used and "official" class name did not match. #237NewIniDirectives sniff would report violations against the PHP version in which the ini directive was introduced. This should be the version below it. #246PregReplaceEModifier sniff would report false positives for compound regex parameters with different quote types. #266. Fixes #265.RemovedGlobalVariables sniff would report false positives for lowercase/mixed cased variables shadowing superglobals. #245.RemovedHashAlgorithms sniff would not report errors when the case of the hash function name used and "official" class name did not match. #240ShortArray sniff would report all violations on the line of the PHP open tag, not on the lines of the short array open/close tags. #238Thanks go out to [Juliette Reinders Folmer] for her contributions to this version. :clap:
See all related issues and PRs in the [7.0.6 milestone].
stripQuotes() utility method in the PHPCompatibility_Sniff base class to strip quotes which surround text strings in a consistent manner. #224ForbiddenCallTimePassByReference sniff will now also report the deprecation as of PHP 5.3, not just its removal as of PHP 5.4. #203NewFunctionArrayDereferencing sniff will now also check method calls for array dereferencing, not just function calls. #229. Fixes #227.NewExecutionDirectives sniff will now throw warnings instead of errors for invalid values encountered in execution directives. #223findImplementedInterfaceNames() utility method when it exists. #222EmptyNonVariable sniff would throw false positives for variable variables and for array access with a (partially) variable array index. #212. Fixes #210.NewFunctionArrayDereferencing sniff would throw false positives for lines of code containing both a function call as well as square brackets, even when they were unrelated. #228. Fixes #226.ParameterShadowSuperGlobals sniff would report false positives for lowercase/mixed cased variables shadowing superglobals. #218. Fixes #214.determineNamespace() utility method now accounts properly for namespaces within scoped declare() statements. #221Thanks go out to [Jason Stallings], [Juliette Reinders Folmer] and [Mark Clements] for their contributions to this version. :clap:
See all related issues and PRs in the [7.0.5 milestone].
MbstringReplaceEModifier sniff to detect the use of the PHP 7.1 deprecated e modifier in Mbstring regex functions. #202ForbiddenBreakContinueVariableArguments sniff will now also report on break 0/continue 0 which is not allowed since PHP 5.4. #209getFunctionCallParameters(), getFunctionCallParameter() utility methods in the PHPCompatibility_Sniff base class. #170tokenHasScope() utility method in the PHPCompatibility_Sniff base class. #189goto and callable detection and some other miscellanous extra unit tests for the NewKeywords sniff. #189ForbiddenNames sniff will now also check interface declarations for usage of reserved keywords. #200PregReplaceEModifier sniff: improved handling of regexes build up of a combination of variables, function calls and/or text strings. #201NewKeywords sniff will now also correctly recognize new keywords when used in combination with older PHPCS versions and/or run on older PHP versions. #189PregReplaceEModifier sniff: minor improvement to the error message text. #201Tests. #215ConstantArraysUsingDefine sniff: the version check logic was reversed causing the error not to be reported in certain circumstances. #199DeprecatedIniDirectives and NewIniDirectives sniffs could potentially trigger on the ini value instead of the ini directive name. #170ForbiddenNames sniff: Reserved keywords when used as the name of a constant declared using define() would always be reported independently of the testVersion set. #200PregReplaceEModifier sniff would not report errors when the function name used was not in lowercase. #201TernaryOperators sniff: the version check logic was reversed causing the error not to be reported in certain circumstances. #188getFQClassNameFromNewToken() and getFQClassNameFromDoubleColonToken() utility methods would get confused when the class name was a variable instead of being hard-coded, resulting in a PHP warning being thown. #206. Fixes #205.getFunctionCallParameters() utility method would incorrectly identify an extra parameter if the last parameter passed to a function would have an - unnecessary - comma after it. The getFunctionCallParameters() utility method also did not handle parameters passed as short arrays correctly. #213. Fixes #211.NewFunctionArrayDereferencing sniff were not being run due to a naming error. #208testVersion from a custom ruleset was incorrect. #204Thanks go out to [Juliette Reinders Folmer] and [Yoshiaki Yoshida] for their contributions to this version. :clap:
See all related issues and PRs in the [7.0.4 milestone].
EmptyNonVariable sniff: detection of empty being used on non-variables for PHP < 5.5. #187NewMagicMethods sniff: detection of declaration of magic methods before the method became "magic". Includes a check for the changed behaviour for the __toString() magic method in PHP 5.2. #176. Fixes #64.RemovedAlternativePHPTags sniff: detection of ASP and script open tags for which support was removed in PHP 7.0. #184, #193. Fixes #127.NonStaticMagicMethods sniff: detection of the __callStatic(), __sleep(), __toString() and __set_state() magic methods.NonStaticMagicMethods sniff: will now also sniff traits for magic methods. #174NonStaticMagicMethods sniff: will now also check for magic methods which should be declared as static. #174testVersion to speed up the running of the unit tests. These are now ~3 x faster. #148ForbiddenBreakContinueVariableArguments sniff would not report on break/continue with a closure as an argument. #171ForbiddenNamesAsInvokedFunctions sniff would not report on reserved keywords which were not lowercase. #186ForbiddenNamesAsInvokedFunctions sniff would not report on the goto and namespace keywords when run on PHP 5.2. #193NewAnonymousClasses sniff: the version check logic was reversed causing the error not to be reported in certain circumstances. #195NewGroupUseDeclarations sniff: the version check logic was reversed causing the error not to be reported in certain circumstances. #190NonStaticMagicMethods sniff would not report on magic methods when the function name as declared was not in the same case as used in the PHP manual. #1740 if PHPCS could not be found. #191Thanks go out to [Juliette Reinders Folmer] for her contributions to this version. :clap:
See all related issues and PRs in the [7.0.3 milestone].
InternalInterfaces sniff: detection of internal PHP interfaces being which should not be implemented by user land classes. #144LateStaticBinding sniff: detection of PHP 5.3 late static binding. #177NewExecutionDirectives sniff: verify execution directives set with declare(). #169NewInterfaces sniff: detection of the use of newly introduced PHP native interfaces. This sniff will also detect unsupported methods when a class implements the Serializable interface. #144RequiredOptionalFunctionParameters sniff: detection of missing function parameters which were required in earlier PHP versions only to become optional in later versions. #165ValidIntegers sniff: detection of binary integers for PHP < 5.4, detection of hexademical numeric strings for which recognition as hex integers was removed in PHP 7.0, detection of invalid binary and octal integers. #160. Fixes #55.DeprecatedExtensions sniff: detect removal of the ereg extension in PHP 7. #149DeprecatedFunctions sniff: detection of the PHP 5.0.5 deprecated php_check_syntax() and PHP 5.4 deprecated mysqli_get_cache_stats() functions. #155.DeprecatedFunctions sniff: detect deprecation of a number of the mysqli functions in PHP 5.3. #149DeprecatedFunctions sniff: detect removal of the call_user_method(), ldap_sort(), ereg_*() and mysql_*() functions in PHP 7.0. #149DeprecatedIniDirectives sniff: detection of a lot more deprecated/removed ini directives. #146NewFunctionParameters sniff: detection of a lot more new function parameters. #164NewFunctions sniff: detection of numerous extra new functions. #161NewIniDirectives sniff: detection of a lot more new ini directives. #146NewLanguageConstructs sniff: detection of the PHP 5.6 ellipsis ... construct. #175NewScalarTypeDeclarations sniff: detection of PHP 5.1 array and PHP 5.4 callable type hints. #168RemovedFunctionParameters sniff: detection of a few extra removed function parameters. #163Generic.NamingConventions.CamelCapsFunctionName sniff is re-used for this with some customization. #173getFQClassNameFromNewToken(), getFQExtendedClassName(), getFQClassNameFromDoubleColonToken(), getFQName(), isNamespaced(), determineNamespace() and getDeclaredNamespaceName() utility methods in the PHPCompatibility_Sniff base class for namespace determination. #162inClassScope() utility method in the PHPCompatibility_Sniff base class. #168doesFunctionCallHaveParameters() and getFunctionCallParameterCount() utility methods in the PHPCompatibility_Sniff base class. #153__halt_compiler() detection by the NewKeywords sniff.NewFunctions sniff. #161ParameterShadowSuperGlobals sniff. #180DeprecatedIniDirectives and the NewIniDirectives sniffs will now indicate an alternative ini directive in case the directive has been renamed. #146NewClasses sniff will now also report on new classes being extended by child classes. #140.NewClasses sniff will now also report on static use of new classes. #162.NewScalarTypeDeclarations sniff will now throw an error on use of type hints pre-PHP 5.0. #168NewScalarTypeDeclarations sniff will now verify type hints used against typical mistakes. #168ParameterShadowSuperGlobals sniff will now do a case-insensitive variable name compare. #180RemovedFunctionParameters sniff will now also report warnings on deprecation of function parameters. #163JsonSerializable has been moved from the NewClasses sniff to the NewInterfaces sniff. #162NewLanguageConstructs sniff will now also recognize new language constructs when used in combination with PHPCS 1.5.x. #175NewFunctionParameters sniff: use correct name for the new parameter for the dirname() function. #164NewScalarTypeDeclarations sniff: minor change in the sniff error message text. #168RemovedFunctionParameters sniff: minor change in the sniff error message text. #163ParameterShadowSuperGlobals sniff now extends the PHPCompatibility_Sniff class. #180DeprecatedFunctions sniff was reporting an incorrect deprecation/removal version number for a few functions. #149DeprecatedIniDirectives sniff was in select cases reporting deprecation of an ini directive prior to removal, while the ini directive was never deprecated prior to its removal. #146DeprecatedPHP4StyleConstructors sniff would cause false positives for methods with the same name as the class in namespaced classes. #167ForbiddenEmptyListAssignment sniff did not report errors when there were only comments or parentheses between the list parentheses. #166ForbiddenEmptyListAssignment sniff will no longer cause false positives during live coding. #166NewClasses sniff would potentially misidentify namespaced classes as PHP native classes. #162NewFunctions sniff would fail to identify called functions when the function call was not lowercase. #161NewFunctions sniff would potentially misidentify namespaced userland functions as new functions. #161NewIniDirectives sniff was reporting an incorrect introduction version number for a few ini directives. #146NewKeywords sniff: the use of the const keyword should only be reported when used outside of a class for PHP < 5.3. #147. Fixes #129.RemovedExtensions sniff was incorrectly reporting a number of extensions as being removed in PHP 5.3 while they were actually removed in PHP 5.1. #156NewFunctionParameters and RemovedFunctionParameters now use the new doesFunctionCallHaveParameters() and getFunctionCallParameterCount() utility methods for improved accuracy in identifying function parameters. This fixes several false positives. #153 Fixes #120, #151, #152.false if the examined construct was not found. This could potentially cause race conditions/infinite sniff loops. #138Thanks go out to [Juliette Reinders Folmer] for her contributions to this version. :clap:
See all related issues and PRs in the [7.0.2 milestone].
RemovedExtensions sniff: ability to whitelist userland functions for which the function prefix overlaps with a prefix of a deprecated/removed extension. #130. Fixes #123.
To use this feature, add the functionWhitelist property in your custom ruleset. For more information, see the [README][README-options].public class properties. Within PHPCS, public properties can be overruled via a custom ruleset. This was not the intention, so the visibility of these properties has been changed to protected. #135Thanks go out to [Juliette Reinders Folmer] for her contributions to this version. :clap:
See all related issues and PRs in the [7.0.1 milestone].
DeprecatedIniDirectives sniff used to throw an error when a deprecated ini directive was used in combination with ini_get(). It will now throw a warning instead. #122 Fixes #119.
Usage of deprecated ini directives in combination with ini_set() will still throw an error.PregReplaceEModifier sniff now also detects the e modifier when used with the preg_filter() function. While this is undocumented, the e modifier was supported by the preg_filter() function as well. #128RemovedExtensions sniff contained superfluous deprecation information in the error message. #131ForbiddenNames sniff did not allow for the PHP 5.6 use function ... and use const ... syntax. #126 Fixes #124.NewClasses sniff failed to detect new classes when the class was instantiated without parenthesis, i.e. new NewClass;. #121PregReplaceEModifier sniff failed to detect the e modifier when using bracket delimiters for the regex other than the {} brackets. #128Thanks go out to [Jason Stallings], [Juliette Reinders Folmer] and [Ryan Neufeld] for their contributions to this version. :clap:
See all related issues and PRs in the [7.0 milestone].
--runtime-set testVersion 5.0-5.4 will now test your code for compatibility with PHP 5.0 up to PHP 5.4. #99NewFunctionArrayDereferencing sniff to detect function array dereferencing as introduced in PHP 5.4. Fixes #52.ShortArray sniff to detect short array syntax as introduced in PHP 5.4. #97. Fixes #47.TernaryOperators sniff to detect ternaries without the middle part (elvis operator) as introduced in PHP 5.3. #101, #103. Fixes #49.ConstantArraysUsingDefine sniff to detect constants declared using define() being assigned an array value which was not allowed prior to PHP 7.0. #110DeprecatedPHP4StyleConstructors sniff to detect PHP 4 style class constructor methods which are deprecated as of PHP 7. #109.ForbiddenEmptyListAssignment sniff to detect empty list() assignments which have been removed in PHP 7.0. #110ForbiddenFunctionParametersWithSameName sniff to detect functions declared with multiple same-named parameters which is no longer accepted since PHP 7.0. #110ForbiddenGlobalVariableVariable sniff to detect variable variables being made global which is not allowed since PHP 7.0. #110ForbiddenNegativeBitshift sniff to detect bitwise shifts by negative number which will throw an ArithmeticError in PHP 7.0. #110ForbiddenSwitchWithMultipleDefaultBlocks sniff to detect switch statements with multiple default blocks which is not allowed since PHP 7.0. #110NewAnonymousClasses sniff to detect anonymous classes as introduced in PHP 7.0. #110NewClosure sniff to detect anonymous functions as introduced in PHP 5.3. Fixes #35NewFunctionParameters sniff to detect use of new parameters in build-in PHP functions. Initially only sniffing for the new PHP 7.0 function parameters and the new PHP 5.3+ before_needle parameter for the strstr() function. #110, #112. Fixes #27.NewGroupUseDeclarations sniff to detect group use declarations as introduced in PHP 7.0. #110NewScalarReturnTypeDeclarations sniff to detect scalar return type hints as introduced in PHP 7.0. #110NewScalarTypeDeclarations sniff to detect scalar function parameter type hints as introduced in PHP 7.0. #110RemovedFunctionParameters sniff to detect use of removed parameters in build-in PHP functions. Initially only sniffing for the function parameters removed in PHP 7.0. #110RemovedGlobalVariables sniff to detect the PHP 7.0 removed $HTTP_RAW_POST_DATA superglobal. #110DeprecatedFunctions sniff: detection of the PHP 5.4 deprecated OCI8 functions. #93ForbiddenNamesAsInvokedFunctions sniff: recognize PHP 5.5 finally as a reserved keywords when invoked as a function. #110NewKeywords sniff: detection of the use of the PHP 5.1+ __halt_compiler keyword. Fixes #50.NewKeywords sniff: detection of the PHP 5.3+ nowdoc syntax. Fixes #48.NewKeywords sniff: detection of the use of the const keyword outside of a class for PHP < 5.3. Fixes #50.DeprecatedFunctions sniff: recognize PHP 7.0 deprecated and removed functions. #110DeprecatedIniDirectives sniff: recognize PHP 7.0 removed ini directives. #110ForbiddenNamesAsInvokedFunctions sniff: recognize new PHP 7.0 reserved keywords when invoked as functions. #110ForbiddenNames sniff: recognize new PHP 7.0 reserved keywords. #110NewFunctions sniff: recognize new functions as introduced in PHP 7.0. #110NewLanguageConstructs sniff: recognize new PHP 7.0 <=> "spaceship" and ?? null coalescing operators. #110RemovedExtensions sniff: recognize PHP 7.0 removed ereg, mssql, mysql and sybase_ct extensions. #110NewLanguageConstructs sniff. #110testVersion config variable.DeprecatedIniDirectives sniff used to always throw an warning. Now it will throw an error when a removed ini directive is used. #110DeprecatedNewReference sniff will now throw an error when the testVersion includes PHP 7.0 or higher. #110ForbiddenNames sniff now supports detection of reserved keywords when used in combination with PHP 7 anonymous classes. #108, #110.PregReplaceEModifier sniff will now throw an error when the testVersion includes PHP 7.0 or higher. #110NewKeywords sniff: clarified the error message text for the use keyword. Fixes #46.testVersion related utility functions. #98composer.json file. #96 Fixes #67.composer.json file. #75ForbiddenCallTimePassByReference sniff was throwing Undefined index notices when used in combination with PHPCS 2.2.0. #100. Fixes #42.ForbiddenNamesAsInvokedFunctions sniff would incorrectly throw an error if the throw keyword was used with parenthesis. Fixes #118.PregReplaceEModifier sniff incorrectly identified e's in the pattern as the e modifier when using {} bracket delimiters for the regex. #94RemovedExtensions sniff was throwing an error instead of a warning for deprecated, but not (yet) removed extensions. Fixes #62.Thanks go out to AlexMiroshnikov, [Chris Abernethy], [dgudgeon], [djaenecke], [Eugene Maslovich], [Ken Guest], Koen Eelen, [Komarov Alexey], [Mark Clements] and [Remko van Bezooijen] for their contributions to this version. :clap:
See all related issues and PRs in the [5.6 milestone].
NewLanguageConstructs sniff. The initial version of this sniff checks for the PHP 5.6 ** power operator and the **= power assignment operator. #87. Fixes #60.ParameterShadowSuperGlobals sniff which covers the PHP 5.4 change Parameter names that shadow super globals now cause a fatal error.`. #74PregReplaceEModifier sniff which detects usage of the e modifier in literal regular expressions used with preg_replace(). The e modifier will not (yet) be detected when the regex passed is a variable or constant. #81, #84. Fixes #71, #83.DeprecatedIniDirectives sniff: PHP 5.6 deprecated ini directives.NewKeywords sniff: detection of the goto keyword introduced in PHP 5.3 and the callable keyword introduced in PHP 5.4. #57PHPCompatibility_Sniff base class initially containing the supportsAbove() and supportsBelow() utility methods. (Nearly) All sniffs now extend this base class and use these methods to determine whether or not violations should be reported for a set testVersion. #77.gitignore to ignore vendor and IDE related directories. #78\ namespace separator has been moved from the NewKeywords sniff to the NewLanguageConstructs sniff. #88DeprecatedIniDirectives sniff: minor change in the sniff error message text.DeprecatedFunctions sniff: minor change in the sniff error message text.composer.json file. #31, #34, #70ForbiddenCallTimePassByReference sniff was throwing false positives when a bitwise and & was used in combination with class constants and class properties within function calls. #44. Partially fixes #39.ForbiddenNamesAsInvokedFunctions sniff was throwing false positives in certain cases when a comment separated a try from the catch block. #29ForbiddenNamesAsInvokedFunctions sniff was incorrectly reporting instanceof as being introduced in PHP 5.4 while it has been around since PHP 5.0. #80Thanks go out to Daniel Jänecke, [Declan Kelly], [Dominic], [Jaap van Otterdijk], [Marin Crnkovic], [Mark Clements], [Nick Pack], [Oliver Klee], [Rowan Collins] and [Sam Van der Borght] for their contributions to this version. :clap:
First tagged release.
See all related issues and PRs in the 5.5 milestone.
How can I help you explore Laravel packages today?