Skip to content

Releases: PHPCompatibility/PHPCompatibility

PHPCompatibility 8.2.0

17 Jul 14:32
eaf613c
Compare
Choose a tag to compare

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

Read more

PHPCompatibility 8.1.0

27 Dec 22:00
4ac01e4
Compare
Choose a tag to compare

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. πŸ‘

PHPCompatibility 8.0.1 - warning: breaking changes in 8.0.0 !

07 Aug 19:44
Compare
Choose a tag to compare

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. πŸ‘

PHPCompatibility 8.0.0 - warning: breaking changes !

02 Aug 23:05
Compare
Choose a tag to compare

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

  1. First run phpcs --config-show to check which path(s) are currently registered with PHP CodeSniffer for external standards.

  2. 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 path/to/dir/abovePHPCompatibility/PHPCompatibility
    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.

  3. 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" />
  4. 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. πŸ‘

7.1.5: PHP 7.1 Sniffs - update 2017-07-17

16 Jul 23:13
Compare
Choose a tag to compare

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. πŸ‘

7.1.4: PHP 7.1 Sniffs - update 2017-05-06

06 May 19:33
Compare
Choose a tag to compare

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. πŸ‘

7.1.3: PHP 7.1 Sniffs - update 2017-04-02

02 Apr 23:46
Compare
Choose a tag to compare

Several updates for 7.1 (and some for 7.2)

See all related issues and PRs in the 7.1.3 milestone.

Added

  • ⚑ 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.
  • β˜” Unit test for multi-line short arrays for the ShortArray sniff. #347
  • β˜” Various additional unit tests against false positives. #345, #369
  • β˜” Unit tests for the supportsBelow(), supportsAbove() and getTestVersion() utility methods. #363
  • πŸ“š Readme: information about installation of the standard using git check-out. #349
  • πŸ“š Contributing.md file with information about reporting bugs, requesting features, making pull requests and running the unit tests. #350

Changed

  • πŸ“Œ The ForbiddenFunctionParametersWithSameName, NewScalarTypeDeclarations, ParameterShadowSuperGlobals sniff will now also sniff for and report violations in closures. #331
  • πŸ”€ βͺ 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
  • βͺ The ForbiddenNames sniff 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 testVersion settings 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

  • πŸ”€ 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

  • πŸ› The PregReplaceEModifier sniff would throw a false positive if a quote character was used as the regex delimiter. #357
  • πŸ› RemovedGlobalVariables sniff would report false positives for class properties shadowing the removed $HTTP_RAW_POST_DATA variables. #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

Credits

Thanks go out to Arthur Edamov, Juliette Reinders Folmer, Mark Clements and Tadas Juozapaitis for their contributions to this version. πŸ‘

7.1.2: PHP 7.1 Sniffs - update 2017-02-17

17 Feb 17:38
Compare
Choose a tag to compare

Several updates for 7.1 (and some for 7.2)

See all related issues and PRs in the 7.1.2 milestone.

Added

  • 🌟 New VariableVariables sniff to detect variables variables for which the behaviour has changed in PHP 7.0. #310 Fixes #309.
  • ⭐ The NewReturnTypeDeclarations sniff will now also sniff for non-scalar return type declarations, i.e. array, callable, self or a class name. #323
  • ⭐ 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
  • ⭐ 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.
  • ⭐ New stripVariables() utility method to the PHPCompatibility_Sniff class to strip variables from interpolated text strings. #341.
  • β˜” Additional unit tests covering previously uncovered code. #308

Changed

  • πŸ“Œ The MbstringReplaceEModifier, PregReplaceEModifier and NewExecutionDirectives sniffs will now also correctly interpret double quoted text strings with interpolated variables. #341, #324.
  • πŸ“Œ The NewNullableTypes sniff will now also report on nullable (return) type hints when used with closures. #323
  • πŸ“Œ The NewReturnTypeDeclarations sniff 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 NewScalarReturnTypeDeclarations sniff has been renamed to NewReturnTypeDeclarations. #323
  • βͺ The ForbiddenNames sniff will now also correctly ignore anonymous classes when used in combination with PHPCS < 2.3.4. #319
  • βͺ The NewAnonymousClasses sniff will now correctly recognize and report on anonymous classes when used in combination with PHPCS < 2.5.2. #325
  • βͺ The NewGroupUseDeclarations sniff will now correctly recognize and report on group use statements when used in combination with PHPCS < 2.6.0. #320
  • βͺ The NewNullableTypes sniff will now correctly recognize and report on nullable return types when used in combination with PHPCS < 2.6.0. #323
  • βͺ The NewReturnTypeDeclarations sniff 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 @group annotations allowing for quicker/easier testing of a select group of tests/sniffs. #305
  • πŸ”§ All unit tests now have appropriate @covers annotations 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

Fixed

  • πŸ› 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
  • πŸ› 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
  • πŸ› The ForbiddenGlobalVariableVariableSniff sniff would only examine the first variable in a global ... statement causing unreported issues if subsequent variables were variable variables. #316
  • πŸ› The NewKeywords sniff would throw a false positive for the const keyword when encountered in an interface. #312
  • πŸ› The NewNullableTypes sniff would not report on nullable return types for namespaced classnames used as a type hint. #323
  • πŸ› 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
  • πŸ› 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
  • βœ… 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. πŸ‘

7.1.1: PHP 7.1 Sniffs - update 2016-12-14

14 Dec 00:46
Compare
Choose a tag to compare

All deprecations, new features, etc. for PHP 7.1

See all related issues and PRs in the 7.1.1 milestone.

Added

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

Fixed

  • πŸ› 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. πŸ‘

PHP 7.1 Sniffs

14 Dec 00:16
Compare
Choose a tag to compare

All deprecations, new features, etc. for PHP 7.1

See all related issues and PRs in the 7.1.0 milestone.

Added

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

Changed

  • πŸ“Œ 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 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. πŸ‘