All Versions
31
Latest Version
Avg Release Cycle
52 days
Latest Release
1660 days ago

Changelog History
Page 2

  • v8.2.0 Changes

    July 17, 2018

    Important changes

    ๐Ÿšš The repository has moved

    ๐Ÿšš 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.

    Framework/CMS specific PHPCompatibility rulesets

    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.

    ๐Ÿ”„ Changes expected in PHPCompatibility 9.0.0

    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.


    ๐Ÿ‘€ See all related issues and PRs in the [8.2.0 milestone].

    โž• Added

    • ๐ŸŒŸ New ArgumentFunctionsUsage sniff to detect usage of the func_get_args(), func_get_arg() and func_num_args() functions and the changes regarding these functions introduced in PHP 5.3. #596. Fixes #372.
    • ๐Ÿฑ ๐ŸŒŸ New DiscouragedSwitchContinue sniff to detect continue targetting a switch control structure for which E_WARNINGS will be thrown as of PHP 7.3. #687
    • ๐Ÿฑ ๐ŸŒŸ New NewClassMemberAccess sniff to detect class member access on instantiation as added in PHP 5.4 and class member access on cloning as added in PHP 7.0. #619. Fixes #53.
    • ๐Ÿฑ ๐ŸŒŸ New NewConstantScalarExpressions sniff to detect PHP 5.6 scalar expression in contexts where PHP previously only allowed static values. #617. Fixes #399.
    • ๐Ÿฑ ๐ŸŒŸ New NewGeneratorReturn sniff to detect return statements within generators as introduced in PHP 7.0. #618
    • ๐Ÿฑ ๐ŸŒŸ New PCRENewModifiers sniff to initially detect the new J regex modifier as introduced in PHP 7.2. #600. Fixes #556.
    • ๐Ÿฑ ๐ŸŒŸ New ReservedFunctionNames sniff to report on double underscore prefixed functions and methods. This was previously reported via an upstream sniff. #581
    • ๐Ÿฑ ๐ŸŒŸ New NewTrailingComma sniff to detect trailing comma's in function calls, method calls, isset() and unset() as will be introduced in PHP 7.3. #632
    • โฌ†๏ธ ๐ŸŒŸ New Upgrade/LowPHPCS sniff to give users of old PHP_CodeSniffer versions advance warning when support will be dropped in the near future. #693
    • ๐Ÿฑ โญ๏ธ NewClasses sniff: check for some 40+ additional PHP native classes added in various PHP versions. #573
    • ๐Ÿฑ โญ๏ธ NewClosure sniff: check for usage of self/parent/static:: being used within closures, support for which was only added in PHP 5.4. #669. Fixes #668.
    • ๐Ÿฑ โญ๏ธ NewConstants sniff: recognize constants added by the PHP 5.5+ password extension. #626
    • ๐Ÿฑ โญ๏ธ NewFunctionParameters sniff: recognize a number of additional function parameters added in PHP 7.0, 7.1 and 7.2. #602
    • โญ๏ธ NewFunctions sniff: recognize the PHP 5.1 SPL extension functions, the PHP 5.1.1 hash_hmac() function, the PHP 5.6 pg_lo_truncate() function, more PHP 7.2 Sodium functions and the new PHP 7.3 is_countable() function. #606, #625, #640, #651
    • ๐Ÿฑ โญ๏ธ NewHashAlgorithms sniff: recognize the new hash algorithms which were added in PHP 7.1. #599
    • ๐Ÿฑ โญ๏ธ NewInterfaces sniff: check for the PHP 5.0 Reflector interface. #572
    • ๐Ÿฑ โญ๏ธ OptionalRequiredFunctionParameters sniff: detect missing $salt parameter in calls to the crypt() function (PHP 5.6+). #605
    • ๐Ÿฑ โญ๏ธ RequiredOptionalFunctionParameters sniff: recognize that the $varname parameter of getenv() and the $scale parameter of bcscale() have become optional as of PHP 7.1 and 7.3 respectively. #598, #612
    • ๐Ÿฑ โญ๏ธ New AbstractFunctionCallParameterSniff to be used as a basis for sniffs examining function call parameters. #636
    • ๐Ÿฑ โญ๏ธ New getReturnTypeHintName() utility method to the PHPCompatibility\Sniff class. #578, #642
    • ๐Ÿฑ โญ๏ธ New isNumber(), isPositiveNumber() and isNegativeNumber() utility methods to the PHPCompatibility\Sniff class. #610, #650
    • ๐Ÿฑ โญ๏ธ New isShortList() utility method to the PHPCompatibility\Sniff class. #635
    • ๐Ÿฑ โญ๏ธ New getCommandLineData() method to the PHPCompatibility\PHPCSHelper class to provide PHPCS cross-version compatible access to command line info at run time. #693
    • ๐Ÿฑ โญ๏ธ Duplicate of upstream findEndOfStatement() method to the PHPCompatibility\PHPCSHelper class 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 testVersion in a custom ruleset to be overruled by the command-line. #607

    ๐Ÿ”„ Changed

    • ๐Ÿฑ ๐Ÿ“š 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 the const keyword.
      0๏ธโƒฃ 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 ForbiddenNegativeBitshift sniff would previously only report on "bitshift right". As of this version, "bitshift left" and bitshift assignments will also be recognized. #614
    • ๐Ÿ“Œ The NewClasses and NewInterfaces sniffs will now also report on new classes/interfaces when used as return type declarations. #578
    • ๐Ÿฑ ๐Ÿ“Œ The NewScalarTypeDeclarations sniff will now recognize parent as a valid type declaration.
      ๐Ÿ‘ The sniff will now also throw an error about using self and parent when PHP < 5.2 needs to be supported as PHP 5.1 and lower would presume these to be class names instead of keywords. #595
    • ๐Ÿ“Œ The PregReplaceEModifier sniff - and the PCRENewModifiers sniff by extension - will now correctly examine and report on modifiers in regexes passed via calls to preg_replace_callback_array(). #600, #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 the PHPCompatibility\Sniff class to the PHPCompatibility\PHPCSHelper class and have become static methods. #613
    • โœ… getReturnTypeHintToken() utility method: align returned $stackPtr with 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, PregReplaceEModifier and the PregReplaceEModifier sniffs now extend the new AbstractFunctionCallParameterSniff class. This should yield more accurate results when checking whether one of the target PHP functions was called. #636
    • โšก๏ธ โœ๏ธ DeprecatedNewReference sniff: minor change to the error text and code - was Forbidden, now Removed -. Custom rulesets which explicitly excluded this error code will need to be updated. #594
    • ๐Ÿฑ โœ๏ธ NewScalarTypeDeclarations sniff: 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.json file, 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

    โœ‚ Removed

    • ๐Ÿšซ 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

    ๐Ÿ›  Fixed

    • ๐Ÿฑ ๐Ÿ› Previously, the PHPCS native Generic.NamingConventions.CamelCapsFunctionName sniff was included in PHPCompatibility. Some error codes of this sniff were excluded, as well as some error messages changed (via the ruleset).
      ๐Ÿ’… If/when PHPCompatibility would be used in combination with a code style-type ruleset, this could inadvertently lead to underreporting of issues which the CS-type ruleset intends to have reported - i.e. the error codes excluded by PHPCompatibility -. This has now been fixed. #581
    • ๐Ÿฑ ๐Ÿ› The ForbiddenNegativeBitshift sniff would incorrectly throw an error when a bitshift was based on a calculation which included a negative number, but would not necessarily result in a negative number. #614. Fixes #294, #466.
    • ๐Ÿฑ ๐Ÿ› The NewClosure sniff would report the same issue twice when the issue was encountered in a nested closure. #669
    • ๐Ÿฑ ๐Ÿ› The NewKeywords sniff would underreport on non-lowercase keywords. #627
    • ๐Ÿฑ ๐Ÿ› The NewKeywords sniff would incorrectly report on the use of class constants and class properties using the same name as a keyword. #627
    • ๐Ÿฑ ๐Ÿ› The NewNullableTypes sniff 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

    Credits

    ๐Ÿฑ Thanks go out to Michael Babker and Juliette Reinders Folmer for their contributions to this version. ๐Ÿ‘

  • v8.1.0 Changes

    December 27, 2017

    ๐Ÿ‘€ See all related issues and PRs in the 8.1.0 milestone.

    โž• Added

    • ๐Ÿฑ ๐ŸŒŸ New NewConstants and RemovedConstants sniffs to detect usage of new/removed PHP constants for all PHP versions from PHP 5 up. #526, #551, #566. Fixes #263.
    • ๐Ÿฑ ๐ŸŒŸ New MagicAutoloadDeprecation sniff to detect deprecated __autoload() functions as deprecated in PHP 7.2. #540
    • ๐Ÿฑ ๐ŸŒŸ New OptionalRequiredFunctionParameter sniff to check for missing function call parameters which were required and only became optional in a later PHP version. #524
    • ๐Ÿฑ ๐ŸŒŸ New DynamicAccessToStatic sniff to detect dynamic access to static methods and properties, as well as class constants, prior to PHP 5.3. #535. Fixes #534.
    • ๐Ÿฑ โญ๏ธ DeprecatedFunctions sniff: recognize yet more PHP 7.2 deprecated functions. #561, #566
    • ๐Ÿฑ โญ๏ธ DeprecatedIniDirectives sniff: 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 the mcrypt extension which has been removed in PHP 7.2. #566
    • โญ๏ธ RemovedGlobalVariables : detection of the use of $php_errormsg with track_errors which has been deprecated in PHP 7.2. #528
    • ๐Ÿ“š ๐Ÿ“š Documentation : added reporting usage instructions. #533, #552

    ๐Ÿ”„ Changed

    • โฌ‡๏ธ ๐Ÿ“Œ 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 a global statement which is no longer supported and show the variable found to make it easier to fix this. Previously only one error would be thrown per global statement. #564
    • ๐Ÿฑ ๐Ÿ“Œ ForbiddenGlobalVariableVariable : the sniff will now throw warnings for non-bare variables used in a global statement as those are discouraged since PHP 7.0. #564
    • โช NewLanguageConstructs : updated the version number for T_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-installer Composer plugin has been upped to 0.4.3. #548

    ๐Ÿ›  Fixed

    • ๐Ÿ› 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 on global in combination with variable variables which are still supported. #564. Fixes #537.
    • ๐Ÿฑ ๐Ÿ› ForbiddenGlobalVariableVariable : variables interspersed with whitespace and/or comments were not being reported. #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.

    Credits

    ๐Ÿฑ Thanks go out to Juliette Reinders Folmer and Jonathan Van Belle for their contributions to this version. ๐Ÿ‘

  • v8.0.1 Changes

    August 07, 2017

    ๐Ÿ‘€ See all related issues and PRs in the 8.0.1 milestone.

    โž• Added

    • ๐Ÿฑ ๐ŸŒŸ New DeprecatedTypeCasts sniff to detect deprecated and removed type casts, such as the (unset) type cast as deprecated in PHP 7.2. #498
    • ๐Ÿฑ ๐ŸŒŸ New NewTypeCasts sniff 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
    • ๐Ÿฑ โญ๏ธ DeprecatedFunctions sniff: recognize some more PHP 7.2 deprecated functions. #501
    • ๐Ÿฑ โญ๏ธ DeprecatedIniDirectives sniff: recognize more PHP 7.2 deprecated ini directives. #500
    • ๐Ÿฑ โญ๏ธ ForbiddenNames sniff: recognize object as a forbidden keyword since PHP 7.2. #499
    • ๐Ÿฑ โญ๏ธ NewReturnTypeDeclarations sniff: recognize generic parent, PHP 7.1 iterable and PHP 7.2 object return type declarations. #505, #499
    • ๐Ÿฑ โญ๏ธ NewScalarTypeDeclarations sniff: recognize PHP 7.2 object type declarion. #499

    ๐Ÿ”„ Changed

    ๐Ÿฑ โœ๏ธ Improved clarity of the deprecated functions alternative in the error message. #502

    ๐Ÿ›  Fixed

    ๐Ÿš‘ ๐Ÿš’ Temporary hotfix for installed_paths (pending upstream fix.) #503

    Credits

    ๐Ÿฑ Thanks go out to Juliette Reinders Folmer for her contributions to this version. ๐Ÿ‘

  • v8.0.0 Changes

    August 02, 2017

    ๐Ÿ”– 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 phpcs script has changed (upstream change).

    โฌ†๏ธ Please follow the below upgrade instructions carefully. This should be a one-time only action.

    โฌ†๏ธ Upgrade instructions

    โฌ†๏ธ Before upgrading

    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.

    โฌ†๏ธ Upgrading: re-registering PHPCompatibility with PHP CodeSniffer

    ๐Ÿ”Œ 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.

    ๐Ÿ”Œ Using a Composer plugin

    ๐Ÿ”Œ 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.1 composer install composer update wimg/php-compatibility squizlabs/php\_codesniffer vendor/bin/phpcs -i
    

    ๐Ÿ‘€ If all went well, you should now see PHPCompatibility listed again in the list of installed standards.

    Manually re-registering PHPCompatibility

    First run phpcs --config-show to 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/wimg vendor/wimg/php-compatibility
    ๐Ÿš€ Unzipped release to arbitrary directory path/to/dir/abovePHPCompatibility
    Git checkout path/to/dir/abovePHPCompatibility path/to/dir/abovePHPCompatibility/PHPCompatibility
    PEAR If the old install instruction has been followed, not registered. path/to/PHPCompatibility

    Side-note :

    ๐Ÿš€ > If you used the old install instructions for a PEAR install, i.e. checking out the latest release to the PHP/CodeSniffer/Standards/PHPCompatibility directory, 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_paths value 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_paths was

    /path/to/MyStandard,/path/to/dir/abovePHPCompatibility

    you 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/wimg/php-compatibility" /\>
    

    โš™ Run phpcs -i to verify that the PHPCompatibility standard is now listed again in the list of installed standards.

    โฌ†๏ธ Upgrading to PHPCS 3.x

    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.

    โฌ†๏ธ Upgrading a Travis build script

    ๐Ÿ— 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 clone to install PHP CodeSniffer and PHPCompatibility on the travis image, your build will fail until you make the following changes:
      1. 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 master or a PHPCS 3 tag.
      2. Check to which path PHPCompatibility is being cloned and adjust the path if necessary.
      3. Adjust the phpcs --config-set installed_paths command as described above to point to the root of the cloned PHPCompatibility repo.
      4. If you switched to using PHPCS 3.x, adjust the call to PHPCS.

    ๐Ÿ”„ Changelog for version 8.0.0

    ๐Ÿ‘€ See all related issues and PRs in the 8.0 milestone.

    โž• Added

    ๐Ÿ”„ Changed

    • ๐Ÿฑ ๐ŸŽ 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 functionWhitelist property for the PHPCompatibility.PHP.RemovedExtensions sniff is now only supported in combination with PHP CodeSniffer 2.6.0 or higher (due to an upstream bug which was fixed in PHPCS 2.6.0). #482
    • ๐Ÿฑ ๐Ÿ”ง Improved the information provided to Composer from the composer.json file. #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-source or 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 .dist extensions 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

    โœ‚ Removed

    ๐Ÿšซ 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

    Credits

    ๐Ÿฑ Thanks go out to Gary Jones and Juliette Reinders Folmer for their contributions to this version. ๐Ÿ‘

  • v7.1.5 Changes

    July 16, 2017

    โž• Added

    ๐Ÿฑ โญ๏ธ The NewKeywords sniff will now also sniff for yield from which was introduced in PHP 7.0. #477. Fixes #476
    ๐Ÿฑ ๐Ÿ“š The LGPL-3.0 license. #447

    ๐Ÿ”„ Changed

    ๐Ÿฑ โช The NewExecutionDirectives sniff 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

    โœ‚ Removed

    ๐Ÿšซ The DefaultTimeZoneRequired sniff. This sniff was checking server settings rather than code. #458. Fixes #457
    ๐Ÿšซ The NewMagicClassConstant sniff as introduced in v 7.1.4 contained two additional checks for not strictly compatibility related issues. One of these was plainly wrong, the other opinionated. Both have been removed. #442. Fixes #436

    ๐Ÿ›  Fixed

    ๐Ÿฑ ๐Ÿ› NewClass sniff: was reporting an incorrect introduction version number for a few of the Exception classes. #441. Fixes #440.
    ๐Ÿฑ ๐Ÿ› ForbiddenBreakContinueVariableArguments sniff: was incorrectly reporting an error if the break or continue was followed by a PHP closing tag (breaking out of PHP). #462. Fixes #460
    ๐Ÿฑ ๐Ÿ› ForbiddenGlobalVariableVariable sniff: was incorrectly reporting an error if the global statement was followed by a PHP closing tag (breaking out of PHP). #463.
    ๐Ÿฑ ๐Ÿ› DeprecatedFunctions sniff: was reporting false positives for classes using the same name as a deprecated function. #465. Fixes #464

    Credits

    ๐Ÿฑ Thanks go out to Juliette Reinders Folmer and Mark Clements for their contributions to this version. ๐Ÿ‘

  • v7.1.4 Changes

    May 06, 2017

    โž• Added

    • ๐Ÿฑ ๐ŸŒŸ New CaseSensitiveKeywords sniff to detect use of non-lowercase self, static and parent keywords which could cause compatibility issues pre-PHP 5.5. #382
    • ๐Ÿฑ ๐ŸŒŸ New ConstantArraysUsingConst sniff to detect constants defined using the const keyword being assigned an array value which was not supported prior to PHP 5.6. #397
    • ๐Ÿฑ ๐ŸŒŸ New ForbiddenClosureUseVariableNames sniff to detect PHP 7.1 forbidden variable names in closure use statements. #386. Fixes #374
    • ๐Ÿฑ ๐ŸŒŸ New NewArrayStringDereferencing sniff to detect array and string literal dereferencing as introduced in PHP 5.5. #388
    • ๐Ÿฑ ๐ŸŒŸ New NewHeredocInitialize sniff 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 NewMagicClassConstant sniff to detect use of the magic ::class constant as introduced in PHP 5.5. #403. Fixes #364.
    • ๐Ÿฑ ๐ŸŒŸ New NewUseConstFunction sniff to detect use statements importing constants and functions as introduced in PHP 5.6. #401
    • ๐Ÿฑ โญ๏ธ DeprecatedFunctions sniff: recognize PHP 7.2 deprecated GD functions. #392
    • ๐Ÿฑ โญ๏ธ DeprecatedIniDirectives sniff: recognize PHP 7.2 deprecated mbstring.func_overload directive. #377
    • ๐Ÿฑ โญ๏ธ NewClasses sniff: check for the PHP 5.1 libXMLError class. #412
    • ๐Ÿฑ โญ๏ธ NewClasses sniff: recognize all native PHP Exception classes. #418
    • ๐Ÿฑ โญ๏ธ NewClosures sniff: check for closures being declared as static and closures using $this. Both of which was not supported pre-PHP 5.4. #389. Fixes #24.
    • โญ๏ธ NewFunctionParameters sniff: recognize new exclude_disabled parameter for the get_defined_functions() function as introduced in PHP 7.0.15. #375
    • ๐Ÿฑ โญ๏ธ NewFunctions sniff: recognize new PHP 7.2 socket related functions. #376
    • ๐Ÿฑ โญ๏ธ NewInterfaces sniff: check for some more PHP native interfaces. #411
    • ๐Ÿฑ โญ๏ธ New isClassProperty(), isClassConstant() and validDirectScope() utility methods to the PHPCompatibility_Sniff class. #393, #391.
    • ๐Ÿฑ โญ๏ธ New getTypeHintsFromFunctionDeclaration() utility method to the PHPCompatibility_Sniff class. #414.
    • ๐Ÿฑ โ˜”๏ธ Unit tests against false positives for the NewMagicMethods sniff. #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_paths via a custom ruleset. #407
    • ๐Ÿš€ ๐Ÿ“š Changelog.md file containing a record of notable changes since the first tagged release. #421

    ๐Ÿ”„ Changed

    • ๐Ÿฑ ๐Ÿ“Œ The ForbiddenNamesAsDeclared sniff will now emit warnings for soft reserved keywords. #406, #370.
    • ๐Ÿฑ ๐Ÿ“Œ The ForbiddenNames sniff 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, NonStaticMagicMethods and RemovedGlobalVariables sniffs will now also sniff for and correctly report violations in combination with anonymous classes. #378, #383, #393, #394, #395, #396. Fixes #351 and #333.
    • ๐Ÿฑ ๐Ÿ“Œ The NewClasses and NewInterfaces sniffs will now also report on new classes/interfaces when used as type hints. #414, #416. Fixes #352
    • ๐Ÿฑ ๐Ÿ“Œ The NewClasses sniff will now also report on Exception classes when used in (multi-)catch statements. #418. Fixes #373.
    • ๐Ÿฑ ๐Ÿ“Œ The NewScalarTypeDeclarations sniff will now report on new type hints even when the type hint is nullable. #379
    • ๐Ÿ”€ The NewNowdoc sniff has been renamed to NewNowdocQuotedHeredoc and will now also check for double quoted heredoc identifiers as introduced in PHP 5.3. #390
    • ๐Ÿฑ โช The NewClasses sniff will now also report anonymous classes which extend a new sniff when used in combination with PHPCS 2.4.0-2.8.0. #432. Fixes #334.
    • ๐Ÿฑ โœ๏ธ NewFunctionParameter sniff: version number precision for two parameters. #384, #428
    • ๐Ÿฑ โ˜”๏ธ Skipping two unit tests for the ForbiddenClosureUseVariable sniff 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 as traits 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

    ๐Ÿ›  Fixed

    • ๐Ÿฑ ๐Ÿ”ฅ Using unbounded ranges in testVersion resulted in unreported errors when used with sniffs using the supportsBelow() method. This affected the results of approximately half the sniffs. #430
    • ๐Ÿฑ ๐Ÿ› The ForbiddenNames sniff would throw false positives for use statements with the final modifier in traits. #402.
    • ๐Ÿฑ ๐Ÿ› The ForbiddenNames sniff would fail to report on functions declared to return by reference using a reserved keyword as the function name. #413
    • ๐Ÿฑ ๐Ÿ› The ForbiddenNames sniff 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 ForbiddenNames sniff would not always correctly report on use statements importing constants or functions using reserved keywords. #420
    • ๐Ÿฑ ๐Ÿ› The NewKeywords sniff would sometimes fail to report on the const keyword when used in a class, but not for a class constant. #424
    • ๐Ÿš€ ๐Ÿ’š PHPCS has released version 3.0 and updated the master branch to reflect this. This was causing the builds to fail. #422

    Credits

    ๐Ÿฑ Thanks go out to Juliette Reinders Folmer and Mark Clements for their contributions to this version. ๐Ÿ‘

  • v7.1.3 Changes

    April 02, 2017

    ๐Ÿ‘€ See all related issues and PRs in the [7.1.3 milestone].

    โž• Added

    • โœ… :zap: The testVersion config parameter now allows for specifying unbounded ranges. For example: specifying -5.6 means: check for compatibility with all PHP versions up to and including PHP 5.6; Specifying 7.0- means: check for compatibility with all PHP versions from PHP 7.0 upwards. For more information about setting the testVersion, see Using the compatibility sniffs in the readme.
    • โœ… :umbrella: Unit test for multi-line short arrays for the ShortArray sniff. #347
    • โœ… :umbrella: Various additional unit tests against false positives. #345, #369
    • โœ… :umbrella: Unit tests for the supportsBelow(), supportsAbove() and getTestVersion() utility methods. #363
    • :books: Readme: information about installation of the standard using git check-out. #349
    • โœ… :books: Contributing.md file with information about reporting bugs, requesting features, making pull requests and running the unit tests. #350

    ๐Ÿ”„ Changed

    • :pushpin: The ForbiddenFunctionParametersWithSameName, NewScalarTypeDeclarations, ParameterShadowSuperGlobals sniff will now also sniff for and report violations in closures. #331
    • :twisted_rightwards_arrows: :rewind: The check for the PHP 5.3 nowdoc structure has been moved from the NewKeywords sniff to a new stand-alone NewNowdoc sniff which will now also recognize this structure when the sniffs are run on PHP 5.2. #335
    • :rewind: The ForbiddenNames sniff will now also correctly recognize reserved keywords used in a declared namespace when run on PHP 5.2. #362
    • ๐ŸŽ :recycle: Various (minor) refactoring for improved performance and sniff accuracy. #360
    • โœ… :recycle: 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 testVersion settings and makes the unit tests run ~6 x faster. Relevant additional unit tests have been added and others adjusted. #369
    • ๐Ÿ”จ :recycle: Refactoring/tidying up of some unit test code. #343, #345, #356, #355, #359
    • General housekeeping. #346
    • :books: Readme: Clarify minimum requirements and influence on the results. #348

    โœ‚ Removed

    • :twisted_rightwards_arrows: Removed the LongArrays sniff. The checks it contained have been moved into the RemovedGlobalVariables sniff. Both sniffs essentially did the same thing, just for different PHP native superglobals. #354

    ๐Ÿ›  Fixed

    • :bug: The PregReplaceEModifier sniff would throw a false positive if a quote character was used as the regex delimiter. #357
    • :bug: RemovedGlobalVariables sniff would report false positives for class properties shadowing the removed $HTTP_RAW_POST_DATA variables. #354.
    • :bug: 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
    • :bug: The determineNamespace() utility method would in certain cases not break out a loop. #358
    • :wrench: Travis script: Minor tweak for PHP 5.2 compatibility. #341
    • โœ… :wrench: The unit test suite is now also compatible with PHPUnit 6. #365
    • :books: Readme: Typo in the composer instructions. #344

    Credits

    Thanks go out to [Arthur Edamov], [Juliette Reinders Folmer], [Mark Clements] and [Tadas Juozapaitis] for their contributions to this version. :clap:

  • v7.1.2 Changes

    February 17, 2017

    ๐Ÿ‘€ See all related issues and PRs in the [7.1.2 milestone].

    โž• Added

    • ๐Ÿ›  :star2: New VariableVariables sniff to detect variables variables for which the behaviour has changed in PHP 7.0. #310 Fixes #309.
    • :star: The NewReturnTypeDeclarations sniff will now also sniff for non-scalar return type declarations, i.e. array, callable, self or a class name. #323
    • :star: The NewLanguageConstructs sniff will now also sniff for the null coalesce equal operator ??=. This operator is slated to be introduced in PHP 7.2 and PHPCS already accounts for it. #340
    • :star: New getReturnTypeHintToken() utility method to the PHPCompatibility_Sniff class to retrieve return type hints from function declarations in a cross-PHPCS-version compatible way. #323.
    • :star: New stripVariables() utility method to the PHPCompatibility_Sniff class to strip variables from interpolated text strings. #341.
    • โœ… :umbrella: Additional unit tests covering previously uncovered code. #308

    ๐Ÿ”„ Changed

    • :pushpin: The MbstringReplaceEModifier, PregReplaceEModifier and NewExecutionDirectives sniffs will now also correctly interpret double quoted text strings with interpolated variables. #341, #324.
    • :pushpin: The NewNullableTypes sniff will now also report on nullable (return) type hints when used with closures. #323
    • :pushpin: The NewReturnTypeDeclarations sniff will now also report on return type hints when used with closures. #323
    • :pushpin: Allow for anonymous classes in the inClassScope() utility method. #315
    • :pushpin: The function call parameter related utility functions can now also be used to get the individual items from an array declaration. #300
    • :twisted_rightwards_arrows: The NewScalarReturnTypeDeclarations sniff has been renamed to NewReturnTypeDeclarations. #323
    • :rewind: The ForbiddenNames sniff will now also correctly ignore anonymous classes when used in combination with PHPCS < 2.3.4. #319
    • :rewind: The NewAnonymousClasses sniff will now correctly recognize and report on anonymous classes when used in combination with PHPCS < 2.5.2. #325
    • :rewind: The NewGroupUseDeclarations sniff will now correctly recognize and report on group use statements when used in combination with PHPCS < 2.6.0. #320
    • :rewind: The NewNullableTypes sniff will now correctly recognize and report on nullable return types when used in combination with PHPCS < 2.6.0. #323
    • :rewind: The NewReturnTypeDeclarations sniff will now correctly recognize and report on new return types when used in combination with PHPCS < 2.6.0. #323
    • ๐ŸŽ :recycle: Various (minor) refactoring for improved performance and sniff accuracy. #317
    • :recycle: Defer to upstream hasCondition() utility method where appropriate. #315
    • ๐Ÿ”จ :recycle: Minor refactoring of some unit test code. #304, #303, #318
    • โœ… :wrench: All unit tests now have appropriate @group annotations allowing for quicker/easier testing of a select group of tests/sniffs. #305
    • ๐Ÿšš :wrench: All unit tests now have appropriate @covers annotations to improve code coverage reporting and remove bleed through of accidental coverage. #307
    • :wrench: Minor tweaks to the travis script. #322
    • ๐Ÿ— :green_heart: The PHPCompatibility code base itself will now be checked for cross-version compatibility during build testing. #322

    ๐Ÿ›  Fixed

    • :bug: The ConstantArraysUsingDefine sniff would throw false positives if the value of the define() was retrieved via a function call and an array parameter was passed. #327
    • ๐Ÿ›  :bug: The ForbiddenCallTimePassByReference sniff would throw false positives on assign by reference within function calls or conditions. #302 Fixes the last two cases reported in #68
    • :bug: The ForbiddenGlobalVariableVariableSniff sniff would only examine the first variable in a global ... statement causing unreported issues if subsequent variables were variable variables. #316
    • :bug: The NewKeywords sniff would throw a false positive for the const keyword when encountered in an interface. #312
    • :bug: The NewNullableTypes sniff would not report on nullable return types for namespaced classnames used as a type hint. #323
    • :bug: The PregReplaceEModifier sniff would always consider the first parameter passed as a single regex, while it could also be an array of regexes. This led to false positives and potentially unreported use of the e modifier when an array of regexes was passed. #300
    • :bug: The PregReplaceEModifier sniff could misidentify the regex delimiter when the regex to be examined was concatenated together from various text strings taken from a compound parameter leading to false positives. #300
    • :white_check_mark: Compatibility with PHPCS 2.7.x. Deal with changed behaviour of the upstream PHP tokenizer and utility function(s). #313, #323, #326, #340

    Credits

    Thanks go out to [Juliette Reinders Folmer] for her contributions to this version. :clap:

  • v7.1.1 Changes

    December 14, 2016

    ๐Ÿ‘€ See all related issues and PRs in the [7.1.1 milestone].

    โž• Added

    • :star: ForbiddenNamesAsDeclared sniff: detection of the PHP 7.1 iterable and void reserved keywords when used to name classes, interfaces or traits. #298

    ๐Ÿ›  Fixed

    • ๐Ÿ‘ฏ :bug: The ForbiddenNamesAsInvokedFunctions sniff would incorrectly throw an error if the clone keyword was used with parenthesis. #299. Fixes #284

    Credits

    Thanks go out to [Juliette Reinders Folmer] for her contributions to this version. :clap:

  • v7.1.0 Changes

    December 14, 2016

    ๐Ÿ‘€ See all related issues and PRs in the [7.1.0 milestone].

    โž• Added

    • :star: New stringToErrorCode(), arrayKeysToLowercase() and addMessage() utility methods to the PHPCompatibility_Sniff class. #291.

    ๐Ÿ”„ Changed

    • :pushpin: 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
    • :pencil2: Minor changes to some of the error message texts for consistency across sniffs. #291
    • ๐Ÿ”จ :recycle: Refactored the complex version sniffs to reduce code duplication. #291
    • ๐ŸŽ :recycle: Miscellaneous other refactoring for improved performance and sniff accuracy. #291
    • ๐Ÿšš :umbrella: The unit tests for the RemovedExtensions sniff now verify that the correct alternative extension is being suggested. #291

    Credits

    Thanks go out to [Juliette Reinders Folmer] for her contributions to this version. :clap: