All notable changes to this project will be documented in this file.
This projects adheres to Keep a CHANGELOG.
Up to version 8.0.0, the major.minor version numbers were based on the PHP version for which compatibility check support was added, with patch version numbers being specific to this library.
From version 8.0.0 onwards, Semantic Versioning is used.
Nothing yet.
9.3.5 - 2019-12-27
See all related issues and PRs in the 9.3.5 milestone.
- ⭐
PHPCompatibility.Classes.NewClassessniff: recognize the newFFIextension related classes as introduced in PHP 7.4. #949 - ⭐
PHPCompatibility.IniDirectives.NewIniDirectivessniff: detect use of the newFFIextension related ini directives as introduced in PHP 7.4. #949
- 📝
PHPCompatibility.Syntax.NewShortArray: improved clarity of the error message and made it consistent with other error messages in this standard. #934 - 📝
PHPCompatibility.Interfaces.NewInterfaces: updated the URL which is mentioned in select error messages. #942 - ♻️ Another slew of code documentation fixes. #937, #939, #940, #941, #943, #944, #951, #950. Fixes #734.
- 💚 Travis: various tweaks. The builds against PHP 7.4 are no longer allowed to fail. #935, #938 For running the sniffs on PHP 7.4, it is recommended to use PHP_CodeSniffer 3.5.0+ as PHP_CodeSniffer itself is not compatible with PHP 7.4 until version 3.5.0.
- 🐛
PHPCompatibility.Classes.NewClasses: two new PHP 7.4 classes were being checked as if they were Exceptions. #945
Thanks go out to William Entriken for their contribution to this version. 👏
9.3.4 - 2019-11-15
See all related issues and PRs in the 9.3.4 milestone.
- 🐛
PHPCompatibility.Keywords.ForbiddenNames: false positive for list when used in aforeach()condition. #930. Fixes #928, #929
Thanks go out to Sergii Bondarenko for their contribution to this version. 👏
9.3.3 - 2019-11-11
See all related issues and PRs in the 9.3.3 milestone.
- ⭐
PHPCompatibility.Constants.NewConstantssniff: detection of yet more (undocumented) PHP 7.2 Sodium constants. #924 - ⭐
PHPCompatibility.Keywords.ForbiddenNamessniff: detect the use of more reserved keywords which are not allowed to be used to name certain constructs. #923. Fixes #922
- 🐛
PHPCompatibility.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. #921
Thanks go out to Nikhil for their contribution to this version. 👏
9.3.2 - 2019-10-16
See all related issues and PRs in the 9.3.2 milestone.
- ⭐
PHPCompatibility.Constants.NewConstantssniff: detection of the PHP 7.2SODIUM_CRYPTO_PWHASH_ALG_ARGON2ID13constant. #915 - 📚 Readme: a list of projects which are build upon or extend PHPCompatibility. #904
- 📌
PHPCompatibility.FunctionNameRestrictions.RemovedPHP4StyleConstructors: minor efficiency fix to make the sniff faster. #912 - 📌
PHPCompatibility.FunctionNameRestrictions.ReservedFunctionNames: functions marked as@deprecatedin the function docblock will now be ignored by this sniff. #917. Fixes #911 - 📝
PHPCompatibility.FunctionDeclarations.ForbiddenToStringParameters: the$ooScopeTokensproperty is nowprotected, it should never have beenpublicin the first place. #907 - ♻️ More code documentation fixes. #903, #916
- 📚 Readme/Contributing: various tweaks. #904, #905
- 🐛
PHPCompatibility.FunctionUse.OptionalToRequiredFunctionParameters: false positive when a class is instantiated which has the same name as one of the affected functions. #914. Fixes #913 - 🐛
PHPCompatibility.FunctionUse.RequiredToOptionalFunctionParameters: false positive when a class is instantiated which has the same name as one of the affected functions. #914 - 🐛
PHPCompatibility.MethodUse.NewDirectCallsToClone: false positive on calling__clone()from within the class being cloned #910. Fixes #629 (comment) - 🐛
PHPCompatibility.Miscellaneous.ValidIntegers: binary numbers using an uppercaseBwere not always recognized correctly. #909
9.3.1 - 2019-09-06
See all related issues and PRs in the 9.3.1 milestone.
- ♻️ A whole slew of code documentation fixes. #892, #895, #896, #897, #898, #899, #900
- 🔧 Travis: minor tweaks to the build script. #893
- 🐛
PHPCompatibility.ParameterValues.RemovedImplodeFlexibleParamOrder: false positive when an array item in the second parameter contained a ternary. #891. Fixes #890 - 🐛
PHPCompatibility.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.
9.3.0 - 2019-08-29
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.
- 🌟 New
PHPCompatibility.Miscellaneous.NewPHPOpenTagEOFsniff 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. #843 - 🌟 New
PHPCompatibility.ParameterValues.ForbiddenStripTagsSelfClosingXHTMLsniff to detect calls tostrip_tags()passing self-closing XHTML tags in the$allowable_tagsparameter. This has not been supported since PHP 5.3.4. #866 - 🌟 New
PHPCompatibility.ParameterValues.NewHTMLEntitiesEncodingDefaultsniff to detect calls tohtml_entity_decode(),htmlentities()andhtmlspecialchars()which are impacted by the change to the default value of the$encodingparameter in PHP 5.4. #862 - 🌟 New
PHPCompatibility.ParameterValues.NewIconvMbstringCharsetDefaultsniff to detect code impacted by the change in thedefault_charsetvalue in PHP 5.6. #864 Fixes #839 - 🌟 New
PHPCompatibility.ParameterValues.NewIDNVariantDefaultsniff to detect calls toidn_to_ascii()andidn_to_utf8()impacted by the PHP 7.4 change in the default value for the$variantparameter. #861 - 🌟 New
PHPCompatibility.ParameterValues.NewPasswordAlgoConstantValuessniff to detect calls topassword_hash()andpassword_needs_rehash()impacted by the changed value of thePASSWORD_DEFAULT,PASSWORD_BCRYPT,PASSWORD_ARGON2IandPASSWORD_ARGON2IDconstants in PHP 7.4. #865 - 🌟 New
PHPCompatibility.ParameterValues.NewProcOpenCmdArraysniff to detect calls toproc_open()passing an array for the$cmdparameter as supported as of PHP 7.4. #869 - 🌟 New
PHPCompatibility.ParameterValues.NewStripTagsAllowableTagsArraysniff to detect calls tostrip_tags()passing an array for the$allowable_tagsparameter as will be supported as of PHP 7.4. #867 - 🌟 New
PHPCompatibility.ParameterValues.RemovedImplodeFlexibleParamOrdersniff to detectimplode()being called with$glueand$piecesin reverse order from the documented argument order. This was previously allowed for historical reasons, but will be deprecated in PHP 7.4. #846 - 🌟 New
PHPCompatibility.ParameterValues.RemovedMbStrrposEncodingThirdParamsniff to detect the$encodingbeing passed as the third, instead of the fourth parameter, tomb_strrpos()as has been soft deprecated since PHP 5.2 and will be hard deprecated as of PHP 7.4. #860 - 🌟 New
PHPCompatibility.Syntax.RemovedCurlyBraceArrayAccesssniff to detect array and string offset access using curly braces as will be deprecated as of PHP 7.4. #855- In contrast to any other sniff in the PHPCompatibility standard, this sniff contains an auto-fixer.
- 🌟 New
PHPCompatibility.TextStrings.NewUnicodeEscapeSequencesniff to detect use of the PHP 7.0+ unicode codepoint escape sequences and issues with invalid sequences. #856 - 🌟 New
PHPCompatibility.Upgrade.LowPHPsniff 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.NewClassessniff: recognize the newWeakReferenceclass as introduced in PHP 7.4. #857 - ⭐
PHPCompatibility.Constants.NewConstantssniff: detection of new Curl constants as introduced in PHP 7.3.5. #878 - ⭐
PHPCompatibility.Constants.NewConstantssniff: detection of the revivedT_BAD_CHARACTERconstant as re-introduced in PHP 7.4. #882 - ⭐
PHPCompatibility.Constants.NewConstantssniff: detection of the newIMG_FILTER_SCATTERandPASSWORD_ARGON2_PROVIDERconstants as introduced in PHP 7.4. #887 - ⭐
PHPCompatibility.Constants.RemovedConstantssniff: detection of use of theCURLPIPE_HTTP1constant which will be deprecated in PHP 7.4. #879 - ⭐
PHPCompatibility.Constants.RemovedConstantssniff: detection of use of theFILTER_SANITIZE_MAGIC_QUOTESconstant which will be deprecated in PHP 7.4. #845 - ⭐
PHPCompatibility.Constants.RemovedConstantssniff: detection of use of theT_CHARACTERandT_BAD_CHARACTERconstants which were removed in PHP 7.0. #882 - ⭐
PHPCompatibility.FunctionDeclarations.NewMagicMethodssniff: recognize the new__serialize()and__unserialize()magic methods as introduced in PHP 7.4. #868 - ⭐
PHPCompatibility.FunctionDeclarations.NewMagicMethodssniff: recognize the PHP 5.0__construct()and__destruct()magic methods. #884 - ⭐
PHPCompatibility.FunctionDeclarations.NonStaticMagicMethodssniff: recognize the new__serialize()and__unserialize()magic methods as introduced in PHP 7.4. #868 - ⭐
PHPCompatibility.FunctionUse.NewFunctionssniff: recognize the new PHP 7.4 functionimagecreatefromtga(). #873 - ⭐
PHPCompatibility.FunctionUse.RemovedFunctionParameterssniff: recognize the deprecation of the$ageparameter of thecurl_version()function. #874 - ⭐
PHPCompatibility.FunctionUse.RemovedFunctionssniff: recognize the PHP 7.4 deprecatedconvert_cyr_string()(),ezmlm_hash(),get_magic_quotes_gpc(),get_magic_quotes_runtime(),hebrevc(),is_real(),money_format()andrestore_include_path()functions. #847 - ⭐
PHPCompatibility.IniDirectives.NewIniDirectivessniff: detect use of the new PHP 7.4zend.exception_ignore_argsini directive. #871 - ⭐
PHPCompatibility.IniDirectives.RemovedIniDirectivessniff: detect use of theallow_url_includeini directive which is deprecated as of PHP 7.4. #870 - ⭐
PHPCompatibility.IniDirectives.RemovedIniDirectivessniff: detection of use of theopcache.load_commentsdirective which was removed in PHP 7.0. #883 - ⭐
PHPCompatibility.ParameterValues.NewHashAlgorithms: recognize use of the new PHP 7.4crc32chash algorithm. #872 - ⭐
PHPCompatibility.TypeCasts.RemovedTypeCastssniff: detect usage of the(real)type cast which will be deprecated in PHP 7.4. #844 - ⭐ Recognize the
recodeextension functionality which will be removed in PHP 7.4 (moved to PECL) in theRemovedExtensionsandRemovedFunctionssniffs. #841 - ⭐ Recognize the
OPcacheextension functionality which was be introduced in PHP 5.5, but not yet fully accounted for in theNewFunctionsandNewIniDirectivessniffs. #883 - ⭐ New
getCompleteTextString()utility method to thePHPCompatibility\Sniffclass. #856 - ☔ Unit test for the
PHPCompatibility.Upgrade.LowPHPCSsniff. - ☔ Some extra unit tests for the
PHPCompatibility.ParameterValues.NewNegativeStringOffset,PHPCompatibility.ParameterValues.RemovedMbStringModifiersand sniffs. #876, #877 - 📚
CONTRIBUTING.md: Added a list of typical sources for information about changes to PHP. #875
- 📌
PHPCompatibility.FunctionDeclarations.NewExceptionsFromToStringsniff: the sniff will now also examine the function docblock, if available, and will throw an error when a@throwstag is found in the docblock. #880. Fixes #863 - 📌
PHPCompatibility.FunctionDeclarations.NonStaticMagicMethodssniff: will now also check the visibility andstatic(or not) requirements of the magic__construct(),__destruct(),__clone(),__debugInfo(),__invoke()and__set_state()methods. #885 - 📌
PHPCompatibility.Syntax.NewArrayStringDereferencingsniff: the sniff will now also recognize array string dereferencing using curly braces as was (silently) supported since PHP 7.0. #851- The sniff will now also throw errors for each dereference found on the array/string, not just the first one.
- 📌
PHPCompatibility.Syntax.NewClassMemberAccesssniff: 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- The sniff will now also throw errors for each access detected, not just the first one.
- The line number on which the error is thrown in now set more precisely.
- 📌
PHPCompatibility.Syntax.NewFunctionArrayDereferencingsniff: the sniff will now also recognize function array dereferencing using curly braces as was (silently) supported since PHP 7.0. #853- The sniff will now also throw errors for each access detected, not just the first one.
- The line number on which the error is thrown in now set more precisely.
- ♻️ Various code clean-up and improvements. #849, #850
- ♻️ Various minor inline documentation fixes. #854, #886
- 🔧 Travis: various tweaks to the build script. #834, #842
- 🐛
PHPCompatibility.FunctionDeclarations.ForbiddenParametersWithSameNamesniff: variable names are case-sensitive, so recognition of same named parameters should be done in a case-sensitive manner. #848 - 🐛
PHPCompatibility.FunctionDeclarations.NewExceptionsFromToStringsniff: Exceptions thrown within atryshould not trigger the sniff. #880. Fixes #863 - 🐛
PHPCompatibility.FunctionDeclarations.NewExceptionsFromToStringsniff: the$ooScopeTokensproperty should never have been a public property. #880. - ☔ Some of the unit tests for the
PHPCompatibility.Operators.RemovedTernaryAssociativitysniff were not being run. #836
9.2.0 - 2019-06-28
See 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.
- 🌟 New
PHPCompatibility.Classes.ForbiddenAbstractPrivateMethodssniff to detect methods declared as bothprivateas well asabstract. This was allowed between PHP 5.0.0 and 5.0.4, but disallowed in PHP 5.1 as the behaviour ofprivateandabstractare mutually exclusive. #822 - 🌟 New
PHPCompatibility.Classes.NewTypedPropertiessniff to detect PHP 7.4 typed property declarations. #801, #829 - 🌟 New
PHPCompatibility.Classes.RemovedOrphanedParentsniff to detect the use of theparentkeyword 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. #818 - 🌟 New
PHPCompatibility.FunctionDeclarations.NewExceptionsFromToStringsniff to detect throwing exceptions from__toString()methods. This would previously result in a fatal error, but will be allowed as of PHP 7.4. #814 - 🌟 New
PHPCompatibility.FunctionDeclarations.ForbiddenToStringParameterssniff to detect__toString()function declarations expecting parameters. This was disallowed in PHP 5.3. #815 - 🌟 New
PHPCompatibility.MethodUse.ForbiddenToStringParameterssniff to detect direct calls to__toString()magic methods passing parameters. This was disallowed in PHP 5.3. #830 - 🌟 New
PHPCompatibility.Operators.ChangedConcatOperatorPrecedencesniff 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. #805 - 🌟 New
PHPCompatibility.Operators.RemovedTernaryAssociativitysniff 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. #810 - 🌟 New
PHPCompatibility.Syntax.NewArrayUnpackingsniff to detect the use of the spread operator to unpack arrays when declaring a new array, as introduced in PHP 7.4. #804 - ⭐
PHPCompatibility.Classes.NewClassessniff: recognize the newReflectionReferenceclass as introduced in PHP 7.4. #820 - ⭐
PHPCompatibility.Constants.NewConstantssniff: detection of the new PHP 7.4 Core (Standard), MBString, Socket and Tidy constants. #821 - ⭐
PHPCompatibility.FunctionUse.NewFunctionssniff: detect usage of the new PHP 7.4get_mangled_object_vars(),mb_str_split(),openssl_x509_verify(),password_algos(),pcntl_unshare(),sapi_windows_set_ctrl_handler()andsapi_windows_generate_ctrl_event()functions. #811, #819, #827 - ⭐
PHPCompatibility.FunctionUse.NewFunctionssniff: recognize the new OCI functions as introduced in PHP 7.2.14 and PHP 7.3.1. #786 - ⭐
PHPCompatibility.FunctionUse.RemovedFunctionssniff: recognize the PHP 7.4 deprecatedldap_control_paged_result_response()andldap_control_paged_result()functions. #831 - ⭐
PHPCompatibility.FunctionUse.RemovedFunctionssniff: recognize thePayflow Pro/pfprofunctions as removed in PHP 5.1. #823 - ⭐
PHPCompatibility.FunctionUse.RequiredToOptionalFunctionParameterssniff: account for the parameters forarray_merge()andarray_merge_recursive()becoming optional in PHP 7.4. #817 - ⭐
PHPCompatibility.IniDirectives.RemovedIniDirectivessniff: recognize thePayflow Pro/pfproini directives as removed in PHP 5.1. #823 - ⭐ Recognize the
interbase/Firebirdextension functionality which will be removed in PHP 7.4 (moved to PECL) in theRemovedConstants,RemovedExtensions,RemovedFunctionsandRemovedIniDirectivessniffs. #807 - ⭐ Recognize the
wddxextension functionality which will be removed in PHP 7.4 (moved to PECL) in theRemovedExtensionsandRemovedFunctionssniffs. #826 - ⭐ New
isShortTernary()andisUnaryPlusMinus()utility methods to thePHPCompatibility\Sniffclass. #810, #805
- ✏️ The
PHPCompatibility.Extensions.RemovedExtensionssniff will now only report on the removedPayflow Proextension when a function usespfpro_as a prefix. Previously, it used thepfproprefix (without underscore) for detection. #812 - ✏️ The error message thrown when the
T_ELLIPSIStoken, 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.NewParamTypeDeclarationsis now also tested with parameters using the splat operator. #802 - 📚 The documentation now uses the GitHub repo of
PHP_CodeSnifferas the canonical entry point forPHP_CodeSniffer. Previously, it would point to the PEAR package. #788 - 📚 The links in the changelog now all point to the
PHPCompatibility/PHPCompatibilityrepo and no longer to the (deprecated)wimg/PHPCompatibilityrepo. #828 - ♻️ Various minor inline documentation improvements. #825
- 🔧 Various performance optimizations and code simplifications. #783, #784, #795, #813
- 💚 Travis: build tests are now being run against PHP 7.4 (unstable) as well. #790 Note: the builds are currently not (yet) tested against PHP 8.0 (unstable) as there is no compatible PHPUnit version available (yet).
- 🔧 Travis: The build script has been refactored to use stages to get the most relevant results faster. Additionally some more tweaks have been made to improve and/or simplify the build script. #798
- 🔧 Build/PHPCS: warnings are no longer allowed for the PHPCompatibility native code. #800
- 🔧 Build/PHPCS: added variable assignment alignment check and file include check to the PHPCompatibility native CS configuration. #824
- 🔧 The minimum version for the recommended
DealerDirect/phpcodesniffer-composer-installerComposer plugin has been upped to0.5.0. #791
- 🐛 The
PHPCompatibility.Extensions.RemovedExtensionssniff contained a typo in the alternative recommended for the removedmcveextension. #806 - 🐛 The
PHPCompatibility.Extensions.RemovedExtensionssniff listed the wrong removal version number for thePayflow Pro/pfproextension (PHP 5.3 instead of the correct 5.1). #823
Thanks go out to Yılmaz and Tim Millwood for their contribution to this version. 👏
9.1.1 - 2018-12-31
See all related issues and PRs in the 9.1.1 milestone.
- 🐛
ForbiddenThisUseContexts: false positive for unsetting$this['key']on objects implementingArrayAccess. #781. Fixes #780
9.1.0 - 2018-12-16
See all related issues and PRs in the 9.1.0 milestone.
- 🌟 New
PHPCompatibility.FunctionUse.ArgumentFunctionsReportCurrentValuesniff to detect code which could be affected by the PHP 7.0 change in the values reported byfunc_get_arg(),func_get_args(),debug_backtrace()and exception backtraces. #750. Fixes #585. - 🌟 New
PHPCompatibility.MethodUse.NewDirectCallsToClonesniff to detect direct call to a__clone()magic method which wasn't allowed prior to PHP 7.0. #743. Fixes #629. - 🌟 New
PHPCompatibility.Variables.ForbiddenThisUseContextsniff to detect most of the inconsistencies surrounding the use of the$thisvariable, which were removed in PHP 7.1. #762, #771. Fixes #262 and #740. - ⭐
NewClasses: detection of more native PHP Exceptions. #743, #753 - ⭐
NewConstants: detection of the new PHP 7.3 Curl, Stream Crypto and LDAP constants and some more PHP 7.0 Tokenizer constants. #752, #767, #778 - ⭐
NewFunctionssniff: recognize (more) new LDAP functions as introduced in PHP 7.3. #768 - ⭐
NewFunctionParameterssniff: recognize the new$serverctrlsparameter which was added to a number of LDAP functions in PHP 7.3. #769 - ⭐
NewIniDirectivessniff: recognize the newimap.enable_insecure_rshini directive as introduced in PHP 7.1.25, 7.2.13 and 7.3.0. #770 - ⭐
NewInterfacessniff: recognize two more Session related interfaces which were introduced in PHP 5.5.1 and 7.0 respectively. #748 - ⭐ Duplicate of upstream
findStartOfStatement()method to thePHPCompatibility\PHPCSHelperclass to allow for PHPCS cross-version usage of that method. #750
- 📌
RemovedPHP4StyleConstructors: will now also detect PHP4-style constructors when declared in interfaces. #751 - 📌
Sniff::validDirectScope(): the return value of this method has changed. Previously it would always be a boolean. It will stil returnfalsewhen no valid direct scope has been found, but it will now return thestackPtrto the scope token if a valid direct scope was encountered. #758 - ⏪
NewOperators: updated the version number forT_COALESCE_EQUAL. #746 - 📝 Minor improvement to an error message in the unit test suite. #742
- ♻️ Various code clean-up and improvements. #745, #756, #774
- ♻️ Various minor inline documentation fixes. #749, #757
- ☔ Improved code coverage recording. #744, #776
- 💚 Travis: build tests are now being run against PHP 7.3 as well. #511 Note: full PHP 7.3 support is only available in combination with PHP_CodeSniffer 2.9.2 or 3.3.1+ due to an incompatibility within PHP_CodeSniffer itself.
- ✅ Compatibility with the upcoming release of PHPCS 3.4.0. Deal with changed behaviour of the PHPCS
Tokenizerregarding binary type casts. #760 - 🐛
InternalInterfaces: false negative for implemented/extended interfaces prefixed with a namespace separator. #775 - 🐛
NewClasses: the introduction version of various native PHP Exceptions has been corrected. #743, #753 - 🐛
NewInterfaces: false negative for implemented/extended interfaces prefixed with a namespace separator. #775 - 🐛
RemovedPHP4StyleConstructors: the sniff would examine methods in nested anonymous classes as if they were methods of the higher level class. #751 - ⏪
RemovedPHP4StyleConstructors: 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. #751 - ⏪
ReservedFunctionNames: fixed incorrect error message text for methods in anonymous classes when used in combination with PHPCS 2.3.x. #755 - 🐛
ReservedFunctionNames: prevent duplicate errors being thrown for methods in nested anonymous classes. #755 - 🐛
PHPCSHelper::findEndOfStatement(): minor bug fix. #749 - 🐛
Sniff::isClassProperty(): class properties for classes nested in conditions or function calls were not always recognized as class properties. #758
Thanks go out to Jonathan Champ for his contribution to this version. 👏
9.0.0 - 2018-10-07
IMPORTANT: This release contains breaking changes. Please read the below information 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 | Packagist] as well as the PHPCompatibilityWP [GH|Packagist] 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 | Packagist] for @ircmaxell's password_compat libary, PHPCompatibilityParagonieRandomCompat and PHPCompatibilityParagonieSodiumCompat [GH|Packagist] for the Paragonie polyfills and a number of rulesets related to various polyfills offered by the Symfony project [GH|Packagist].
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.
- If you have
<exclude name="..."/>directives in your own project's custom ruleset which relate to sniffs from the PHPCompatibility library, you will need to update your ruleset to use the new sniff names. - If you use the new PHPCS 3.2+ inline annotations, i.e.
// phpcs:ignore Standard.Category.SniffName, in combination with PHPCompatibility sniff names, you will need to update these annotations. - If you use neither of the above, you should be fine and upgrading should be painless.
| Old Category.SniffName | New Category.SniffName |
|---|---|
| PHP.ArgumentFunctionsUsage | FunctionUse.ArgumentFunctionsUsage |
| PHP.CaseSensitiveKeywords | Keywords.CaseSensitiveKeywords |
| PHP.ConstantArraysUsingConst | InitialValue.NewConstantArraysUsingConst |
| PHP.ConstantArraysUsingDefine | InitialValue.NewConstantArraysUsingDefine |
| PHP.DeprecatedFunctions | FunctionUse.RemovedFunctions |
| PHP.DeprecatedIniDirectives | IniDirectives.RemovedIniDirectives |
| PHP.DeprecatedMagicAutoload | FunctionNameRestrictions.RemovedMagicAutoload |
| PHP.DeprecatedNewReference | Syntax.RemovedNewReference |
| PHP.DeprecatedPHP4StyleConstructors | FunctionNameRestrictions.RemovedPHP4StyleConstructors |
| PHP.DeprecatedTypeCasts | TypeCasts.RemovedTypeCasts |
| PHP.DiscouragedSwitchContinue | ControlStructures.DiscouragedSwitchContinue |
| PHP.DynamicAccessToStatic | Syntax.NewDynamicAccessToStatic |
| PHP.EmptyNonVariable | LanguageConstructs.NewEmptyNonVariable |
| PHP.ForbiddenBreakContinueOutsideLoop | ControlStructures.ForbiddenBreakContinueOutsideLoop |
| PHP.ForbiddenBreakContinueVariableArguments | ControlStructures.ForbiddenBreakContinueVariableArguments |
| PHP.ForbiddenCallTimePassByReference | Syntax.ForbiddenCallTimePassByReference |
| PHP.ForbiddenClosureUseVariableNames | FunctionDeclarations.ForbiddenVariableNamesInClosureUse |
| PHP.ForbiddenEmptyListAssignment | Lists.ForbiddenEmptyListAssignment |
| PHP.ForbiddenFunctionParametersWithSameName | FunctionDeclarations.ForbiddenParametersWithSameName |
| PHP.ForbiddenGlobalVariableVariable | Variables.ForbiddenGlobalVariableVariable |
| PHP.ForbiddenNames | Keywords.ForbiddenNames |
| PHP.ForbiddenNamesAsDeclared | Keywords.ForbiddenNamesAsDeclared |
| PHP.ForbiddenNamesAsInvokedFunctions | Keywords.ForbiddenNamesAsInvokedFunctions |
| PHP.ForbiddenNegativeBitshift | Operators.ForbiddenNegativeBitshift |
| PHP.ForbiddenSwitchWithMultipleDefaultBlocks | ControlStructures.ForbiddenSwitchWithMultipleDefaultBlocks |
| PHP.InternalInterfaces | Interfaces.InternalInterfaces |
| PHP.LateStaticBinding | Classes.NewLateStaticBinding |
| PHP.MbstringReplaceEModifier | ParameterValues.RemovedMbstringModifiers |
| PHP.NewAnonymousClasses | Classes.NewAnonymousClasses |
| PHP.NewArrayStringDereferencing | Syntax.NewArrayStringDereferencing |
| PHP.NewClasses | Classes.NewClasses |
| PHP.NewClassMemberAccess | Syntax.NewClassMemberAccess |
| PHP.NewClosure | FunctionDeclarations.NewClosure |
| PHP.NewConstants | Constants.NewConstants |
| PHP.NewConstantScalarExpressions | InitialValue.NewConstantScalarExpressions |
| PHP.NewConstVisibility | Classes.NewConstVisibility |
| PHP.NewExecutionDirectives | ControlStructures.NewExecutionDirectives |
| PHP.NewFunctionArrayDereferencing | Syntax.NewFunctionArrayDereferencing |
| PHP.NewFunctionParameters | FunctionUse.NewFunctionParameters |
| PHP.NewFunctions | FunctionUse.NewFunctions |
| PHP.NewGeneratorReturn | Generators.NewGeneratorReturn |
| PHP.NewGroupUseDeclarations | UseDeclarations.NewGroupUseDeclarations |
| PHP.NewHashAlgorithms | ParameterValues.NewHashAlgorithms |
| PHP.NewHeredocInitialize | InitialValue.NewHeredoc |
| PHP.NewIniDirectives | IniDirectives.NewIniDirectives |
| PHP.NewInterfaces | Interfaces.NewInterfaces |
| PHP.NewKeywords | Keywords.NewKeywords |
| PHP.NewLanguageConstructs | LanguageConstructs.NewLanguageConstructs |
| PHP.NewMagicClassConstant | Constants.NewMagicClassConstant |
| PHP.NewMagicMethods | FunctionNameRestrictions.NewMagicMethods |
| PHP.NewMultiCatch | ControlStructures.NewMultiCatch |
| PHP.NewNullableTypes | FunctionDeclarations.NewNullableTypes |
| PHP.NewReturnTypeDeclarations | FunctionDeclarations.NewReturnTypeDeclarations |
| PHP.NewScalarTypeDeclarations | FunctionDeclarations.NewParamTypeDeclarations |
| PHP.NewTrailingComma | Syntax.NewFunctionCallTrailingComma |
| PHP.NewTypeCasts | TypeCasts.NewTypeCasts |
| PHP.NewUseConstFunction | UseDeclarations.NewUseConstFunction |
| PHP.NonStaticMagicMethods | FunctionDeclarations.NonStaticMagicMethods |
| PHP.OptionalRequiredFunctionParameters | FunctionUse.OptionalToRequiredFunctionParameters |
| PHP.ParameterShadowSuperGlobals | FunctionDeclarations.ForbiddenParameterShadowSuperGlobals |
| PHP.PCRENewModifiers | ParameterValues.NewPCREModifiers |
| PHP.PregReplaceEModifier | ParameterValues.RemovedPCREModifiers |
| PHP.RemovedAlternativePHPTags | Miscellaneous.RemovedAlternativePHPTags |
| PHP.RemovedConstants | Constants.RemovedConstants |
| PHP.RemovedExtensions | Extensions.RemovedExtensions |
| PHP.RemovedFunctionParameters | FunctionUse.RemovedFunctionParameters |
| PHP.RemovedGlobalVariables | Variables.RemovedPredefinedGlobalVariables |
| PHP.RemovedHashAlgorithms | ParameterValues.RemovedHashAlgorithms |
| PHP.ReservedFunctionNames | FunctionNameRestrictions.ReservedFunctionNames |
| PHP.RequiredOptionalFunctionParameters | FunctionUse.RequiredToOptionalFunctionParameters |
| PHP.ShortArray | Syntax.NewShortArray |
| PHP.TernaryOperators | Operators.NewShortTernary |
| PHP.ValidIntegers | Miscellaneous.ValidIntegers |
| PHP.VariableVariables | Variables.NewUniformVariableSyntax |
See all related issues and PRs in the 9.0.0 milestone.
- 🌟 New
PHPCompatibility.ControlStructures.NewForeachExpressionReferencingsniff to detect referencing of$valuewithin aforeach()when the iterated array is not a variable. This was not supported prior to PHP 5.5. #664 - 🌟 New
PHPCompatibility.ControlStructures.NewListInForeachsniff to detect unpacking nested arrays into separate variables via thelist()construct in aforeach()statement. This was not supported prior to PHP 5.5. #657 - 🌟 New
PHPCompatibility.FunctionNameRestrictions.RemovedNamespacedAssertsniff to detect declaring a function calledassert()within a namespace. This has been deprecated as of PHP 7.3. #735. Partially fixes #718. - 🌟 New
PHPCompatibility.Lists.AssignmentOrdersniff to detectlist()constructs affected by the change in assignment order in PHP 7.0. #656 - 🌟 New
PHPCompatibility.Lists.NewKeyedListsniff to detect usage of keys inlist(), support for which was added in PHP 7.1. #655. Fixes #252. - 🌟 New
PHPCompatibility.Lists.NewListReferenceAssignmentsniff to detect reference assignments being used inlist()constructs, support for which has been added in PHP 7.3. #731 - 🌟 New
PHPCompatibility.Lists.NewShortListsniff to detect the shorthand array syntax[]being used for symmetric array destructuring as introduced in PHP 7.1. #654. Fixes #248. - 🌟 New
PHPCompatibility.Operators.NewOperatorssniff which checks for usage of the pow, pow equals, spaceship and coalesce (equals) operators. #738 These checks were previously contained within thePHPCompatibility.LanguageConstructs.NewLanguageConstructssniff. - 🌟 New
PHPCompatibility.ParameterValues.ForbiddenGetClassNullsniff to detectnullbeing passed toget_class(), support for which has been removed in PHP 7.2 #659. Fixes #557. - 🌟 New
PHPCompatibility.ParameterValues.NewArrayReduceInitialTypesniff to detect non-integers being passed as the$initialparameter to thearray_reduce()function, which was not supported before PHP 5.3. #666. Fixes #649 - 🌟 New
PHPCompatibility.ParameterValues.NewFopenModessniff to examine the$modeparameter passed tofopen()for modes not available in older PHP versions. #658 - 🌟 New
PHPCompatibility.ParameterValues.NewNegativeStringOffsetsniff to detect negative string offsets being passed to string manipulation functions which was not supported before PHP 7.1. #662. Partially fixes #253. - 🌟 New
PHPCompatibility.ParameterValues.NewPackFormatssniff to examine the$formatparameter passed topack()for formats not available in older PHP versions. #665 - 🌟 New
PHPCompatibility.ParameterValues.RemovedIconvEncodingsniff to detect the PHP 5.6 deprecated encoding$types being passed toiconv_set_encoding(). #660. Fixes #475. - 🌟 New
PHPCompatibility.ParameterValues.RemovedNonCryptoHashessniff to detect non-cryptographic hash algorithms being passed to varioushash_*()functions. This is no longer accepted as of PHP 7.2. #663. Fixes #559 - 🌟 New
PHPCompatibility.ParameterValues.RemovedSetlocaleStringsniff to detect string literals being passed to the$categoryparameter of thesetlocale()function. This behaviour was deprecated in PHP 4.2 and support has been removed in PHP 7.0. #661 - 🌟 New
PHPCompatibility.Syntax.NewFlexibleHeredocNowdocsniff 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.NewClassessniff: recognize the newCompileErrorandJsonExceptionclasses as introduced in PHP 7.3. #676 - ⭐
PHPCompatibility.Constants.NewConstantssniff: recognize new constants which are being introduced in PHP 7.3. #678 - ⭐
PHPCompatibility.Constants.RemovedConstantssniff: recognize constants which have been deprecated or removed in PHP 7.3. #710. Partially fixes #718. - ⭐
PHPCompatibility.FunctionUse.NewFunctionssniff: recognize various new functions being introduced in PHP 7.3. #679 - ⭐
PHPCompatibility.FunctionUse.NewFunctionssniff: recognize thesapi_windows_*(),hash_hkdf()andpcntl_signal_get_handler()functions as introduced in PHP 7.1. #728 - ⭐
PHPCompatibility.FunctionUse.RemovedFunctionParameterssniff: recognize the deprecation of the$case_insensitiveparameter for thedefine()function in PHP 7.3. #706 - ⭐
PHPCompatibility.FunctionUse.RemovedFunctionssniff: recognize the PHP 7.3 deprecation of theimage2wbmp(),fgetss()andgzgetss()functions, as well as the deprecation of undocumented Mbstring function aliases. #681, #714, #720. Partially fixes #718. - ⭐
PHPCompatibility.FunctionUse.RequiredToOptionalFunctionParameterssniff: account for the second parameter forarray_push()andarray_unshift()becoming optional in PHP 7.3, as well as for the$modeparameter for a range offtp_*()functions becoming optional. #680 - ⭐
PHPCompatibility.IniDirectives.NewIniDirectivessniff: recognize newsyslogandsessionini directives as introduced in PHP 7.3. #702, #719, #730 - ⭐
PHPCompatibility.IniDirectives.NewIniDirectivessniff: recognize some more ini directives which were introduced in PHP 7.1. #727 - ⭐
PHPCompatibility.IniDirectives.RemovedIniDirectivedsniff: recognize ini directives removed in PHP 7.3. #677, #717. Partially fixes #718. - ⭐ New
isNumericCalculation()andisVariable()utility methods to thePHPCompatibility\Sniffclass. #664, #666 - 📚 A section about the new sniff naming conventions to the
Contributingfile. #738
- 🔥 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. #738. Fixes #601, #692 See the table at the top of this changelog for details of all the file renames.
- ☔ The unit test files have been moved about as well. #738
- The directory structure for these now mirrors the default directory structure used by PHPCS itself.
- The file names of the unit test files have been adjusted for the changes made in the sniffs.
- The unit test case files have been renamed and moved to the same directory as the actual test file they apply to.
- The
BaseSniffTest::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. - The unit tests for the utility methods in the
PHPCompatibility\Sniffclass have been moved to a newPHPCompatibility\Util\Tests\Coresubdirectory. - The bootstrap file used for PHPUnit has been moved to the project root directory and renamed
phpunit-bootstrap.php.
- 🔀 The
PHPCompatibility.LanguageConstructs.NewLanguageConstructssniff has been split into two sniffs. #738 ThePHPCompatibility.LanguageConstructs.NewLanguageConstructssniff now contains just the checks for the namespace separator and the ellipsis. The newPHPCompatibility.Operators.NewOperatorssniff now contains the checks regarding the pow, pow equals, spaceship and coalesce (equals) operators. - 📌 The
PHPCompatibility.ParameterValues.RemovedMbstringModifierssniff 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. #715 - 📌 The
PHPCompatibility\Sniff::getFunctionCallParameter()utility method now allows for closures called via a variable. #723 - ✏️
PHPCompatibility.Upgrade.LowPHPCS: the minimum supported PHPCS version is now 2.3.0. #699 - ✏️ Minor inline documentation improvements. #738
- ☔ Minor improvements to the unit tests for the
PHPCompatibility.FunctionNameRestrctions.RemovedMagicAutoloadsniff. #716 - ♻️ Minor other optimizations. #698, #697
- 🔧 Minor improvements to the build tools. #701
- 🔧 Removed some unnecessary inline annotations. #700
- 📚 Replaced some of the badges in the Readme file. #721, #722
- 📚 Composer: updated the list of package authors. #739
- 🚫 Support for PHP_CodeSniffer 1.x and low 2.x versions. The new minimum version of PHP_CodeSniffer to be able to use this library is 2.3.0. #699. Fixes #691. The minimum recommended version of PHP_CodeSniffer remains the same, i.e. 2.6.0.
- 🚫 The
\PHPCompatibility\Sniff::inUseScope()method has been removed as it is no longer needed now support for PHPCS 1.x has been dropped. #699 - 🚫 Composer: The
autoloadsection has been removed from thecomposer.jsonfile. #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.NewFunctionParameterssniff: The new$modeparameter of thephp_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. #711 - 🐛
PHPCompatibility.Generators.NewGeneratorReturnsniff: The sniff would throw false positives forreturnstatements in nested constructs and did not correctly detect the scope which should be examined. #725. Fixes #724. - 🐛
PHPCompatibility.Keywords.NewKeywordssniff: PHP magic constants are case _in_sensitive. This sniff now accounts for this. #707 - 🐛 Various bugs in the
PHPCompatibility.Syntax.ForbiddenCallTimePassByReferencesniff #723:- Closures called via a variable will now also be examined. (false negative)
- References within arrays/closures passed as function call parameters would incorrectly trigger an error. (false positive)
- 💚 Compatibility with PHPUnit 7.2. #712
Thanks go out to Jonathan Champ for his contribution to this version. 👏
8.2.0 - 2018-07-17
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|Packagist.
For more information, see the Readme and Contributing guidelines.
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.
- 🌟 New
ArgumentFunctionsUsagesniff to detect usage of thefunc_get_args(),func_get_arg()andfunc_num_args()functions and the changes regarding these functions introduced in PHP 5.3. #596. Fixes #372. - 🌟 New
DiscouragedSwitchContinuesniff to detectcontinuetargetting aswitchcontrol structure for whichE_WARNINGSwill be thrown as of PHP 7.3. #687 - 🌟 New
NewClassMemberAccesssniff 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. - 🌟 New
NewConstantScalarExpressionssniff to detect PHP 5.6 scalar expression in contexts where PHP previously only allowed static values. #617. Fixes #399. - 🌟 New
NewGeneratorReturnsniff to detectreturnstatements within generators as introduced in PHP 7.0. #618 - 🌟 New
PCRENewModifierssniff to initially detect the newJregex modifier as introduced in PHP 7.2. #600. Fixes #556. - 🌟 New
ReservedFunctionNamessniff to report on double underscore prefixed functions and methods. This was previously reported via an upstream sniff. #581 - 🌟 New
NewTrailingCommasniff to detect trailing comma's in function calls, method calls,isset()andunset()as will be introduced in PHP 7.3. #632 - 🌟 New
Upgrade/LowPHPCSsniff to give users of old PHP_CodeSniffer versions advance warning when support will be dropped in the near future. #693 - ⭐
NewClassessniff: check for some 40+ additional PHP native classes added in various PHP versions. #573 - ⭐
NewClosuresniff: check for usage ofself/parent/static::being used within closures, support for which was only added in PHP 5.4. #669. Fixes #668. - ⭐
NewConstantssniff: recognize constants added by the PHP 5.5+ password extension. #626 - ⭐
NewFunctionParameterssniff: recognize a number of additional function parameters added in PHP 7.0, 7.1 and 7.2. #602 - ⭐
NewFunctionssniff: recognize the PHP 5.1 SPL extension functions, the PHP 5.1.1hash_hmac()function, the PHP 5.6pg_lo_truncate()function, more PHP 7.2 Sodium functions and the new PHP 7.3is_countable()function. #606, #625, #640, #651 - ⭐
NewHashAlgorithmssniff: recognize the new hash algorithms which were added in PHP 7.1. #599 - ⭐
NewInterfacessniff: check for the PHP 5.0Reflectorinterface. #572 - ⭐
OptionalRequiredFunctionParameterssniff: detect missing$saltparameter in calls to thecrypt()function (PHP 5.6+). #605 - ⭐
RequiredOptionalFunctionParameterssniff: recognize that the$varnameparameter ofgetenv()and the$scaleparameter ofbcscale()have become optional as of PHP 7.1 and 7.3 respectively. #598, #612 - ⭐ New
AbstractFunctionCallParameterSniffto be used as a basis for sniffs examining function call parameters. #636 - ⭐ New
getReturnTypeHintName()utility method to thePHPCompatibility\Sniffclass. #578, #642 - ⭐ New
isNumber(),isPositiveNumber()andisNegativeNumber()utility methods to thePHPCompatibility\Sniffclass. #610, #650 - ⭐ New
isShortList()utility method to thePHPCompatibility\Sniffclass. #635 - ⭐ New
getCommandLineData()method to thePHPCompatibility\PHPCSHelperclass to provide PHPCS cross-version compatible access to command line info at run time. #693 - ⭐ Duplicate of upstream
findEndOfStatement()method to thePHPCompatibility\PHPCSHelperclass to allow for PHPCS cross-version usage of that method. #614 - ☔ additional unit test to confirm that the
PHPCompatibility\Sniff::isUseOfGlobalConstant()method handles multi-constant declarations correctly. #587 - ☔ additional unit tests to confirm that the
PHPCompatibility\Sniff::isClassProperty()method handles multi-property declarations correctly. #583 - 📚 Readme & Contributing: add information about the framework/CMS specific rulesets. Related PRs: #615, #624, #648, #674, #685, #694. Related to issue #530.
- 📚 Readme: information about the PHPCS 3.3.0 change which allows for a
testVersionin a custom ruleset to be overruled by the command-line. #607
- 📚 Adjusted references to the old repository location throughout the codebase to reflect the move to a GitHub organization. #689
This repository will now live in https://github.com/PHPCompatibility/PHPCompatibility and the Packagist reference will now be
phpcompatibility/php-compatibility. - ✅ The
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. #593 - 📌
NewHeredocInitialize: improved handling of constant declarations using theconstkeyword. The sniff will now also report on multi-declarations for variables, constants and class properties and on using heredoc as a function parameter default. #641 - 📌
ForbiddenEmptyListAssignment: this sniff will now also report on empty list assignments when the PHP 7.1 short list syntax is used. #653 - 📌 The
ForbiddenNegativeBitshiftsniff would previously only report on "bitshift right". As of this version, "bitshift left" and bitshift assignments will also be recognized. #614 - 📌 The
NewClassesandNewInterfacessniffs will now also report on new classes/interfaces when used as return type declarations. #578 - 📌 The
NewScalarTypeDeclarationssniff will now recognizeparentas a valid type declaration. The sniff will now also throw an error about usingselfandparentwhen PHP < 5.2 needs to be supported as PHP 5.1 and lower would presume these to be class names instead of keywords. #595 - 📌 The
PregReplaceEModifiersniff - and thePCRENewModifierssniff by extension - will now correctly examine and report on modifiers in regexes passed via calls topreg_replace_callback_array(). #600, #636 - 📌
getReturnTypeHintToken()utility method: improved support for interface methods and abstract function declarations. #652 - 📌 The
findExtendedClassName(),findImplementedInterfaceNames(),getMethodParameters()utility methods which are duplicates of upstream PHPCS methods, have been moved from thePHPCompatibility\Sniffclass to thePHPCompatibility\PHPCSHelperclass and have become static methods. #613 - ✅
getReturnTypeHintToken()utility method: align returned$stackPtrwith native PHPCS behaviour by returning the last token of the type declaration. #575 - ✅ PHPCS cross-version compatibility: sync
getMethodParameters()method with improved upstream version. #643 - ✏️ The
MbstringReplaceEModifier,PregReplaceEModifierand thePregReplaceEModifiersniffs nowextendthe newAbstractFunctionCallParameterSniffclass. This should yield more accurate results when checking whether one of the target PHP functions was called. #636 - ✏️
DeprecatedNewReferencesniff: minor change to the error text and code - wasForbidden, nowRemoved-. Custom rulesets which explicitly excluded this error code will need to be updated. #594 - ✏️
NewScalarTypeDeclarationssniff: minor change to the error message text.#644 - ☔ The unit test framework now allows for sniffs in categories other than
PHP. #634 - ☔ Boyscouting: fixed up some (non-relevant) parse errors in a unit test case file. #576
- 💚 Travis: build tests are now also being run against the lowest supported PHPCS 3.x version. Previously only the highest supported PHPCS 3.x version was tested against. #633
- 📚 Readme: Improved Composer install instructions. #690
- 📚 Minor documentation fixes. #672
- 🔧 Minor performance optimizations and code simplifications. #592, #630, #671
- 🔧 Composer: Various improvements, including improved information about the suggested packages, suggesting
roave/security-advisories, allowing for PHPUnit 7.x. #604, #616, #622, #646 - 🔧 Various Travis build script improvements, including tweaks for faster build time, validation of the
composer.jsonfile, validation of the framework specific rulesets. #570, #571, #579, #621, #631 - 🔧 Build/PHPCS: made some more CS conventions explicit and start using PHPCS 3.x options for the PHPCompatibility native ruleset. #586, #667, #673
- 🔧 Some code style clean up and start using the new inline PHPCS 3.2+ annotations where applicable. #586, #591, #620, #673
- 🚫 PHPCompatibility no longer explicitly supports PHP_CodeSniffer 2.2.0. #687, #690
- 🚫 The PHPCompatibility ruleset no longer includes the PHPCS native
Generic.NamingConventions.CamelCapsFunctionName. Double underscore prefixed function names are now being reported on by a new dedicated sniff. #581 - 🚫 PHPCompatibility no longer explicitly supports HHVM and builds are no longer tested against HHVM. For now, running PHPCompatibility on HHVM to test PHP code may still work for a little while, but HHVM has announced they are dropping PHP support. #623. Fixes #603.
- 📚 Readme: badges from services which are no longer supported or inaccurate. #609, #628
- 🐛 Previously, the PHPCS native
Generic.NamingConventions.CamelCapsFunctionNamesniff 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. #581 - 🐛 The
ForbiddenNegativeBitshiftsniff 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. - 🐛 The
NewClosuresniff would report the same issue twice when the issue was encountered in a nested closure. #669 - 🐛 The
NewKeywordssniff would underreport on non-lowercase keywords. #627 - 🐛 The
NewKeywordssniff would incorrectly report on the use of class constants and class properties using the same name as a keyword. #627 - 🐛 The
NewNullableTypessniff would potentially underreport when comments where interspersed in the (return) type declarations. #577 - 🐛 The
Sniff::getFunctionCallParameters()utility method would in rare cases return incorrect results when it encountered a closure as a parameter. #682 - 🐛 The
Sniff::getReturnTypeHintToken()utility method would not always return a$stackPtr. #645 - 🐛 Minor miscellanous other bugfixes. #670
- ☔
PHPCompatibility\Tests\BaseClass\MethodTestFrame::getTargetToken()could potentially not find the correct token to run a test against. #588
Thanks go out to Michael Babker and Juliette Reinders Folmer for their contributions to this version. 👏
8.1.0 - 2017-12-27
See all related issues and PRs in the 8.1.0 milestone.
- 🌟 New
NewConstantsandRemovedConstantssniffs to detect usage of new/removed PHP constants for all PHP versions from PHP 5 up. #526, #551, #566. Fixes #263. - 🌟 New
MagicAutoloadDeprecationsniff to detect deprecated__autoload()functions as deprecated in PHP 7.2. #540 - 🌟 New
OptionalRequiredFunctionParametersniff to check for missing function call parameters which were required and only became optional in a later PHP version. #524 - 🌟 New
DynamicAccessToStaticsniff to detect dynamic access to static methods and properties, as well as class constants, prior to PHP 5.3. #535. Fixes #534. - ⭐
DeprecatedFunctionssniff: recognize yet more PHP 7.2 deprecated functions. #561, #566 - ⭐
DeprecatedIniDirectivessniff: recognize the last of the PHP 7.2 deprecated ini directives. #566, #567 - ⭐
NewFunctions: detection of all new PHP 7.2 functions added. #522, #545, #551, #565 - ⭐
RemovedExtensions: report on usage of themcryptextension which has been removed in PHP 7.2. #566 - ⭐
RemovedGlobalVariables: detection of the use of$php_errormsgwithtrack_errorswhich has been deprecated in PHP 7.2. #528 - 📚 Documentation : added reporting usage instructions. #533, #552
- 📌
NewClosures: downgraded "$this found in closure outside class" to warning. #536. Fixes #527. - 📌
ForbiddenGlobalVariableVariable: the sniff will now throw an error for each variable in aglobalstatement which is no longer supported and show the variable found to make it easier to fix this. Previously only one error would be thrown perglobalstatement. #564 - 📌
ForbiddenGlobalVariableVariable: the sniff will now throwwarnings for non-bare variables used in aglobalstatement as those are discouraged since PHP 7.0. #564 - ⏪
NewLanguageConstructs: updated the version number forT_COALESCE_EQUAL. #523 - ✏️
Sniff::getTestVersion(): simplified regex logic. #520 - 💚 Travis : build tests are now being run against PHP 7.2 as well. #511
- 🔧 Improved check for superfluous whitespaces in files. #542
- 🔧 Build/PHPCS : stabilized the exclude patterns. #529
- 🔧 Build/PHPCS : added array indentation check. #538
- ✅ PHPCS cross-version compatibility : sync
FindExtendedClassname()method with upstream. #507 - 🔧 The minimum version for the recommended
DealerDirect/phpcodesniffer-composer-installerComposer plugin has been upped to0.4.3. #548
- 🐛
ForbiddenCallTimePassByReference: 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 onglobalin combination with variable variables which are still supported. #564. Fixes #537. - 🐛
ForbiddenGlobalVariableVariable: variables interspersed with whitespace and/or comments were not being reported. #564 - ⏪
ForbiddenNamesAsInvokedFunctions: improved recognition of function invocations using forbidden words and prevent warnings for keywords which are no longer forbidden as method names in PHP 7.0+. #516. Fixes #515 - 🐛
VariableVariables: variables interspersed with whitespace and/or comments were not being reported. #563 - ☔ Fixed some unintentional syntax errors in test files. #539
- ☔ Tests : fixed case numbering error. #525
- 📚 Tests : added missing test skip explanation. #521
- 🔧 Fixed PHPCS whitespaces. #543
- 🔧 Fixed code test coverage verification. #550. Fixes #549.
Thanks go out to Juliette Reinders Folmer and Jonathan Van Belle for their contributions to this version. 👏
8.0.1 - 2017-08-07
See all related issues and PRs in the 8.0.1 milestone.
- 🌟 New
DeprecatedTypeCastssniff to detect deprecated and removed type casts, such as the(unset)type cast as deprecated in PHP 7.2. #498 - 🌟 New
NewTypeCastssniff to detect type casts not present in older PHP versions such as the(binary)type cast as added in PHP 5.2.1. #497 - ⭐
NewGroupUseDeclaration: Detection of PHP 7.2 trailing comma's in group use statements. #504 - ⭐
DeprecatedFunctionssniff: recognize some more PHP 7.2 deprecated functions. #501 - ⭐
DeprecatedIniDirectivessniff: recognize more PHP 7.2 deprecated ini directives. #500 - ⭐
ForbiddenNamessniff: recognizeobjectas a forbidden keyword since PHP 7.2. #499 - ⭐
NewReturnTypeDeclarationssniff: recognize genericparent, PHP 7.1iterableand PHP 7.2objectreturn type declarations. #505, #499 - ⭐
NewScalarTypeDeclarationssniff: recognize PHP 7.2objecttype declarion. #499
- ✏️ Improved clarity of the deprecated functions alternative in the error message. #502
- 🚒 Temporary hotfix for installed_paths (pending upstream fix.) #503
Thanks go out to Juliette Reinders Folmer for her contributions to this version. 👏
8.0.0 - 2017-08-03
IMPORTANT: This release contains a breaking change. Please read the below information 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.
There are two things you will need to be aware of:
- The path to the PHPCompatibility standard has changed.
- If you intend to upgrade to PHPCS 3.x, the path to the
phpcsscript has changed (upstream change).
Please follow the below upgrade instructions carefully. This should be a one-time only action.
If you had previously made accommodations for the old directory layout, you should remove any such "hacks" (meant in the kindest of ways) now.
By this we mean: symlinks for the PHPCompatibility install to the PHP_CodeSniffer/CodeSniffer/Standards directory, scripts to move the sniffs files to the PHPCS directory, scripts which made symlinks etc.
So, please remove those first.
Side-note:
If you had previously forked this repository to solve this issue, please consider reverting your fork to the official version or removing it all together.
External PHP CodeSniffer standards need to be registered with PHP CodeSniffer. You have probably done this the first time you used PHPCompatibility or have a script or Composer plugin in place to do this for you.
As the directory layout of PHPCompatibility has changed, the path previously registered with PHP CodeSniffer will no longer work and running phpcs -i will not list PHPCompatibility as one of the registered standards.
If you use Composer, we recommend you use a Composer plugin to sort this out. In previous install instructions we recommended the SimplyAdmin plugin for this. This plugin has since been abandoned. We now recommend the DealerDirect plugin.
composer remove --dev simplyadmire/composer-plugins
composer require --dev dealerdirect/phpcodesniffer-composer-installer:^0.4.3
composer install
composer update phpcompatibility/php-compatibility squizlabs/php_codesniffer
vendor/bin/phpcs -iIf all went well, you should now see PHPCompatibility listed again in the list of installed standards.
-
First run
phpcs --config-showto check which path(s) are currently registered with PHP CodeSniffer for external standards. -
Check in the below table what the new path for PHPCompatibility will be - the path should point to the root directory of your PHPCompatibility install (not to the sub-directory of the same name):
Install type Old path New path Composer vendor/wimgvendor/phpcompatibility/php-compatibilityUnzipped release to arbitrary directory path/to/dir/abovePHPCompatibilitypath/to/dir/abovePHPCompatibility/PHPCompatibilityGit checkout path/to/dir/abovePHPCompatibilitypath/to/dir/abovePHPCompatibility/PHPCompatibilityPEAR If the old install instruction has been followed, not registered. path/to/PHPCompatibilitySide-note:
If you used the old install instructions for a PEAR install, i.e. checking out the latest release to the
PHP/CodeSniffer/Standards/PHPCompatibilitydirectory, and you intend to upgrade to PHP CodeSniffer 3.x, it is recommended you move the PHPCompatibility folder out of the PEAR directory now, as the layout of the PHPCS directory has changed with PHPCS 3.x and you may otherwise lose your PHPCompatibility install when you upgrade PHP CodeSniffer via PEAR. -
There are two ways in which you can register the new
installed_pathsvalue with PHP CodeSniffer. Choose your preferred method:-
Run
phpcs --config-set installed_paths ...and include all previously installed paths including the adjusted path for the PHPCompatibility standard.For example, if the previous value of
installed_pathswas/path/to/MyStandard,/path/to/dir/abovePHPCompatibilityyou should now set it using
phpcs --config-set installed_paths /path/to/MyStandard,/path/to/PHPCompatibility -
If you use a custom ruleset in combination with PHPCS 2.6.0 or higher, you can pass the value to PHPCS from your custom ruleset:
<config name="installed_paths" value="vendor/phpcompatibility/php-compatibility" />
-
-
Run
phpcs -ito verify that the PHPCompatibility standard is now listed again in the list of installed standards.
The path to the phpcs script has changed in PHPCS 3.x which will impact how you call PHPCS.
| Version | PHPCS 2.x | PHPCS 3.x |
|---|---|---|
Generic phpcs Command |
path/to/PHP_CodeSniffer/scripts/phpcs .... |
path/to/PHP_CodeSniffer/bin/phpcs .... |
| Composer command | vendor/bin/phpcs ... |
vendor/bin/phpcs ... |
So, for Composer users, nothing changes. For everyone else, you may want to add the path/to/PHP_CodeSniffer/bin/phpcs path to your PATH environment variable or adjust any scripts - like build scripts - which call PHPCS.
If you run PHPCompatibility against your code as part of your Travis build:
- If you use Composer to install PHP CodeSniffer and PHPCompatibility on the travis image and you've made the above mentioned changes, your build should pass again.
- If you use
git cloneto install PHP CodeSniffer and PHPCompatibility on the travis image, your build will fail until you make the following changes:- Check which branch of PHPCS is being checked out. If you previously fixed this to a pre-PHPCS 3.x branch or tag, you can now change this (back) to
masteror a PHPCS 3 tag. - Check to which path PHPCompatibility is being cloned and adjust the path if necessary.
- Adjust the
phpcs --config-set installed_pathscommand as described above to point to the root of the cloned PHPCompatibility repo. - If you switched to using PHPCS 3.x, adjust the call to PHPCS.
- Check which branch of PHPCS is being checked out. If you previously fixed this to a pre-PHPCS 3.x branch or tag, you can now change this (back) to
See all related issues and PRs in the 8.0.0 milestone.
- 🎁 As of this version PHPCompatibility will use semantic versioning.
- 🔥 The directory structure of the repository has changed for better compatibility with installation via Composer. #446. Fixes #102, #107
- ✏️ The custom
functionWhitelistproperty for thePHPCompatibility.PHP.RemovedExtensionssniff 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). #482 - 🔧 Improved the information provided to Composer from the
composer.jsonfile. #446, #482, #486 - 🔧 Release archives will no longer contain the unit tests and other typical development files. You can still get these by using Composer with
--prefer-sourceor by checking out a git clone of the repository. #494 - 🔧 A variety of minor improvements to the build process. #485, #486, #487
- 🔧 Some files for use by contributors have been renamed to use
.distextensions or moved for easier access. #478, #479, #483, #493 - 📚 The installation instructions in the Readme. #496
- 📚 The unit test instructions in the Contributing file. #496
- 📚 Improved the example code in the Readme. #490
-
🚫 Support for PHP 5.1 and 5.2.
The sniffs can now only be run on PHP 5.3 or higher in combination with PHPCS 1.5.6 or 2.x and on PHP 5.4 or higher in combination with PHPCS 3.x. #484, #482
Thanks go out to Gary Jones and Juliette Reinders Folmer for their contributions to this version. 👏
7.1.5 - 2017-07-17
See all related issues and PRs in the 7.1.5 milestone.
- ⭐ The
NewKeywordssniff will now also sniff foryield fromwhich was introduced in PHP 7.0. #477. Fixes #476 - 📚 The LGPL-3.0 license. #447
- ⏪ The
NewExecutionDirectivessniff will now also report on execution directives when used in combination with PHPCS 2.0.0-2.3.3. #451 - ⏪ The
getMethodParameters()utility method will no longer break when used with PHPCS 1.5.x < 1.5.6. This affected a number of sniffs. #452 - ⏪ The
inUseScope()utility method will no longer break when used with PHPCS 2.0.0 - 2.2.0. This affected a number of sniffs. #454 - ♻️ Various (minor) refactoring for improved performance and sniff accuracy. #443, #474
- ✏️ Renamed a test file for consistency. #453
- 🔧 Code style clean up. #429
- 🔧 Prevent Composer installing PHPCS 3.x. PHPCS 3.x is not (yet) supported by the PHPCompatibility standard, but will be in the near future. #444
- 💚 The code base will now be checked for consistent code style during build testing. #429
- 💚 The sniffs are now also tested against HHVM for consistent results. Note: the sniffs do not contain any HHVM specific checks nor is there any intention to add them at this time. #450
- 📚 Made it explicit that - at this moment - PHPCS 3.x is not (yet) supported. #444
- 📚 Minor improvements to the Readme. #448, #449, #468
- 📚 Minor improvements to the Contributing guidelines. #467
- 🚫 The
DefaultTimeZoneRequiredsniff. This sniff was checking server settings rather than code. #458. Fixes #457 - 🚫 The
NewMagicClassConstantsniff 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 #436
- 🐛
NewClasssniff: was reporting an incorrect introduction version number for a few of the Exception classes. #441. Fixes #440. - 🐛
ForbiddenBreakContinueVariableArgumentssniff: was incorrectly reporting an error if thebreakorcontinuewas followed by a PHP closing tag (breaking out of PHP). #462. Fixes #460 - 🐛
ForbiddenGlobalVariableVariablesniff: was incorrectly reporting an error if theglobalstatement was followed by a PHP closing tag (breaking out of PHP). #463. - 🐛
DeprecatedFunctionssniff: was reporting false positives for classes using the same name as a deprecated function. #465. Fixes #464
Thanks go out to Juliette Reinders Folmer and Mark Clements for their contributions to this version. 👏
7.1.4 - 2017-05-06
See all related issues and PRs in the 7.1.4 milestone.
- 🌟 New
CaseSensitiveKeywordssniff to detect use of non-lowercaseself,staticandparentkeywords which could cause compatibility issues pre-PHP 5.5. #382 - 🌟 New
ConstantArraysUsingConstsniff to detect constants defined using theconstkeyword being assigned an array value which was not supported prior to PHP 5.6. #397 - 🌟 New
ForbiddenClosureUseVariableNamessniff to detect PHP 7.1 forbidden variable names in closure use statements. #386. Fixes #374 - 🌟 New
NewArrayStringDereferencingsniff to detect array and string literal dereferencing as introduced in PHP 5.5. #388 - 🌟 New
NewHeredocInitializesniff to detect initialization of static variables and class properties/constants using the heredoc syntax which is supported since PHP 5.3. #391. Fixes #51 - 🌟 New
NewMagicClassConstantsniff to detect use of the magic::classconstant as introduced in PHP 5.5. #403. Fixes #364. - 🌟 New
NewUseConstFunctionsniff to detect use statements importing constants and functions as introduced in PHP 5.6. #401 - ⭐
DeprecatedFunctionssniff: recognize PHP 7.2 deprecated GD functions. #392 - ⭐
DeprecatedIniDirectivessniff: recognize PHP 7.2 deprecatedmbstring.func_overloaddirective. #377 - ⭐
NewClassessniff: check for the PHP 5.1libXMLErrorclass. #412 - ⭐
NewClassessniff: recognize all native PHP Exception classes. #418 - ⭐
NewClosuresniff: check for closures being declared as static and closures using$this. Both of which was not supported pre-PHP 5.4. #389. Fixes #24. - ⭐
NewFunctionParameterssniff: recognize newexclude_disabledparameter for theget_defined_functions()function as introduced in PHP 7.0.15. #375 - ⭐
NewFunctionssniff: recognize new PHP 7.2 socket related functions. #376 - ⭐
NewInterfacessniff: check for some more PHP native interfaces. #411 - ⭐ New
isClassProperty(),isClassConstant()andvalidDirectScope()utility methods to thePHPCompatibility_Sniffclass. #393, #391. - ⭐ New
getTypeHintsFromFunctionDeclaration()utility method to thePHPCompatibility_Sniffclass. #414. - ☔ Unit tests against false positives for the
NewMagicMethodssniff. #381 - ☔ More unit tests for the
getTestVersion()utility method. #405, #430 - 💚 The XML of the ruleset will now be validated and checked for consistent code style during the build testing by Travis. #433
- 📚 Readme: information about setting
installed_pathsvia a custom ruleset. #407 - 📚
Changelog.mdfile containing a record of notable changes since the first tagged release. #421
- 📌 The
ForbiddenNamesAsDeclaredsniff will now emitwarnings for soft reserved keywords. #406, #370. - 📌 The
ForbiddenNamessniff will now allow for the more liberal rules for usage of reserved keywords as of PHP 7.0. #417 - 📌 The
InternalInterfaces,NewClasses,NewConstVisibility,NewInterfaces,NewMagicMethods,NonStaticMagicMethodsandRemovedGlobalVariablessniffs will now also sniff for and correctly report violations in combination with anonymous classes. #378, #383, #393, #394, #395, #396. Fixes #351 and #333. - 📌 The
NewClassesandNewInterfacessniffs will now also report on new classes/interfaces when used as type hints. #414, #416. Fixes #352 - 📌 The
NewClassessniff will now also report on Exception classes when used in (multi-)catchstatements. #418. Fixes #373. - 📌 The
NewScalarTypeDeclarationssniff will now report on new type hints even when the type hint is nullable. #379 - 🔀 The
NewNowdocsniff has been renamed toNewNowdocQuotedHeredocand will now also check for double quoted heredoc identifiers as introduced in PHP 5.3. #390 - ⏪ The
NewClassessniff will now also report anonymous classes whichextenda new sniff when used in combination with PHPCS 2.4.0-2.8.0. #432. Fixes #334. - ✏️
NewFunctionParametersniff: version number precision for two parameters. #384, #428 - ☔ Skipping two unit tests for the
ForbiddenClosureUseVariablesniff when run on PHPCS 2.5.1 as these cause an infinite loop due to an upstream bug. #408 - ☔ Skipping unit tests involving
traits in combination with PHP < 5.4 and PHPCS < 2.4.0 astraits are not recognized in those circumstances. #431 - ♻️ Various (minor) refactoring for improved performance and sniff accuracy. #385, #387, #415, #423, #424
- ♻️ Minor simplification of the PHPUnit 6 compatibility layer and other test code. #426, #425
- General housekeeping. #398, #400
- 🔧 Minor tweaks to the Travis build script. #409
- 💚 The sniffs are now also tested against PHP nightly for consistent results. #380
- 🔥 Using unbounded ranges in
testVersionresulted in unreported errors when used with sniffs using thesupportsBelow()method. This affected the results of approximately half the sniffs. #430 - 🐛 The
ForbiddenNamessniff would throw false positives forusestatements with thefinalmodifier in traits. #402. - 🐛 The
ForbiddenNamessniff would fail to report on functions declared to return by reference using a reserved keyword as the function name. #413 - 🐛 The
ForbiddenNamessniff would only examine the first part of a namespace and not report on reserved keywords used in subsequent parts of a nested namespace. #419 - 🐛 The
ForbiddenNamessniff would not always correctly report on use statements importing constants or functions using reserved keywords. #420 - 🐛 The
NewKeywordssniff would sometimes fail to report on theconstkeyword when used in a class, but not for a class constant. #424 - 💚 PHPCS has released version 3.0 and updated the
masterbranch to reflect this. This was causing the builds to fail. #422
Thanks go out to Juliette Reinders Folmer and Mark Clements for their contributions to this version. 👏
7.1.3 - 2017-04-02
See all related issues and PRs in the 7.1.3 milestone.
- ⚡ The
testVersionconfig parameter now allows for specifying unbounded ranges. For example: specifying-5.6means: check for compatibility with all PHP versions up to and including PHP 5.6; Specifying7.0-means: check for compatibility with all PHP versions from PHP 7.0 upwards. For more information about setting thetestVersion, see Using the compatibility sniffs in the readme. - ☔ Unit test for multi-line short arrays for the
ShortArraysniff. #347 - ☔ Various additional unit tests against false positives. #345, #369
- ☔ Unit tests for the
supportsBelow(),supportsAbove()andgetTestVersion()utility methods. #363 - 📚 Readme: information about installation of the standard using git check-out. #349
- 📚
Contributing.mdfile with information about reporting bugs, requesting features, making pull requests and running the unit tests. #350
- 📌 The
ForbiddenFunctionParametersWithSameName,NewScalarTypeDeclarations,ParameterShadowSuperGlobalssniff will now also sniff for and report violations in closures. #331 - 🔀 ⏪ The check for the PHP 5.3
nowdocstructure has been moved from theNewKeywordssniff to a new stand-aloneNewNowdocsniff which will now also recognize this structure when the sniffs are run on PHP 5.2. #335 - ⏪ The
ForbiddenNamessniff will now also correctly recognize reserved keywords used in a declared namespace when run on PHP 5.2. #362 - ♻️ Various (minor) refactoring for improved performance and sniff accuracy. #360
- ♻️ The unit tests would previously run each test case file against all PHPCompatibility sniffs. Now, they will only be tested against the sniff which the test case file is intended to test. This allows for more test cases to be tested, more precise testing in combination with
testVersionsettings and makes the unit tests run ~6 x faster. Relevant additional unit tests have been added and others adjusted. #369 - ♻️ Refactoring/tidying up of some unit test code. #343, #345, #356, #355, #359
- General housekeeping. #346
- 📚 Readme: Clarify minimum requirements and influence on the results. #348
- 🔀 Removed the
LongArrayssniff. The checks it contained have been moved into theRemovedGlobalVariablessniff. Both sniffs essentially did the same thing, just for different PHP native superglobals. #354
- 🐛 The
PregReplaceEModifiersniff would throw a false positive if a quote character was used as the regex delimiter. #357 - 🐛
RemovedGlobalVariablessniff would report false positives for class properties shadowing the removed$HTTP_RAW_POST_DATAvariables. #354. - 🐛 The
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, #342 - 🐛 The
determineNamespace()utility method would in certain cases not break out a loop. #358 - 🔧 Travis script: Minor tweak for PHP 5.2 compatibility. #341
- 🔧 The unit test suite is now also compatible with PHPUnit 6. #365
- 📚 Readme: Typo in the composer instructions. #344
Thanks go out to Arthur Edamov, Juliette Reinders Folmer, Mark Clements and Tadas Juozapaitis for their contributions to this version. 👏
7.1.2 - 2017-02-17
See all related issues and PRs in the 7.1.2 milestone.
- 🌟 New
VariableVariablessniff to detect variables variables for which the behaviour has changed in PHP 7.0. #310 Fixes #309. - ⭐ The
NewReturnTypeDeclarationssniff will now also sniff for non-scalar return type declarations, i.e.array,callable,selfor a class name. #323 - ⭐ The
NewLanguageConstructssniff 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. #340 - ⭐ New
getReturnTypeHintToken()utility method to thePHPCompatibility_Sniffclass to retrieve return type hints from function declarations in a cross-PHPCS-version compatible way. #323. - ⭐ New
stripVariables()utility method to thePHPCompatibility_Sniffclass to strip variables from interpolated text strings. #341. - ☔ Additional unit tests covering previously uncovered code. #308
- 📌 The
MbstringReplaceEModifier,PregReplaceEModifierandNewExecutionDirectivessniffs will now also correctly interpret double quoted text strings with interpolated variables. #341, #324. - 📌 The
NewNullableTypessniff will now also report on nullable (return) type hints when used with closures. #323 - 📌 The
NewReturnTypeDeclarationssniff will now also report on return type hints when used with closures. #323 - 📌 Allow for anonymous classes in the
inClassScope()utility method. #315 - 📌 The function call parameter related utility functions can now also be used to get the individual items from an array declaration. #300
- 🔀 The
NewScalarReturnTypeDeclarationssniff has been renamed toNewReturnTypeDeclarations. #323 - ⏪ The
ForbiddenNamessniff will now also correctly ignore anonymous classes when used in combination with PHPCS < 2.3.4. #319 - ⏪ The
NewAnonymousClassessniff will now correctly recognize and report on anonymous classes when used in combination with PHPCS < 2.5.2. #325 - ⏪ The
NewGroupUseDeclarationssniff will now correctly recognize and report on group use statements when used in combination with PHPCS < 2.6.0. #320 - ⏪ The
NewNullableTypessniff will now correctly recognize and report on nullable return types when used in combination with PHPCS < 2.6.0. #323 - ⏪ The
NewReturnTypeDeclarationssniff will now correctly recognize and report on new return types when used in combination with PHPCS < 2.6.0. #323 - ♻️ Various (minor) refactoring for improved performance and sniff accuracy. #317
- ♻️ Defer to upstream
hasCondition()utility method where appropriate. #315 - ♻️ Minor refactoring of some unit test code. #304, #303, #318
- 🔧 All unit tests now have appropriate
@groupannotations allowing for quicker/easier testing of a select group of tests/sniffs. #305 - 🔧 All unit tests now have appropriate
@coversannotations to improve code coverage reporting and remove bleed through of accidental coverage. #307 - 🔧 Minor tweaks to the travis script. #322
- 💚 The PHPCompatibility code base itself will now be checked for cross-version compatibility during build testing. #322
- 🐛 The
ConstantArraysUsingDefinesniff would throw false positives if the value of thedefine()was retrieved via a function call and an array parameter was passed. #327 - 🐛 The
ForbiddenCallTimePassByReferencesniff would throw false positives on assign by reference within function calls or conditions. #302 Fixes the last two cases reported in #68 - 🐛 The
ForbiddenGlobalVariableVariableSniffsniff would only examine the first variable in aglobal ...statement causing unreported issues if subsequent variables were variable variables. #316 - 🐛 The
NewKeywordssniff would throw a false positive for theconstkeyword when encountered in an interface. #312 - 🐛 The
NewNullableTypessniff would not report on nullable return types for namespaced classnames used as a type hint. #323 - 🐛 The
PregReplaceEModifiersniff 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 theemodifier when an array of regexes was passed. #300 - 🐛 The
PregReplaceEModifiersniff 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. #300 - ✅ Compatibility with PHPCS 2.7.x. Deal with changed behaviour of the upstream PHP tokenizer and utility function(s). #313, #323, #326, #340
Thanks go out to Juliette Reinders Folmer for her contributions to this version. 👏
7.1.1 - 2016-12-14
See all related issues and PRs in the 7.1.1 milestone.
- ⭐
ForbiddenNamesAsDeclaredsniff: detection of the PHP 7.1iterableandvoidreserved keywords when used to name classes, interfaces or traits. #298
- 🐛 The
ForbiddenNamesAsInvokedFunctionssniff would incorrectly throw an error if theclonekeyword was used with parenthesis. #299. Fixes #284
Thanks go out to Juliette Reinders Folmer for her contributions to this version. 👏
7.1.0 - 2016-12-14
See all related issues and PRs in the 7.1.0 milestone.
- ⭐ New
stringToErrorCode(),arrayKeysToLowercase()andaddMessage()utility methods to thePHPCompatibility_Sniffclass. #291.
- 📌 All sniff error messages now have modular error codes allowing for selectively disabling individual checks - and even selectively disabling individual sniff for specific files - without disabling the complete sniff. #291
- ✏️ Minor changes to some of the error message texts for consistency across sniffs. #291
- ♻️ Refactored the complex version sniffs to reduce code duplication. #291
- ♻️ Miscellaneous other refactoring for improved performance and sniff accuracy. #291
- ☔ The unit tests for the
RemovedExtensionssniff now verify that the correct alternative extension is being suggested. #291
Thanks go out to Juliette Reinders Folmer for her contributions to this version. 👏
7.0.8 - 2016-10-31 - 👻 Spooky! 🎃
See all related issues and PRs in the 7.0.8 milestone.
- 🌟 New
ForbiddenNamesAsDeclaredsniff: 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 theForbiddenNamesandForbiddenNamesAsInvokedFunctionssniffs causing false positives as the rules for their reservation are different from the rules for "normal" reserved keywords. - ⭐ New
inUseScope()utility method to thePHPCompatibility_Sniffclass which handles PHPCS cross-version compatibility when determining the scope of ausestatement. #271. - ☔ More unit tests for the
ForbiddenNamessniff. #271.
- 📌 Deprecated functionality should throw a
warning. Removed or otherwise unavailable functionality should throw anerror. This distinction was previously not consistently applied everywhere. #286 This change affects the following sniffs:DeprecatedPHP4StyleConstructorswill now throw awarninginstead of anerrorfor deprecated PHP4 style class constructors.ForbiddenCallTimePassByReferencewill now throw awarningif thetestVersionis5.3and anerrorif thetestVersionif5.4or higher.MbstringReplaceEModifierwill now throw awarninginstead of anerrorfor usage of the deprecatedemodifier.PregReplaceEModifierwill now throw awarningif thetestVersionis5.5or5.6and anerrorif thetestVersionif7.0or higher. Fixes #290.TernaryOperatorswill now throw anerrorwhen thetestVersion<5.3and the middle part has been omitted.ValidIntegerswill now throw awarningwhen an invalid binary integer is detected.
- ✏️
DeprecatedFunctionsandDeprecatedIniDirectivessniffs: 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.
- 🐛
ForbiddenNamessniff would throw false positives forusestatements which changed the visibility of methods in traits. #271. - 🐛
ForbiddenNamessniff would not report reserved keywords when used in combination withuse functionoruse const. #271. - 🐛
ForbiddenNamessniff would potentially - unintentionally - skip over tokens, thereby - potentially - not reporting all errors. #271. - 🔧 Composer config:
prefer-stableshould be a root element of the json file. Fixes #277.
Thanks go out to Juliette Reinders Folmer for her contributions to this version. 👏
7.0.7 - 2016-10-20
See all related issues and PRs in the 7.0.7 milestone.
- 🌟 New
ForbiddenBreakContinueOutsideLoopsniff: verify thatbreak/continueis not used outside of a loop structure. This will cause fatal errors since PHP 7.0. #278. Fixes #275 - 🌟 New
NewConstVisibilitysniff: detect visibility indicators forclassandinterfaceconstants as introduced in PHP 7.1. #280. Fixes #249 - 🌟 New
NewHashAlgorithmssniff to check used hash algorithms against the PHP version in which they were introduced. #242 - 🌟 New
NewMultiCatchsniff: detect catch statements catching multiple Exceptions as introduced in PHP 7.1. #281. Fixes #251 - 🌟 New
NewNullableTypessniff: detect nullable parameter and return type hints (only supported in PHPCS >= 2.3.4) as introduced in PHP 7.1. #282. Fixes #247 - ⭐
DeprecatedIniDirectivessniff: recognize PHP 7.1 removedsessionini directives. #256 - ⭐
NewFunctionssniff: recognize newsocket_export_stream()function as introduced in PHP 7.0.7. #264 - ⭐
NewFunctionssniff: recognize newcurl_...(),is_iterable(),pcntl_async_signals(),session_create_id(),session_gc()functions as introduced in PHP 7.1. #273 - ⭐
NewFunctionParameterssniff: recognize new OpenSSL function parameters as introduced in PHP 7.1. #258 - ⭐
NewIniDirectivessniff: recognize newsessionini directives as introduced in PHP 7.1. #259 - ⭐
NewScalarReturnTypeDeclarationssniff: recognize PHP 7.1voidreturn type hint. #250 - ⭐
NewScalarTypeDeclarationssniff: recognize PHP 7.1iterabletype hint. #255 - ⭐ Recognize the PHP 7.1 deprecated
mcryptfunctionality in theRemovedExtensions,DeprecatedFunctionsandDeprecatedIniDirectivessniffs. #257
- 📌
LongArrayssniff used to only throwwarnings. It will now throwerrors for PHP versions in which the long superglobals have been removed. #270 - 📌 The
NewIniDirectivessniff used to always throw anwarning. Now it will throw anerrorwhen a new ini directive is used in combination withini_set(). #246. - 📌
RemovedHashAlgorithmssniff: also recognize removed algorithms when used with the PHP 5.5+hash_pbkdf2()function. #240 - 📌 Properly recognize nullable type hints in the
getMethodParameters()utility method. #282 - ✏️
DeprecatedPHP4StyleConstructorssniff: minor error message text fix. #236 - ✏️
NewIniDirectivessniff: improved precision for the introduction version numbers being reported. #246 - ♻️ Various (minor) refactoring for improved performance and sniff accuracy. #238, #244, #240, #276
- ☔ Re-activate the unit tests for the
NewScalarReturnTypeDeclarationssniff. #250
- 🐛 The
DeprecatedPHP4StyleConstructorssniff would not report errors when the case of the class name and the PHP4 constructor function name did not match. #236 - 🐛
LongArrayssniff would report false positives for class properties shadowing removed PHP superglobals. #270. Fixes #268. - 🐛 The
NewClassessniff would not report errors when the case of the class name used and "official" class name did not match. #237 - 🐛 The
NewIniDirectivessniff would report violations against the PHP version in which the ini directive was introduced. This should be the version below it. #246 - 🐛
PregReplaceEModifiersniff would report false positives for compound regex parameters with different quote types. #266. Fixes #265. - 🐛
RemovedGlobalVariablessniff would report false positives for lowercase/mixed cased variables shadowing superglobals. #245. - 🐛 The
RemovedHashAlgorithmssniff would not report errors when the case of the hash function name used and "official" class name did not match. #240 - 🐛 The
ShortArraysniff would report all violations on the line of the PHP open tag, not on the lines of the short array open/close tags. #238
Thanks go out to Juliette Reinders Folmer for her contributions to this version. 👏
7.0.6 - 2016-09-23
See all related issues and PRs in the 7.0.6 milestone.
- ⭐ New
stripQuotes()utility method in thePHPCompatibility_Sniffbase class to strip quotes which surround text strings in a consistent manner. #224 - 📚 Readme: Add PHP Version Support section. #225
- 📌 The
ForbiddenCallTimePassByReferencesniff will now also report the deprecation as of PHP 5.3, not just its removal as of PHP 5.4. #203 - 📌 The
NewFunctionArrayDereferencingsniff will now also check method calls for array dereferencing, not just function calls. #229. Fixes #227. - ✏️ The
NewExecutionDirectivessniff will now throwwarnings instead oferrors for invalid values encountered in execution directives. #223 - ✏️ Minor miscellaneous fixes. #231
- ♻️ Various (minor) refactoring for improved performance and sniff accuracy. #219, #203
- ♻️ Defer to upstream
findImplementedInterfaceNames()utility method when it exists. #222 - 🔧 Exclude the test files from analysis by Scrutinizer CI. #230
- 🚫 Some redundant code. #232
- 🐛 The
EmptyNonVariablesniff would throw false positives for variable variables and for array access with a (partially) variable array index. #212. Fixes #210. - 🐛 The
NewFunctionArrayDereferencingsniff 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. - 🐛
ParameterShadowSuperGlobalssniff would report false positives for lowercase/mixed cased variables shadowing superglobals. #218. Fixes #214. - 🐛 The
determineNamespace()utility method now accounts properly for namespaces within scopeddeclare()statements. #221 - 📚 Readme: Logo alignment in the Credits section. #233
Thanks go out to Jason Stallings, Juliette Reinders Folmer and Mark Clements for their contributions to this version. 👏
7.0.5 - 2016-09-08
See all related issues and PRs in the 7.0.5 milestone.
- 🌟 New
MbstringReplaceEModifiersniff to detect the use of the PHP 7.1 deprecatedemodifier in Mbstring regex functions. #202 - ⭐ The
ForbiddenBreakContinueVariableArgumentssniff will now also report onbreak 0/continue 0which is not allowed since PHP 5.4. #209 - ⭐ New
getFunctionCallParameters(),getFunctionCallParameter()utility methods in thePHPCompatibility_Sniffbase class. #170 - ⭐ New
tokenHasScope()utility method in thePHPCompatibility_Sniffbase class. #189 - ☔ Unit test for
gotoandcallabledetection and some other miscellanous extra unit tests for theNewKeywordssniff. #189 - 📚 Readme: Information for sniff developers about running unit tests for other sniff libraries using the PHPCS native test framework without running into conflicts with the PHPCompatibility specific unit test framework. #217
- 📌 The
ForbiddenNamessniff will now also check interface declarations for usage of reserved keywords. #200 - 📌
PregReplaceEModifiersniff: improved handling of regexes build up of a combination of variables, function calls and/or text strings. #201 - ⏪ The
NewKeywordssniff will now also correctly recognize new keywords when used in combination with older PHPCS versions and/or run on older PHP versions. #189 - ✏️
PregReplaceEModifiersniff: minor improvement to the error message text. #201 - ♻️ Various (minor) refactoring for improved performance and sniff accuracy. #170, #188, #189, #199, #200, #201, #208
- 🔧 The unit tests for the utility methods have been moved to their own subdirectory within
Tests. #215 - 💚 The sniffs are now also tested against PHP 7.1 for consistent results. #216
- 🐛
ConstantArraysUsingDefinesniff: the version check logic was reversed causing the error not to be reported in certain circumstances. #199 - 🐛 The
DeprecatedIniDirectivesandNewIniDirectivessniffs could potentially trigger on the ini value instead of the ini directive name. #170 - 🐛
ForbiddenNamessniff: Reserved keywords when used as the name of a constant declared usingdefine()would always be reported independently of thetestVersionset. #200 - 🐛
PregReplaceEModifiersniff would not report errors when the function name used was not in lowercase. #201 - 🐛
TernaryOperatorssniff: the version check logic was reversed causing the error not to be reported in certain circumstances. #188 - 🐛 The
getFQClassNameFromNewToken()andgetFQClassNameFromDoubleColonToken()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. - 🐛 The
getFunctionCallParameters()utility method would incorrectly identify an extra parameter if the last parameter passed to a function would have an - unnecessary - comma after it. ThegetFunctionCallParameters()utility method also did not handle parameters passed as short arrays correctly. #213. Fixes #211. - ☔ Unit tests for the
NewFunctionArrayDereferencingsniff were not being run due to a naming error. #208 - 📚 Readme: Information about setting the
testVersionfrom a custom ruleset was incorrect. #204 - 🔧 Path to PHPCS in the unit tests breaking for non-Composer installs. #198
Thanks go out to Juliette Reinders Folmer and Yoshiaki Yoshida for their contributions to this version. 👏
7.0.4 - 2016-08-20
See all related issues and PRs in the 7.0.4 milestone.
- 🌟 New
EmptyNonVariablesniff: detection of empty being used on non-variables for PHP < 5.5. #187 - 🌟 New
NewMagicMethodssniff: 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. - 🌟 New
RemovedAlternativePHPTagssniff: detection of ASP and script open tags for which support was removed in PHP 7.0. #184, #193. Fixes #127. - ⭐
NonStaticMagicMethodssniff: detection of the__callStatic(),__sleep(),__toString()and__set_state()magic methods. - 💚 Lint all non-test case files for syntax errors during the build testing by Travis. #192
- 📌
NonStaticMagicMethodssniff: will now also snifftraits for magic methods. #174 - 📌
NonStaticMagicMethodssniff: will now also check for magic methods which should be declared asstatic. #174 - ♻️ Various (minor) refactoring for improved performance and sniff accuracy. #178, #179, #174, #171
- ♻️ The unit test suite now internally caches PHPCS run results in combination with a set
testVersionto speed up the running of the unit tests. These are now ~3 x faster. #148 - 📚 Readme: Minor clarification of the minimum requirements.
- 📚 Readme: Advise to use the latest stable version of this repository.
- 🔧 The unit tests can now be run with PHPCS installed in an arbitrary location by passing the location through an environment option. #191.
- 🔧 Improved coveralls configuration and compatibility. #194
- 💚 The sniffs are now also tested against PHP 5.2 for consistent results. Except for namespace, trait and group use related errors, most sniffs work as intended on PHP 5.2. #196
- 🐛 The
ForbiddenBreakContinueVariableArgumentssniff would not report onbreak/continuewith a closure as an argument. #171 - 🐛 The
ForbiddenNamesAsInvokedFunctionssniff would not report on reserved keywords which were not lowercase. #186 - 🐛 The
ForbiddenNamesAsInvokedFunctionssniff would not report on thegotoandnamespacekeywords when run on PHP 5.2. #193 - 🐛
NewAnonymousClassessniff: the version check logic was reversed causing the error not to be reported in certain circumstances. #195. - 🐛
NewGroupUseDeclarationssniff: the version check logic was reversed causing the error not to be reported in certain circumstances. #190. - 🐛 The
NonStaticMagicMethodssniff would not report on magic methods when the function name as declared was not in the same case as used in the PHP manual. #174 - 🔧 The unit tests would exit with
0if PHPCS could not be found. #191 - 💚 The PHPCompatibility library itself was not fully compatible with PHP 5.2. #193
Thanks go out to Juliette Reinders Folmer for her contributions to this version. 👏
7.0.3 - 2016-08-18
See all related issues and PRs in the 7.0.3 milestone.
- 🌟 New
InternalInterfacessniff: detection of internal PHP interfaces being which should not be implemented by user land classes. #144 - 🌟 New
LateStaticBindingsniff: detection of PHP 5.3 late static binding. #177 - 🌟 New
NewExecutionDirectivessniff: verify execution directives set withdeclare(). #169 - 🌟 New
NewInterfacessniff: detection of the use of newly introduced PHP native interfaces. This sniff will also detect unsupported methods when a class implements theSerializableinterface. #144 - 🌟 New
RequiredOptionalFunctionParameterssniff: detection of missing function parameters which were required in earlier PHP versions only to become optional in later versions. #165 - 🌟 New
ValidIntegerssniff: 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. - ⭐
DeprecatedExtensionssniff: detect removal of theeregextension in PHP 7. #149 - ⭐
DeprecatedFunctionssniff: detection of the PHP 5.0.5 deprecatedphp_check_syntax()and PHP 5.4 deprecatedmysqli_get_cache_stats()functions. #155. - ⭐
DeprecatedFunctionssniff: detect deprecation of a number of themysqlifunctions in PHP 5.3. #149 - ⭐
DeprecatedFunctionssniff: detect removal of thecall_user_method(),ldap_sort(),ereg_*()andmysql_*()functions in PHP 7.0. #149 - ⭐
DeprecatedIniDirectivessniff: detection of a lot more deprecated/removed ini directives. #146 - ⭐
NewFunctionParameterssniff: detection of a lot more new function parameters. #164 - ⭐
NewFunctionssniff: detection of numerous extra new functions. #161 - ⭐
NewIniDirectivessniff: detection of a lot more new ini directives. #146 - ⭐
NewLanguageConstructssniff: detection of the PHP 5.6 ellipsis...construct. #175 - ⭐
NewScalarTypeDeclarationssniff: detection of PHP 5.1arrayand PHP 5.4callabletype hints. #168 - ⭐
RemovedFunctionParameterssniff: detection of a few extra removed function parameters. #163 - ⭐ Detection of functions and methods with a double underscore prefix as these are reserved by PHP for future use. The existing upstream
Generic.NamingConventions.CamelCapsFunctionNamesniff is re-used for this with some customization. #173 - ⭐ New
getFQClassNameFromNewToken(),getFQExtendedClassName(),getFQClassNameFromDoubleColonToken(),getFQName(),isNamespaced(),determineNamespace()andgetDeclaredNamespaceName()utility methods in thePHPCompatibility_Sniffbase class for namespace determination. #162 - ♻️ New
inClassScope()utility method in thePHPCompatibility_Sniffbase class. #168 - ♻️ New
doesFunctionCallHaveParameters()andgetFunctionCallParameterCount()utility methods in thePHPCompatibility_Sniffbase class. #153 - ☔ Unit test for
__halt_compiler()detection by theNewKeywordssniff. - ☔ Unit tests for the
NewFunctionssniff. #161 - ☔ Unit tests for the
ParameterShadowSuperGlobalssniff. #180 - 🔧 Minimal config for Scrutinizer CI. #145.
- 📌 The
DeprecatedIniDirectivesand theNewIniDirectivessniffs will now indicate an alternative ini directive in case the directive has been renamed. #146 - 📌 The
NewClassessniff will now also report on new classes being extended by child classes. #140. - 📌 The
NewClassessniff will now also report on static use of new classes. #162. - 📌 The
NewScalarTypeDeclarationssniff will now throw an error on use of type hints pre-PHP 5.0. #168 - 📌 The
NewScalarTypeDeclarationssniff will now verify type hints used against typical mistakes. #168 - 📌 The
ParameterShadowSuperGlobalssniff will now do a case-insensitive variable name compare. #180 - 📌 The
RemovedFunctionParameterssniff will now also reportwarnings on deprecation of function parameters. #163 - 🔀 The check for
JsonSerializablehas been moved from theNewClassessniff to theNewInterfacessniff. #162 - ⏪ The
NewLanguageConstructssniff will now also recognize new language constructs when used in combination with PHPCS 1.5.x. #175 - ✏️
NewFunctionParameterssniff: use correct name for the new parameter for thedirname()function. #164 - ✏️
NewScalarTypeDeclarationssniff: minor change in the sniff error message text. #168 - ✏️
RemovedFunctionParameterssniff: minor change in the sniff error message text. #163 - ✏️ The
ParameterShadowSuperGlobalssniff now extends thePHPCompatibility_Sniffclass. #180 - ♻️ Various (minor) refactoring for improved performance and sniff accuracy. #181, #182, #166, #167, #172, #180, #146, #138
- ♻️ Various refactoring to remove code duplication in the unit tests and add proper test skip notifications where relevant. #139, #149
- 🐛 The
DeprecatedFunctionssniff was reporting an incorrect deprecation/removal version number for a few functions. #149 - 🐛 The
DeprecatedIniDirectivessniff was in select cases reporting deprecation of an ini directive prior to removal, while the ini directive was never deprecated prior to its removal. #146 - 🐛 The
DeprecatedPHP4StyleConstructorssniff would cause false positives for methods with the same name as the class in namespaced classes. #167 - 🐛 The
ForbiddenEmptyListAssignmentsniff did not report errors when there were only comments or parentheses between the list parentheses. #166 - 🐛 The
ForbiddenEmptyListAssignmentsniff will no longer cause false positives during live coding. #166 - 🐛 The
NewClassessniff would potentially misidentify namespaced classes as PHP native classes. #161 - 🐛 The
NewFunctionssniff would fail to identify called functions when the function call was not lowercase. #161 - 🐛 The
NewFunctionssniff would potentially misidentify namespaced userland functions as new functions. #161 - 🐛 The
NewIniDirectivessniff was reporting an incorrect introduction version number for a few ini directives. #146 - 🐛
NewKeywordssniff: the use of theconstkeyword should only be reported when used outside of a class for PHP < 5.3. #147. Fixes #129. - 🐛 The
RemovedExtensionssniff was incorrectly reporting a number of extensions as being removed in PHP 5.3 while they were actually removed in PHP 5.1. #156 - 🐛 ♻️ The
NewFunctionParametersandRemovedFunctionParametersnow use the newdoesFunctionCallHaveParameters()andgetFunctionCallParameterCount()utility methods for improved accuracy in identifying function parameters. This fixes several false positives. #153 Fixes #120, #151, #152. - 🐛 A number of sniffs would return
falseif the examined construct was not found. This could potentially cause race conditions/infinite sniff loops. #138 - 🔧 The unit tests would fail to run when used in combination with a PEAR install of PHPCS. #157.
- 💚 Unit tests failing against PHPCS 2.6.1. #158 The unit tests will still fail against PHPCS 2.6.2 due to a bug in PHPCS itself. This bug does not affect the running of the sniffs outside of a unit test context.
Thanks go out to Juliette Reinders Folmer for her contributions to this version. 👏
7.0.2 - 2016-08-03
See all related issues and PRs in the 7.0.2 milestone.
- ⭐
RemovedExtensionssniff: 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 thefunctionWhitelistproperty in your custom ruleset. For more information, see the README.
- ✏️ A number of sniffs contained
publicclass properties. Within PHPCS,publicproperties can be overruled via a custom ruleset. This was not the intention, so the visibility of these properties has been changed toprotected. #135 - 🔧 Composer config: Stable packages are preferred over unstable/dev.
- ✏️ Ruleset name. #134
Thanks go out to Juliette Reinders Folmer for her contributions to this version. 👏
7.0.1 - 2016-08-02
See all related issues and PRs in the 7.0.1 milestone.
- 📌 The
DeprecatedIniDirectivessniff used to throw anerrorwhen a deprecated ini directive was used in combination withini_get(). It will now throw awarninginstead. #122 Fixes #119. Usage of deprecated ini directives in combination withini_set()will still throw anerror. - 📌 The
PregReplaceEModifiersniff now also detects theemodifier when used with thepreg_filter()function. While this is undocumented, theemodifier was supported by thepreg_filter()function as well. #128 - ✏️ The
RemovedExtensionssniff contained superfluous deprecation information in the error message. #131
- 🔧 Duplicate builds from the Travis CI build matrix. #132
- 🐛 The
ForbiddenNamessniff did not allow for the PHP 5.6use function ...anduse const ...syntax. #126 Fixes #124. - 🐛 The
NewClassessniff failed to detect new classes when the class was instantiated without parenthesis, i.e.new NewClass;. #121 - 🐛 The
PregReplaceEModifiersniff failed to detect theemodifier when using bracket delimiters for the regex other than the{}brackets. #128 - 💚 Unit tests failing against PHPCS 2.6.1.
Thanks go out to Jason Stallings, Juliette Reinders Folmer and Ryan Neufeld for their contributions to this version. 👏
7.0 - 2016-07-02
See all related issues and PRs in the 7.0 milestone.
- ⚡ Ability to specify a range of PHP versions against which to test your code base for compatibility, i.e.
--runtime-set testVersion 5.0-5.4will now test your code for compatibility with PHP 5.0 up to PHP 5.4. #99 - 🌟 New
NewFunctionArrayDereferencingsniff to detect function array dereferencing as introduced in PHP 5.4. Fixes #52. - 🌟 New
ShortArraysniff to detect short array syntax as introduced in PHP 5.4. #97. Fixes #47. - 🌟 New
TernaryOperatorssniff to detect ternaries without the middle part (elvisoperator) as introduced in PHP 5.3. #101, #103. Fixes #49. - 🌟 New
ConstantArraysUsingDefinesniff to detect constants declared usingdefine()being assigned anarrayvalue which was not allowed prior to PHP 7.0. #110 - 🌟 New
DeprecatedPHP4StyleConstructorssniff to detect PHP 4 style class constructor methods which are deprecated as of PHP 7. #109. - 🌟 New
ForbiddenEmptyListAssignmentsniff to detect empty list() assignments which have been removed in PHP 7.0. #110 - 🌟 New
ForbiddenFunctionParametersWithSameNamesniff to detect functions declared with multiple same-named parameters which is no longer accepted since PHP 7.0. #110 - 🌟 New
ForbiddenGlobalVariableVariablesniff to detect variable variables being madeglobalwhich is not allowed since PHP 7.0. #110 - 🌟 New
ForbiddenNegativeBitshiftsniff to detect bitwise shifts by negative number which will throw an ArithmeticError in PHP 7.0. #110 - 🌟 New
ForbiddenSwitchWithMultipleDefaultBlockssniff to detect switch statements with multiple default blocks which is not allowed since PHP 7.0. #110 - 🌟 New
NewAnonymousClassessniff to detect anonymous classes as introduced in PHP 7.0. #110 - 🌟 New
NewClosuresniff to detect anonymous functions as introduced in PHP 5.3. Fixes #35 - 🌟 New
NewFunctionParameterssniff 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_needleparameter for thestrstr()function. #110, #112. Fixes #27. - 🌟 New
NewGroupUseDeclarationssniff to detect group use declarations as introduced in PHP 7.0. #110 - 🌟 New
NewScalarReturnTypeDeclarationssniff to detect scalar return type hints as introduced in PHP 7.0. #110 - 🌟 New
NewScalarTypeDeclarationssniff to detect scalar function parameter type hints as introduced in PHP 7.0. #110 - 🌟 New
RemovedFunctionParameterssniff to detect use of removed parameters in build-in PHP functions. Initially only sniffing for the function parameters removed in PHP 7.0. #110 - 🌟 New
RemovedGlobalVariablessniff to detect the PHP 7.0 removed$HTTP_RAW_POST_DATAsuperglobal. #110 - ⭐
DeprecatedFunctionssniff: detection of the PHP 5.4 deprecated OCI8 functions. #93 - ⭐
ForbiddenNamesAsInvokedFunctionssniff: recognize PHP 5.5finallyas a reserved keywords when invoked as a function. #110 - ⭐
NewKeywordssniff: detection of the use of the PHP 5.1+__halt_compilerkeyword. Fixes #50. - ⭐
NewKeywordssniff: detection of the PHP 5.3+nowdocsyntax. Fixes #48. - ⭐
NewKeywordssniff: detection of the use of theconstkeyword outside of a class for PHP < 5.3. Fixes #50. - ⭐
DeprecatedFunctionssniff: recognize PHP 7.0 deprecated and removed functions. #110 - ⭐
DeprecatedIniDirectivessniff: recognize PHP 7.0 removed ini directives. #110 - ⭐
ForbiddenNamesAsInvokedFunctionssniff: recognize new PHP 7.0 reserved keywords when invoked as functions. #110 - ⭐
ForbiddenNamessniff: recognize new PHP 7.0 reserved keywords. #110 - ⭐
NewFunctionssniff: recognize new functions as introduced in PHP 7.0. #110 - ⭐
NewLanguageConstructssniff: recognize new PHP 7.0<=>"spaceship" and??null coalescing operators. #110 - ⭐
RemovedExtensionssniff: recognize PHP 7.0 removedereg,mssql,mysqlandsybase_ctextensions. #110 - ☔ Additional unit tests for the
NewLanguageConstructssniff. #110 - 📚 Readme: New section containing information about the use of the
testVersionconfig variable. - 📚 Readme: Sponsor credits.
- 📌 The
DeprecatedIniDirectivessniff used to always throw anwarning. Now it will throw anerrorwhen a removed ini directive is used. #110. - 📌 The
DeprecatedNewReferencesniff will now throw an error when thetestVersionincludes PHP 7.0 or higher. #110 - 📌 The
ForbiddenNamessniff now supports detection of reserved keywords when used in combination with PHP 7 anonymous classes. #108, #110. - 📌 The
PregReplaceEModifiersniff will now throw an error when thetestVersionincludes PHP 7.0 or higher. #110 - ✏️
NewKeywordssniff: clarified the error message text for theusekeyword. Fixes #46. - ♻️ Minor refactor of the
testVersionrelated utility functions. #98 - 🔧 Add autoload to the
composer.jsonfile. #96 Fixes #67. - 🔧 Minor other updates to the
composer.jsonfile. #75 - 🔧 Improved creation of the code coverage reports needed by coveralls via Travis.
- 💚 The sniffs are now also tested against PHP 7.0 for consistent results.
- 🐛 The
ForbiddenCallTimePassByReferencesniff was throwingUndefined indexnotices when used in combination with PHPCS 2.2.0. #100. Fixes #42. - 🐛 The
ForbiddenNamesAsInvokedFunctionssniff would incorrectly throw an error if thethrowkeyword was used with parenthesis. Fixes #118. - 🐛 The
PregReplaceEModifiersniff incorrectly identifiede's in the pattern as theemodifier when using{}bracket delimiters for the regex. #94 - 🐛 The
RemovedExtensionssniff was throwing anerrorinstead of awarningfor 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. 👏
5.6 - 2015-09-14
See all related issues and PRs in the 5.6 milestone.
- 🌟 New:
NewLanguageConstructssniff. The initial version of this sniff checks for the PHP 5.6**power operator and the**=power assignment operator. #87. Fixes #60. - 🌟 New:
ParameterShadowSuperGlobalssniff which covers the PHP 5.4 change Parameter names that shadow super globals now cause a fatal error.`. #74 - 🌟 New:
PregReplaceEModifiersniff which detects usage of theemodifier in literal regular expressions used withpreg_replace(). Theemodifier will not (yet) be detected when the regex passed is a variable or constant. #81, #84. Fixes #71, #83. - ⭐
DeprecatedIniDirectivessniff: PHP 5.6 deprecated ini directives. - ⭐
NewKeywordssniff: detection of thegotokeyword introduced in PHP 5.3 and thecallablekeyword introduced in PHP 5.4. #57 - ♻️
PHPCompatibility_Sniffbase class initially containing thesupportsAbove()andsupportsBelow()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 settestVersion. #77 - 📚 Readme: Composer installation instructions. #32, #61
- 🔧
.gitignoreto ignore vendor and IDE related directories. #78 - 💚 Code coverage checking via coveralls.
- 🔀 The check for the
\namespace separator has been moved from theNewKeywordssniff to theNewLanguageConstructssniff. #88 - ✏️
DeprecatedIniDirectivessniff: minor change in the sniff error message text. - ✏️
DeprecatedFunctionssniff: minor change in the sniff error message text. - 🔧 Minor updates to the
composer.jsonfile. #31, 34, #70 - 🔧 Tests: The unit tests can now be run without configuration.
- 🔧 Tests: Skipped unit tests will now be annotated as such. #85
- 💚 The sniffs are now also tested against PHP 5.6 for consistent results.
- 💚 The sniffs are now also tested against PHPCS 2.0+.
- 💚 The sniffs are now tested using the new container-based infrastructure in Travis CI. #37
- 🐛 The
ForbiddenCallTimePassByReferencesniff was throwing false positives when a bitwise and&was used in combination with class constants and class properties within function calls. #44. Fixes #39. - 🐛 The
ForbiddenNamesAsInvokedFunctionssniff was throwing false positives in certain cases when a comment separated atryfrom thecatchblock. #29 - 🐛 The
ForbiddenNamesAsInvokedFunctionssniff was incorrectly reportinginstanceofas being introduced in PHP 5.4 while it has been around since PHP 5.0. #80 - ✅ Compatibility with PHPCS 2.0 - 2.3. #63, #65
Thanks 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. 👏
First tagged release.
See all related issues and PRs in the 5.5 milestone.