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 organizationPHPCompatibility
.
โก๏ธ Composer users are advised to update theircomposer.json
. The dependency is now calledphpcompatibility/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 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
DiscouragedSwitchContinue
sniff to detectcontinue
targetting aswitch
control structure for whichE_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 detectreturn
statements within generators as introduced in PHP 7.0. #618 - ๐ฑ ๐ New
PCRENewModifiers
sniff to initially detect the newJ
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()
andunset()
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 ofself
/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.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 - ๐ฑ โญ๏ธ
NewHashAlgorithms
sniff: recognize the new hash algorithms which were added in PHP 7.1. #599 - ๐ฑ โญ๏ธ
NewInterfaces
sniff: check for the PHP 5.0Reflector
interface. #572 - ๐ฑ โญ๏ธ
OptionalRequiredFunctionParameters
sniff: detect missing$salt
parameter in calls to thecrypt()
function (PHP 5.6+). #605 - ๐ฑ โญ๏ธ
RequiredOptionalFunctionParameters
sniff: recognize that the$varname
parameter ofgetenv()
and the$scale
parameter ofbcscale()
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 thePHPCompatibility\Sniff
class. #578, #642 - ๐ฑ โญ๏ธ New
isNumber()
,isPositiveNumber()
andisNegativeNumber()
utility methods to thePHPCompatibility\Sniff
class. #610, #650 - ๐ฑ โญ๏ธ New
isShortList()
utility method to thePHPCompatibility\Sniff
class. #635 - ๐ฑ โญ๏ธ New
getCommandLineData()
method to thePHPCompatibility\PHPCSHelper
class to provide PHPCS cross-version compatible access to command line info at run time. #693 - ๐ฑ โญ๏ธ Duplicate of upstream
findEndOfStatement()
method to thePHPCompatibility\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 bephpcompatibility/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 theconst
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
andNewInterfaces
sniffs will now also report on new classes/interfaces when used as return type declarations. #578 - ๐ฑ ๐ The
NewScalarTypeDeclarations
sniff will now recognizeparent
as a valid type declaration.
๐ The sniff will now also throw an error about usingself
andparent
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 thePCRENewModifiers
sniff 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\Sniff
class to thePHPCompatibility\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 thePregReplaceEModifier
sniffs nowextend
the newAbstractFunctionCallParameterSniff
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 - wasForbidden
, nowRemoved
-. 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. ๐
- ๐ New