PHPCompatibility v8.2.0 Release Notes

Release Date: 2018-07-17 // almost 6 years ago
  • 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. ๐Ÿ‘