From 4bbd57e113fc1bbd1f77ecfd550cc87ae9a75d32 Mon Sep 17 00:00:00 2001 From: Mark Nielsen Date: Wed, 23 Aug 2017 15:53:29 -0700 Subject: [PATCH 1/2] Upgrade PHPCompatibility to 7.1.5 --- PHPCompatibility/.travis.yml | 20 +- .../AbstractRemovedFeatureSniff.php | 2 +- PHPCompatibility/CHANGELOG.md | 40 +- PHPCompatibility/CONTRIBUTING.md | 31 +- PHPCompatibility/LICENSE | 165 ++ PHPCompatibility/README.md | 32 +- PHPCompatibility/Sniff.php | 341 ++- .../Sniffs/PHP/CaseSensitiveKeywordsSniff.php | 14 +- .../PHP/ConstantArraysUsingConstSniff.php | 6 +- .../PHP/ConstantArraysUsingDefineSniff.php | 12 +- .../PHP/DefaultTimezoneRequiredSniff.php | 62 - .../Sniffs/PHP/DeprecatedFunctionsSniff.php | 1499 +++++----- .../PHP/DeprecatedIniDirectivesSniff.php | 100 +- .../PHP/DeprecatedNewReferenceSniff.php | 31 +- .../DeprecatedPHP4StyleConstructorsSniff.php | 32 +- .../Sniffs/PHP/EmptyNonVariableSniff.php | 11 +- ...ForbiddenBreakContinueOutsideLoopSniff.php | 7 +- ...denBreakContinueVariableArgumentsSniff.php | 10 +- .../ForbiddenCallTimePassByReferenceSniff.php | 35 +- .../ForbiddenClosureUseVariableNamesSniff.php | 122 +- .../PHP/ForbiddenEmptyListAssignmentSniff.php | 15 +- ...denFunctionParametersWithSameNameSniff.php | 14 +- .../ForbiddenGlobalVariableVariableSniff.php | 14 +- .../PHP/ForbiddenNamesAsDeclaredSniff.php | 15 +- .../ForbiddenNamesAsInvokedFunctionsSniff.php | 10 +- .../Sniffs/PHP/ForbiddenNamesSniff.php | 32 +- .../PHP/ForbiddenNegativeBitshiftSniff.php | 18 +- ...enSwitchWithMultipleDefaultBlocksSniff.php | 14 +- .../Sniffs/PHP/InternalInterfacesSniff.php | 14 +- .../Sniffs/PHP/LateStaticBindingSniff.php | 16 +- .../Sniffs/PHP/LongArraysSniff.php | 114 - .../PHP/MbstringReplaceEModifierSniff.php | 20 +- .../Sniffs/PHP/NewAnonymousClassesSniff.php | 22 +- .../PHP/NewArrayStringDereferencingSniff.php | 2 +- .../Sniffs/PHP/NewClassesSniff.php | 401 ++- .../Sniffs/PHP/NewClosureSniff.php | 20 +- .../Sniffs/PHP/NewConstVisibilitySniff.php | 12 +- .../PHP/NewExecutionDirectivesSniff.php | 86 +- .../NewFunctionArrayDereferencingSniff.php | 32 +- .../Sniffs/PHP/NewFunctionParametersSniff.php | 1440 +++++----- .../Sniffs/PHP/NewFunctionsSniff.php | 2472 ++++++++--------- .../PHP/NewGroupUseDeclarationsSniff.php | 18 +- .../Sniffs/PHP/NewHashAlgorithmsSniff.php | 12 +- .../Sniffs/PHP/NewHeredocInitializeSniff.php | 10 +- .../Sniffs/PHP/NewIniDirectivesSniff.php | 24 +- .../Sniffs/PHP/NewInterfacesSniff.php | 138 +- .../Sniffs/PHP/NewKeywordsSniff.php | 209 +- .../Sniffs/PHP/NewLanguageConstructsSniff.php | 146 +- .../Sniffs/PHP/NewMagicClassConstantSniff.php | 64 +- .../Sniffs/PHP/NewMagicMethodsSniff.php | 92 +- .../Sniffs/PHP/NewMultiCatchSniff.php | 12 +- .../PHP/NewNowdocQuotedHeredocSniff.php | 13 +- .../Sniffs/PHP/NewNullableTypesSniff.php | 14 +- .../PHP/NewReturnTypeDeclarationsSniff.php | 90 +- .../PHP/NewScalarTypeDeclarationsSniff.php | 98 +- .../Sniffs/PHP/NonStaticMagicMethodsSniff.php | 4 +- .../PHP/ParameterShadowSuperGlobalsSniff.php | 29 +- .../Sniffs/PHP/PregReplaceEModifierSniff.php | 21 +- .../PHP/RemovedAlternativePHPTagsSniff.php | 39 +- .../Sniffs/PHP/RemovedExtensionsSniff.php | 133 +- .../PHP/RemovedFunctionParametersSniff.php | 78 +- .../PHP/RemovedGlobalVariablesSniff.php | 12 +- ...equiredOptionalFunctionParametersSniff.php | 52 +- .../Sniffs/PHP/ShortArraySniff.php | 24 +- .../Sniffs/PHP/TernaryOperatorsSniff.php | 3 +- .../Sniffs/PHP/ValidIntegersSniff.php | 47 +- .../Sniffs/PHP/VariableVariablesSniff.php | 27 +- .../DoesFunctionCallHaveParametersTest.php | 4 +- .../Tests/BaseClass/FunctionsTest.php | 80 +- ...GetFQClassNameFromDoubleColonTokenTest.php | 4 +- .../GetFQClassNameFromNewTokenTest.php | 4 +- .../BaseClass/GetFQExtendedClassNameTest.php | 4 +- .../GetFunctionParameterCountTest.php | 4 +- .../BaseClass/GetFunctionParametersTest.php | 468 ++-- .../Tests/BaseClass/IsClassConstantTest.php | 4 +- .../Tests/BaseClass/IsClassPropertyTest.php | 4 +- .../Tests/BaseClass/MethodTestFrame.php | 20 +- .../BaseClass/TestHelperPHPCompatibility.php | 27 +- ...kenHasScopeTest.php => TokenScopeTest.php} | 12 +- PHPCompatibility/Tests/BaseSniffTest.php | 81 +- .../ConstantArraysUsingDefineSniffTest.php | 4 +- .../PHP/DefaultTimezoneRequiredSniffTest.php | 55 - .../PHP/DeprecatedFunctionsSniffTest.php | 42 +- .../PHP/DeprecatedIniDirectivesSniffTest.php | 16 +- .../PHP/DeprecatedNewReferenceSniffTest.php | 6 +- ...precatedPHP4StyleConstructorsSniffTest.php | 4 +- ...reakContinueVariableArgumentsSniffTest.php | 9 +- ...biddenCallTimePassByReferenceSniffTest.php | 4 +- .../ForbiddenEmptyListAssignmentSniffTest.php | 4 +- ...unctionParametersWithSameNameSniffTest.php | 4 +- ...rbiddenGlobalVariableVariableSniffTest.php | 7 +- ...biddenNamesAsInvokedFunctionsSniffTest.php | 4 +- .../Sniffs/PHP/ForbiddenNamesSniffTest.php | 10 +- .../ForbiddenNegativeBitshiftSniffTest.php | 4 +- ...itchWithMultipleDefaultBlocksSniffTest.php | 4 +- .../PHP/InternalInterfacesSniffTest.php | 16 +- .../Tests/Sniffs/PHP/LongArraysSniffTest.php | 121 - .../PHP/NewAnonymousClassesSniffTest.php | 4 +- .../Tests/Sniffs/PHP/NewClassesSniffTest.php | 14 +- .../Tests/Sniffs/PHP/NewClosureSniffTest.php | 4 +- .../PHP/NewExecutionDirectivesSniffTest.php | 12 +- ...NewFunctionArrayDereferencingSniffTest.php | 4 +- .../PHP/NewFunctionParameterSniffTest.php | 206 -- .../PHP/NewFunctionParametersSniffTest.php | 4 +- .../Sniffs/PHP/NewFunctionsSniffTest.php | 8 +- .../PHP/NewGroupUseDeclarationsSniffTest.php | 4 +- .../Sniffs/PHP/NewHashAlgorithmSniffTest.php | 102 - .../Sniffs/PHP/NewHashAlgorithmsSniffTest.php | 2 +- .../Sniffs/PHP/NewIniDirectivesSniffTest.php | 8 +- .../Tests/Sniffs/PHP/NewKeywordsSniffTest.php | 74 +- .../PHP/NewLanguageConstructsSniffTest.php | 4 +- .../PHP/NewMagicClassConstantSniffTest.php | 63 +- .../Sniffs/PHP/NewMagicMethodsSniffTest.php | 2 +- .../NewReturnTypeDeclarationsSniffTest.php | 4 +- .../NewScalarTypeDeclarationsSniffTest.php | 15 +- .../PHP/NewUseConstFunctionSniffTest.php | 3 +- .../PHP/NonStaticMagicMethodsSniffTest.php | 4 +- .../PHP/PregReplaceEModifierSniffTest.php | 8 +- .../PHP/RemovedAlternativePHPTagsUnitTest.php | 170 -- .../Sniffs/PHP/RemovedExtensionsSniffTest.php | 24 +- .../PHP/RemovedFunctionParameterSniffTest.php | 152 - .../RemovedFunctionParametersSniffTest.php | 4 +- .../PHP/RemovedGlobalVariablesSniffTest.php | 4 +- .../PHP/RemovedHashAlgorithmsSniffTest.php | 6 +- ...iredOptionalFunctionParameterSniffTest.php | 98 - .../Tests/Sniffs/PHP/ShortArraySniffTest.php | 9 +- .../Sniffs/PHP/TernaryOperatorsSniffTest.php | 4 +- PHPCompatibility/Tests/bootstrap.php | 4 +- .../sniff-examples/deprecated_functions.php | 1 + .../deprecated_new_reference.php | 2 + ...idden_break_continue_variable_argument.php | 14 + .../forbidden_global_variable_variable.php | 3 + .../forbidden_names_correct_usage_use.php | 8 - .../Tests/sniff-examples/long_arrays.php | 45 - .../Tests/sniff-examples/new_keywords.php | 7 + .../new_magic_class_constant.php | 7 +- .../Tests/sniff-examples/timezone.php | 4 - PHPCompatibility/composer.json | 5 +- PHPCompatibility/phpcs.xml | 71 + 139 files changed, 5169 insertions(+), 5816 deletions(-) create mode 100644 PHPCompatibility/LICENSE delete mode 100644 PHPCompatibility/Sniffs/PHP/DefaultTimezoneRequiredSniff.php delete mode 100644 PHPCompatibility/Sniffs/PHP/LongArraysSniff.php rename PHPCompatibility/Tests/BaseClass/{TokenHasScopeTest.php => TokenScopeTest.php} (94%) delete mode 100644 PHPCompatibility/Tests/Sniffs/PHP/DefaultTimezoneRequiredSniffTest.php delete mode 100644 PHPCompatibility/Tests/Sniffs/PHP/LongArraysSniffTest.php delete mode 100644 PHPCompatibility/Tests/Sniffs/PHP/NewFunctionParameterSniffTest.php delete mode 100644 PHPCompatibility/Tests/Sniffs/PHP/NewHashAlgorithmSniffTest.php delete mode 100644 PHPCompatibility/Tests/Sniffs/PHP/RemovedAlternativePHPTagsUnitTest.php delete mode 100644 PHPCompatibility/Tests/Sniffs/PHP/RemovedFunctionParameterSniffTest.php delete mode 100644 PHPCompatibility/Tests/Sniffs/PHP/RequiredOptionalFunctionParameterSniffTest.php delete mode 100644 PHPCompatibility/Tests/sniff-examples/forbidden_names_correct_usage_use.php delete mode 100644 PHPCompatibility/Tests/sniff-examples/long_arrays.php delete mode 100644 PHPCompatibility/Tests/sniff-examples/timezone.php diff --git a/PHPCompatibility/.travis.yml b/PHPCompatibility/.travis.yml index 16c214f4..cf76ff92 100644 --- a/PHPCompatibility/.travis.yml +++ b/PHPCompatibility/.travis.yml @@ -56,16 +56,25 @@ matrix: - php: nightly env: PHPCS_VERSION="2.9.x-dev" + - php: hhvm + dist: trusty + env: PHPCS_VERSION=">=1.5.1,<2.0" + - php: hhvm + dist: trusty + env: PHPCS_VERSION="2.9.x-dev" + allow_failures: # Allow failures for unstable builds. - php: nightly + - php: hhvm before_install: - export XMLLINT_INDENT=" " # PHP 5.3+: set up test environment using Composer. - if [[ $TRAVIS_PHP_VERSION > "5.2" ]]; then composer self-update; fi - - if [[ $TRAVIS_PHP_VERSION > "5.2" && $TRAVIS_PHP_VERSION != "nightly" ]]; then composer require --dev satooshi/php-coveralls:${COVERALLS_VERSION}; fi + - if [[ $TRAVIS_PHP_VERSION > "5.2" && $COVERALLS_VERSION ]]; then composer require --dev satooshi/php-coveralls:${COVERALLS_VERSION};fi - if [[ $TRAVIS_PHP_VERSION > "5.2" ]]; then composer require squizlabs/php_codesniffer:${PHPCS_VERSION}; fi + - if [[ $TRAVIS_PHP_VERSION == hhv* ]]; then composer require phpunit/phpunit:~4.0; fi - if [[ $TRAVIS_PHP_VERSION > "5.2" ]]; then composer install; fi # PHP 5.2: set up test environment using git cloning. - if [[ $TRAVIS_PHP_VERSION < "5.3" ]]; then export PHPCS_DIR=/tmp/phpcs; fi @@ -74,7 +83,7 @@ before_install: - if [[ $TRAVIS_PHP_VERSION < "5.3" ]]; then $PHPCS_BIN --config-set installed_paths "$(dirname "$(pwd)")"; fi before_script: - - if [[ $TRAVIS_PHP_VERSION > "5.2" && $TRAVIS_PHP_VERSION != "nightly" ]]; then mkdir -p build/logs; fi + - if [[ $COVERALLS_VERSION ]]; then mkdir -p build/logs; fi - phpenv rehash script: @@ -83,10 +92,11 @@ script: - if [[ $TRAVIS_PHP_VERSION > "5.2" ]]; then find -L . -path ./Tests/sniff-examples -prune -o -path ./vendor -prune -o -name '*.php' -print0 | xargs -0 -n 1 -P 4 php -l; fi - if [[ $TRAVIS_PHP_VERSION < "5.3" ]]; then find -L . -path ./Tests/sniff-examples -prune -o -path ./Tests/PHPUnit6Compat.php -prune -o -path ./vendor -prune -o -name '*.php' -print0 | xargs -0 -n 1 -P 4 php -l; fi # Check the code style of the code base. - - if [[ "$SNIFF" == "1" ]]; then vendor/bin/phpcs . --standard=./phpcs.xml; fi + - if [[ "$SNIFF" == "1" ]]; then vendor/bin/phpcs . --standard=./phpcs.xml --runtime-set ignore_warnings_on_exit 1; fi # Run the unit tests. - - if [[ $TRAVIS_PHP_VERSION > "5.2" && $TRAVIS_PHP_VERSION != "nightly" ]]; then phpunit --configuration phpunit-travis.xml --coverage-clover build/logs/clover.xml; fi + - if [[ $COVERALLS_VERSION ]]; then phpunit --configuration phpunit-travis.xml --coverage-clover build/logs/clover.xml; fi - if [[ $TRAVIS_PHP_VERSION == "5.2" || $TRAVIS_PHP_VERSION == "nightly" ]]; then phpunit --configuration phpunit.xml; fi + - if [[ $TRAVIS_PHP_VERSION == hhv* ]]; then vendor/bin/phpunit --configuration phpunit.xml; fi # Validate the xml file. # @link http://xmlsoft.org/xmllint.html - if [[ "$SNIFF" == "1" ]]; then xmllint --noout ./ruleset.xml; fi @@ -94,4 +104,4 @@ script: - if [[ "$SNIFF" == "1" ]]; then diff -B ./ruleset.xml <(xmllint --format "./ruleset.xml"); fi after_success: - - if [[ $TRAVIS_PHP_VERSION > "5.2" && $TRAVIS_PHP_VERSION != "nightly" ]]; then php vendor/bin/coveralls -v -x build/logs/clover.xml; fi + - if [[ $COVERALLS_VERSION ]]; then php vendor/bin/coveralls -v -x build/logs/clover.xml; fi diff --git a/PHPCompatibility/AbstractRemovedFeatureSniff.php b/PHPCompatibility/AbstractRemovedFeatureSniff.php index 958b1618..9761d770 100644 --- a/PHPCompatibility/AbstractRemovedFeatureSniff.php +++ b/PHPCompatibility/AbstractRemovedFeatureSniff.php @@ -69,7 +69,7 @@ public function getErrorInfo(array $itemArray, array $itemInfo) if ($removed === true && $errorInfo['removed'] === '') { $errorInfo['removed'] = $version; $errorInfo['error'] = true; - } else if ($errorInfo['deprecated'] === '') { + } elseif ($errorInfo['deprecated'] === '') { $errorInfo['deprecated'] = $version; } } diff --git a/PHPCompatibility/CHANGELOG.md b/PHPCompatibility/CHANGELOG.md index 179ed05f..4f9be4e0 100644 --- a/PHPCompatibility/CHANGELOG.md +++ b/PHPCompatibility/CHANGELOG.md @@ -13,6 +13,42 @@ The `patch` version numbers are specific to this library. _Nothing yet._ +## [7.1.5] - 2017-07-17 + +See all related issues and PRs in the [7.1.5 milestone]. + +### Added +- :star: The `NewKeywords` sniff will now also sniff for `yield from` which was introduced in PHP 7.0. [#477](https://github.com/wimg/PHPCompatibility/pull/477). Fixes [#476](https://github.com/wimg/PHPCompatibility/issues/476) +- :books: The LGPL-3.0 license. [#447](https://github.com/wimg/PHPCompatibility/pull/447) + +### Changed +- :rewind: The `NewExecutionDirectives` sniff will now also report on execution directives when used in combination with PHPCS 2.0.0-2.3.3. [#451](https://github.com/wimg/PHPCompatibility/pull/451) +- :rewind: 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](https://github.com/wimg/PHPCompatibility/pull/452) +- :rewind: 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](https://github.com/wimg/PHPCompatibility/pull/454) +- :recycle: Various (minor) refactoring for improved performance and sniff accuracy. [#443](https://github.com/wimg/PHPCompatibility/pull/443), [#474](https://github.com/wimg/PHPCompatibility/pull/474) +- :pencil2: Renamed a test file for consistency. [#453](https://github.com/wimg/PHPCompatibility/pull/453) +- :wrench: Code style clean up. [#429](https://github.com/wimg/PHPCompatibility/pull/429) +- :wrench: 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](https://github.com/wimg/PHPCompatibility/pull/444) +- :green_heart: The code base will now be checked for consistent code style during build testing. [#429](https://github.com/wimg/PHPCompatibility/pull/429) +- :green_heart: 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](https://github.com/wimg/PHPCompatibility/pull/450) +- :books: Made it explicit that - at this moment - PHPCS 3.x is not (yet) supported. [#444](https://github.com/wimg/PHPCompatibility/pull/444) +- :books: Minor improvements to the Readme. [#448](https://github.com/wimg/PHPCompatibility/pull/448), [#449](https://github.com/wimg/PHPCompatibility/pull/449), [#468](https://github.com/wimg/PHPCompatibility/pull/468) +- :books: Minor improvements to the Contributing guidelines. [#467](https://github.com/wimg/PHPCompatibility/pull/467) + +### Removed +- :no_entry_sign: The `DefaultTimeZoneRequired` sniff. This sniff was checking server settings rather than code. [#458](https://github.com/wimg/PHPCompatibility/pull/458). Fixes [#457](https://github.com/wimg/PHPCompatibility/issues/457) +- :no_entry_sign: 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](https://github.com/wimg/PHPCompatibility/pull/442). Fixes [#436](https://github.com/wimg/PHPCompatibility/issues/436) + +### Fixed +- :bug: `NewClass` sniff: was reporting an incorrect introduction version number for a few of the Exception classes. [#441](https://github.com/wimg/PHPCompatibility/pull/441). Fixes [#440](https://github.com/wimg/PHPCompatibility/issues/440). +- :bug: `ForbiddenBreakContinueVariableArguments` sniff: was incorrectly reporting an error if the `break` or `continue` was followed by a PHP closing tag (breaking out of PHP). [#462](https://github.com/wimg/PHPCompatibility/pull/462). Fixes [#460](https://github.com/wimg/PHPCompatibility/issues/460) +- :bug: `ForbiddenGlobalVariableVariable` sniff: was incorrectly reporting an error if the `global` statement was followed by a PHP closing tag (breaking out of PHP). [#463](https://github.com/wimg/PHPCompatibility/pull/463). +- :bug: `DeprecatedFunctions` sniff: was reporting false positives for classes using the same name as a deprecated function. [#465](https://github.com/wimg/PHPCompatibility/pull/465). Fixes [#464](https://github.com/wimg/PHPCompatibility/issues/464) + +### Credits +Thanks go out to [Juliette Reinders Folmer] and [Mark Clements] for their contributions to this version. :clap: + + ## [7.1.4] - 2017-05-06 See all related issues and PRs in the [7.1.4 milestone]. @@ -589,7 +625,8 @@ See all related issues and PRs in the [5.5 milestone]. -[Unreleased]: https://github.com/wimg/PHPCompatibility/compare/7.1.4...HEAD +[Unreleased]: https://github.com/wimg/PHPCompatibility/compare/7.1.5...HEAD +[7.1.5]: https://github.com/wimg/PHPCompatibility/compare/7.1.4...7.1.5 [7.1.4]: https://github.com/wimg/PHPCompatibility/compare/7.1.3...7.1.4 [7.1.3]: https://github.com/wimg/PHPCompatibility/compare/7.1.2...7.1.3 [7.1.2]: https://github.com/wimg/PHPCompatibility/compare/7.1.1...7.1.2 @@ -606,6 +643,7 @@ See all related issues and PRs in the [5.5 milestone]. [7.0]: https://github.com/wimg/PHPCompatibility/compare/5.6...7.0 [5.6]: https://github.com/wimg/PHPCompatibility/compare/5.5...5.6 +[7.1.5 milestone]: https://github.com/wimg/PHPCompatibility/milestone/17 [7.1.4 milestone]: https://github.com/wimg/PHPCompatibility/milestone/15 [7.1.3 milestone]: https://github.com/wimg/PHPCompatibility/milestone/14 [7.1.2 milestone]: https://github.com/wimg/PHPCompatibility/milestone/13 diff --git a/PHPCompatibility/CONTRIBUTING.md b/PHPCompatibility/CONTRIBUTING.md index e1fb5b42..dada4fcc 100644 --- a/PHPCompatibility/CONTRIBUTING.md +++ b/PHPCompatibility/CONTRIBUTING.md @@ -1,8 +1,10 @@ +Hi, thank you for your interest in contributing to PHPCompatibility! We look forward to working with you. + Reporting bugs -------------- Before reporting a bug, you should check what sniff an error is coming from. -Run `phpcs` with the `-s` flag will show the names of the sniffs with each error. +Running `phpcs` with the `-s` flag will show the names of the sniffs with each error. Bug reports containing a minimal code sample which can be used to reproduce the issue are highly appreciated as those are most easily actionable. @@ -18,12 +20,13 @@ Pull requests Contributions in the form of pull requests are very welcome. -To start contributing, fork the repository, create a new branch in your fork, make your intended changes and pull the branch aginst the `master` branch of this repository. +To start contributing, fork the repository, create a new branch in your fork, make your intended changes and pull the branch against the `master` branch of this repository. Please make sure that your pull request contains unit tests covering what's being addressed by it. All code should be compatible with PHPCS 1.5.6 and PHPCS 2.x. All code should be compatible with PHP 5.1 to PHP nightly. +All code should comply with the PHPCompatibility coding standards. The ruleset used by PHPCompatibility is largely based on PSR2 with minor variations and some additional checks for documentation and such. Running the Sniff Tests @@ -31,23 +34,26 @@ Running the Sniff Tests All the sniffs are fully tested with PHPUnit tests. In order to run the tests on the sniffs, the following installation steps are required. -1. Install the master branch of `PHP_CodeSniffer` - [https://github.com/squizlabs/PHP_CodeSniffer.git]. +1. Install the latest release from the `2.x` branch of [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer.git). + + This can be done with composer using the following command: - This can be done with composer by adding the following into - `~/.composer/composer.json`: + $ composer require "squizlabs/php_codesniffer=^2.0" + or by adding the following into `~/.composer/composer.json`: + ```json { "require": { - "phpunit/phpunit": "3.7.*", - "squizlabs/php_codesniffer": ">=2.0" + "phpunit/phpunit": ">=4.0", + "squizlabs/php_codesniffer": "^2.0" } } + ``` 2. Run the following command to compose in the versions indicated in the above global composer.json file: - $ composer.phar global install + $ composer global install 3. Update your system `$PATH` to include the globally composed files: @@ -58,11 +64,10 @@ on the sniffs, the following installation steps are required. $ ln -s /path/to/PHPCompatibility ~/.composer/vendor/squizlabs/php_codesniffer/CodeSniffer/Standards/PHPCompatibility -5. Verify standard is available with `phpcs -i`. The output should include - `PHPCompatibility` +5. Verify the standard is available with `phpcs -i`. The output should include `PHPCompatibility`. -6. Run the tests by running `phpunit` in the root directory of - PHPCompatibility. It will read the `phpunit.xml` file and execute the tests +6. Run the tests by running `phpunit` in the root directory of PHPCompatibility. + It will read the `phpunit.xml` file and execute the tests. #### Issues when running the PHPCS Unit tests for another standard diff --git a/PHPCompatibility/LICENSE b/PHPCompatibility/LICENSE new file mode 100644 index 00000000..65c5ca88 --- /dev/null +++ b/PHPCompatibility/LICENSE @@ -0,0 +1,165 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. diff --git a/PHPCompatibility/README.md b/PHPCompatibility/README.md index eb9c8715..18e236cb 100644 --- a/PHPCompatibility/README.md +++ b/PHPCompatibility/README.md @@ -1,11 +1,19 @@ PHP Compatibility Coding Standard for PHP_CodeSniffer ===================================================== +[![Latest Stable Version](https://poser.pugx.org/wimg/php-compatibility/v/stable.png)](https://packagist.org/packages/wimg/php-compatibility) +[![Latest Unstable Version](https://poser.pugx.org/wimg/php-compatibility/v/unstable.png)](https://packagist.org/packages/wimg/php-compatibility) +![Awesome](https://img.shields.io/badge/awesome%3F-yes!-brightgreen.svg) +[![License](https://poser.pugx.org/wimg/php-compatibility/license.png)](https://github.com/wimg/PHPCompatibility/blob/master/LICENSE) [![Flattr this git repo](http://api.flattr.com/button/flattr-badge-large.png)](https://flattr.com/submit/auto?user_id=wimg&url=https://github.com/wimg/PHPCompatibility&title=PHPCompatibility&language=&tags=github&category=software) + [![Build Status](https://travis-ci.org/wimg/PHPCompatibility.png?branch=master)](https://travis-ci.org/wimg/PHPCompatibility) +[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/wimg/PHPCompatibility/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/wimg/PHPCompatibility/) [![Coverage Status](https://coveralls.io/repos/github/wimg/PHPCompatibility/badge.svg?branch=master)](https://coveralls.io/github/wimg/PHPCompatibility?branch=master) -[![Latest Stable Version](https://poser.pugx.org/wimg/php-compatibility/v/stable.png)](https://packagist.org/packages/wimg/php-compatibility) -[![Latest Unstable Version](https://poser.pugx.org/wimg/php-compatibility/v/unstable.png)](https://packagist.org/packages/wimg/php-compatibility) -[![License](https://poser.pugx.org/wimg/php-compatibility/license.png)](https://packagist.org/packages/wimg/php-compatibility) +[![Dependency Status](https://www.versioneye.com/php/wimg:php-compatibility/badge)](https://www.versioneye.com/php/wimg:php-compatibility) + +[![Tested Runtime Badge](http://php-eye.com/badge/wimg/php-compatibility/tested.svg?branch=dev-master)](http://php-eye.com/package/wimg/php-compatibility) +[![Not Tested Runtime Badge](http://php-eye.com/badge/wimg/php-compatibility/not-tested.svg?branch=dev-master)](http://php-eye.com/package/wimg/php-compatibility) + This is a set of sniffs for [PHP_CodeSniffer](http://pear.php.net/PHP_CodeSniffer) that checks for PHP version compatibility. It will allow you to analyse your code for compatibility with higher and lower versions of PHP. @@ -21,15 +29,15 @@ Pull requests that check for compatibility issues in PHP4 code - in particular b Requirements ------- -The sniffs are designed to give the same results regardless of which PHP version you are using to run CodeSniffer. You should get reasonably consistent results independently of the PHP version used in your test environment, though for the best results it is recommended to run the sniffs on PHP 5.3 or higher. +The sniffs are designed to give the same results regardless of which PHP version you are using to run CodeSniffer. You should get reasonably consistent results independently of the PHP version used in your test environment, though for the best results it is recommended to run the sniffs on PHP 5.4 or higher. PHP CodeSniffer 1.5.1 is required for 90% of the sniffs, PHPCS 2.6 or later is required for full support, notices may be thrown on older versions. -The PHPCompatibility standard is currently not compatible with PHPCS 3.0, though the [intention is to fix this](https://github.com/wimg/PHPCompatibility/issues/367) in the near future. +**_The PHPCompatibility standard is currently not compatible with PHPCS 3.0, though the [intention is to fix this](https://github.com/wimg/PHPCompatibility/issues/367) in the near future._** Thank you --------- -Thanks to all contributors for their valuable contributions. +Thanks to all [contributors](https://github.com/wimg/PHPCompatibility/graphs/contributors) for their valuable contributions. [![WPEngine](https://cu.be/img/wpengine.png)](https://wpengine.com) @@ -39,7 +47,7 @@ Thanks to [WP Engine](https://wpengine.com) for their support on the PHP 7.0 sni Installation using PEAR (method 1) ----------------------- -* Install [PHP_CodeSniffer](http://pear.php.net/PHP_CodeSniffer) with `pear install PHP_CodeSniffer`. +* Install [PHP_CodeSniffer](http://pear.php.net/PHP_CodeSniffer) with `pear install PHP_CodeSniffer-2.9.0`. * Checkout the latest release from https://github.com/wimg/PHPCompatibility/releases into the `PHP/CodeSniffer/Standards/PHPCompatibility` directory. @@ -50,7 +58,7 @@ Installation in Composer project (method 2) ```json "require-dev": { - "squizlabs/php_codesniffer": "*", + "squizlabs/php_codesniffer": "^2.0", "wimg/php-compatibility": "*", "simplyadmire/composer-plugins" : "@dev" }, @@ -64,7 +72,7 @@ Installation in Composer project (method 2) Installation via a git check-out to an arbitrary directory (method 3) ----------------------- -* Install [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) via [your preferred method](https://github.com/squizlabs/PHP_CodeSniffer#installation) (Composer, PEAR, Phar file, Git checkout). +* Install the latest `2.x` version of [PHP_CodeSniffer](https://github.com/squizlabs/PHP_CodeSniffer) via [your preferred method](https://github.com/squizlabs/PHP_CodeSniffer#installation) (Composer, PEAR, Phar file, Git checkout). * Checkout the latest release from https://github.com/wimg/PHPCompatibility/releases into an arbitrary directory. * Add the path to the directory **_above_** the directory in which you cloned the PHPCompability repo to the PHPCS configuration using the below command. ```bash @@ -80,10 +88,10 @@ Installation via a git check-out to an arbitrary directory (method 3) Using the compatibility sniffs ------------------------------ -* Use the coding standard with `phpcs --standard=PHPCompatibility` +* Run the coding standard from the command-line with `phpcs --standard=PHPCompatibility` * You can specify which PHP version you want to test against by specifying `--runtime-set testVersion 5.5`. -* You can also specify a range of PHP versions that your code needs to support. In this situation, compatibility issues that affect any of the PHP versions in that range will be reported: -`--runtime-set testVersion 5.3-5.5`. You can omit one or other part of the range if you want to support everything above/below a particular version (e.g. `--runtime-set testVersion 7.0-` to support PHP 7 and above). +* You can also specify a range of PHP versions that your code needs to support. In this situation, compatibility issues that affect any of the PHP versions in that range will be reported: `--runtime-set testVersion 5.3-5.5`. + You can omit one or other part of the range if you want to support everything above/below a particular version, i.e. `--runtime-set testVersion 7.0-` to support PHP 7 and above. More information can be found on Wim Godden's [blog](http://techblog.wimgodden.be/tag/codesniffer). diff --git a/PHPCompatibility/Sniff.php b/PHPCompatibility/Sniff.php index a561ec4c..9aca2861 100644 --- a/PHPCompatibility/Sniff.php +++ b/PHPCompatibility/Sniff.php @@ -2,8 +2,6 @@ /** * PHPCompatibility_Sniff. * - * PHP version 5.6 - * * @category PHP * @package PHPCompatibility * @author Wim Godden @@ -16,7 +14,6 @@ * @category PHP * @package PHPCompatibility * @author Wim Godden - * @version 1.1.0 * @copyright 2014 Cu.be Solutions bvba */ abstract class PHPCompatibility_Sniff implements PHP_CodeSniffer_Sniff @@ -40,7 +37,7 @@ abstract class PHPCompatibility_Sniff implements PHP_CodeSniffer_Sniff '$_COOKIE', '$_SESSION', '$_REQUEST', - '$_ENV' + '$_ENV', ); /** @@ -106,46 +103,47 @@ private function getTestVersion() $testVersion = trim(PHP_CodeSniffer::getConfigData('testVersion')); - if (!isset($arrTestVersions[$testVersion]) && !empty($testVersion)) { + if (isset($arrTestVersions[$testVersion]) === false && empty($testVersion) === false) { $arrTestVersions[$testVersion] = array(null, null); if (preg_match('/^\d+\.\d+$/', $testVersion)) { $arrTestVersions[$testVersion] = array($testVersion, $testVersion); - } - elseif (preg_match('/^(\d+\.\d+)\s*-\s*(\d+\.\d+)$/', $testVersion, - $matches)) - { + + } elseif (preg_match('/^(\d+\.\d+)\s*-\s*(\d+\.\d+)$/', $testVersion, $matches)) { if (version_compare($matches[1], $matches[2], '>')) { - trigger_error("Invalid range in testVersion setting: '" - . $testVersion . "'", E_USER_WARNING); - } - else { + trigger_error( + "Invalid range in testVersion setting: '" . $testVersion . "'", + E_USER_WARNING + ); + + } else { $arrTestVersions[$testVersion] = array($matches[1], $matches[2]); } - } - elseif (preg_match('/^\d+\.\d+-$/', $testVersion)) { + + } elseif (preg_match('/^\d+\.\d+-$/', $testVersion)) { // If no upper-limit is set, we set the max version to 99.9. // This is *probably* safe... :-) $arrTestVersions[$testVersion] = array(substr($testVersion, 0, -1), '99.9'); - } - elseif (preg_match('/^-\d+\.\d+$/', $testVersion)) { + + } elseif (preg_match('/^-\d+\.\d+$/', $testVersion)) { // If no lower-limit is set, we set the min version to 4.0. // Whilst development focuses on PHP 5 and above, we also accept // sniffs for PHP 4, so we include that as the minimum. // (It makes no sense to support PHP 3 as this was effectively a // different language). $arrTestVersions[$testVersion] = array('4.0', substr($testVersion, 1)); - } - elseif (!$testVersion == '') { - trigger_error("Invalid testVersion setting: '" . $testVersion - . "'", E_USER_WARNING); + + } elseif ($testVersion !== '') { + trigger_error( + "Invalid testVersion setting: '" . $testVersion . "'", + E_USER_WARNING + ); } } if (isset($arrTestVersions[$testVersion])) { return $arrTestVersions[$testVersion]; - } - else { + } else { return array(null, null); } } @@ -195,7 +193,7 @@ public function supportsBelow($phpVersion) $testVersion = $this->getTestVersion(); $testVersion = $testVersion[0]; - if (!is_null($testVersion) + if (is_null($testVersion) === false && version_compare($testVersion, $phpVersion) <= 0 ) { return true; @@ -255,7 +253,8 @@ public function stringToErrorCode($baseString) * * @return string String without quotes around it. */ - public function stripQuotes($string) { + public function stripQuotes($string) + { return preg_replace('`^([\'"])(.*)\1$`Ds', '$2', $string); } @@ -269,12 +268,13 @@ public function stripQuotes($string) { * * @return string String without variables in it. */ - public function stripVariables($string) { + public function stripVariables($string) + { if (strpos($string, '$') === false) { return $string; } - return preg_replace( self::REGEX_COMPLEX_VARS, '', $string ); + return preg_replace(self::REGEX_COMPLEX_VARS, '', $string); } @@ -340,11 +340,11 @@ public function findImplementedInterfaceNames(PHP_CodeSniffer_File $phpcsFile, $ } $find = array( - T_NS_SEPARATOR, - T_STRING, - T_WHITESPACE, - T_COMMA, - ); + T_NS_SEPARATOR, + T_STRING, + T_WHITESPACE, + T_COMMA, + ); $end = $phpcsFile->findNext($find, ($implementsIndex + 1), ($classOpenerIndex + 1), true); $name = $phpcsFile->getTokensAsString(($implementsIndex + 1), ($end - $implementsIndex - 1)); @@ -403,8 +403,7 @@ public function doesFunctionCallHaveParameters(PHP_CodeSniffer_File $phpcsFile, if ($nextNonEmpty === $tokens[$stackPtr]['bracket_closer']) { // No parameters. return false; - } - else { + } else { return true; } } @@ -472,8 +471,8 @@ public function getFunctionCallParameterCount(PHP_CodeSniffer_File $phpcsFile, $ * Extra feature: If passed an T_ARRAY or T_OPEN_SHORT_ARRAY stack pointer, * it will tokenize the values / key/value pairs contained in the array call. * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the function call token. + * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the function call token. * * @return array */ @@ -493,8 +492,8 @@ public function getFunctionCallParameters(PHP_CodeSniffer_File $phpcsFile, $stac $closer = $tokens[$stackPtr]['bracket_closer']; $nestedParenthesisCount = 0; - } - else { + + } else { $opener = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, $stackPtr + 1, null, true, null, true); $closer = $tokens[$opener]['parenthesis_closer']; @@ -510,14 +509,12 @@ public function getFunctionCallParameters(PHP_CodeSniffer_File $phpcsFile, $stac $nextComma = $opener; $paramStart = $opener + 1; $cnt = 1; - while ($nextComma = $phpcsFile->findNext(array(T_COMMA, $tokens[$closer]['code'], T_OPEN_SHORT_ARRAY), $nextComma + 1, $closer + 1)) { + while (($nextComma = $phpcsFile->findNext(array(T_COMMA, $tokens[$closer]['code'], T_OPEN_SHORT_ARRAY), $nextComma + 1, $closer + 1)) !== false) { // Ignore anything within short array definition brackets. - if ( - $tokens[$nextComma]['type'] === 'T_OPEN_SHORT_ARRAY' - && - ( isset($tokens[$nextComma]['bracket_opener']) && $tokens[$nextComma]['bracket_opener'] === $nextComma ) - && - isset($tokens[$nextComma]['bracket_closer']) + if ($tokens[$nextComma]['type'] === 'T_OPEN_SHORT_ARRAY' + && (isset($tokens[$nextComma]['bracket_opener']) + && $tokens[$nextComma]['bracket_opener'] === $nextComma) + && isset($tokens[$nextComma]['bracket_closer']) ) { // Skip forward to the end of the short array definition. $nextComma = $tokens[$nextComma]['bracket_closer']; @@ -525,12 +522,9 @@ public function getFunctionCallParameters(PHP_CodeSniffer_File $phpcsFile, $stac } // Ignore comma's at a lower nesting level. - if ( - $tokens[$nextComma]['type'] === 'T_COMMA' - && - isset($tokens[$nextComma]['nested_parenthesis']) - && - count($tokens[$nextComma]['nested_parenthesis']) !== $nestedParenthesisCount + if ($tokens[$nextComma]['type'] === 'T_COMMA' + && isset($tokens[$nextComma]['nested_parenthesis']) + && count($tokens[$nextComma]['nested_parenthesis']) !== $nestedParenthesisCount ) { continue; } @@ -584,8 +578,7 @@ public function getFunctionCallParameter(PHP_CodeSniffer_File $phpcsFile, $stack if (isset($parameters[$paramOffset]) === false) { return false; - } - else { + } else { return $parameters[$paramOffset]; } } @@ -677,7 +670,7 @@ public function inUseScope(PHP_CodeSniffer_File $phpcsFile, $stackPtr) static $isLowPHPCS, $ignoreTokens; if (isset($isLowPHPCS) === false) { - $isLowPHPCS = version_compare(PHP_CodeSniffer::VERSION, '2.0', '<'); + $isLowPHPCS = version_compare(PHP_CodeSniffer::VERSION, '2.3.0', '<'); } if (isset($ignoreTokens) === false) { $ignoreTokens = PHP_CodeSniffer_Tokens::$emptyTokens; @@ -745,11 +738,11 @@ public function getFQClassNameFromNewToken(PHP_CodeSniffer_File $phpcsFile, $sta } $find = array( - T_NS_SEPARATOR, - T_STRING, - T_NAMESPACE, - T_WHITESPACE, - ); + T_NS_SEPARATOR, + T_STRING, + T_NAMESPACE, + T_WHITESPACE, + ); $end = $phpcsFile->findNext($find, ($start + 1), null, true, null, true); $className = $phpcsFile->getTokensAsString($start, ($end - $start)); @@ -837,17 +830,18 @@ public function getFQClassNameFromDoubleColonToken(PHP_CodeSniffer_File $phpcsFi } $find = array( - T_NS_SEPARATOR, - T_STRING, - T_NAMESPACE, - T_WHITESPACE, - ); + T_NS_SEPARATOR, + T_STRING, + T_NAMESPACE, + T_WHITESPACE, + ); - $start = ($phpcsFile->findPrevious($find, $stackPtr - 1, null, true, null, true) + 1); - if ($start === false) { + $start = $phpcsFile->findPrevious($find, $stackPtr - 1, null, true, null, true); + if ($start === false || isset($tokens[($start + 1)]) === false) { return ''; } + $start = ($start + 1); $className = $phpcsFile->getTokensAsString($start, ($stackPtr - $start)); $className = trim($className); @@ -869,7 +863,7 @@ public function getFQClassNameFromDoubleColonToken(PHP_CodeSniffer_File $phpcsFi */ public function getFQName(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $name) { - if (strpos($name, '\\' ) === 0) { + if (strpos($name, '\\') === 0) { // Already fully qualified. return $name; } @@ -883,8 +877,7 @@ public function getFQName(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $name) if ($namespace === '') { return '\\' . $name; - } - else { + } else { return '\\' . $namespace . '\\' . $name; } } @@ -894,11 +887,12 @@ public function getFQName(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $name) * Is the class/function/constant name namespaced or global ? * * @param string $FQName Fully Qualified name of a class, function etc. - * I.e. should always start with a `\` ! + * I.e. should always start with a `\`. * * @return bool True if namespaced, false if global. */ - public function isNamespaced($FQName) { + public function isNamespaced($FQName) + { if (strpos($FQName, '\\') !== 0) { throw new PHP_CodeSniffer_Exception('$FQName must be a fully qualified name'); } @@ -927,7 +921,7 @@ public function determineNamespace(PHP_CodeSniffer_File $phpcsFile, $stackPtr) // Check for scoped namespace {}. if (empty($tokens[$stackPtr]['conditions']) === false) { $namespacePtr = $phpcsFile->getCondition($stackPtr, T_NAMESPACE); - if ($namespacePtr !== false ) { + if ($namespacePtr !== false) { $namespace = $this->getDeclaredNamespaceName($phpcsFile, $namespacePtr); if ($namespace !== false) { return $namespace; @@ -962,8 +956,7 @@ public function determineNamespace(PHP_CodeSniffer_File $phpcsFile, $stackPtr) // If we still haven't got a namespace, return an empty string. if ($namespace === false) { return ''; - } - else { + } else { return $namespace; } } @@ -980,7 +973,7 @@ public function determineNamespace(PHP_CodeSniffer_File $phpcsFile, $stackPtr) * @return string|false Namespace name or false if not a namespace declaration. * Namespace name can be an empty string for global namespace declaration. */ - public function getDeclaredNamespaceName(PHP_CodeSniffer_File $phpcsFile, $stackPtr ) + public function getDeclaredNamespaceName(PHP_CodeSniffer_File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); @@ -1007,13 +1000,13 @@ public function getDeclaredNamespaceName(PHP_CodeSniffer_File $phpcsFile, $stack // Ok, this should be a namespace declaration, so get all the parts together. $validTokens = array( - T_STRING => true, - T_NS_SEPARATOR => true, - T_WHITESPACE => true, - ); + T_STRING => true, + T_NS_SEPARATOR => true, + T_WHITESPACE => true, + ); $namespaceName = ''; - while(isset($validTokens[$tokens[$nextToken]['code']]) === true) { + while (isset($validTokens[$tokens[$nextToken]['code']]) === true) { $namespaceName .= trim($tokens[$nextToken]['content']); $nextToken++; } @@ -1334,108 +1327,108 @@ public function getMethodParameters(PHP_CodeSniffer_File $phpcsFile, $stackPtr) } } - switch ($tokens[$i]['code']) { - case T_BITWISE_AND: - $passByReference = true; - break; - case T_VARIABLE: - $currVar = $i; - break; - case T_ELLIPSIS: - $variableLength = true; - break; - case T_ARRAY_HINT: - case T_CALLABLE: - $typeHint .= $tokens[$i]['content']; - break; - case T_SELF: - case T_PARENT: - case T_STATIC: - // Self is valid, the others invalid, but were probably intended as type hints. - if (isset($defaultStart) === false) { + switch ($tokens[$i]['type']) { + case 'T_BITWISE_AND': + $passByReference = true; + break; + case 'T_VARIABLE': + $currVar = $i; + break; + case 'T_ELLIPSIS': + $variableLength = true; + break; + case 'T_ARRAY_HINT': + case 'T_CALLABLE': $typeHint .= $tokens[$i]['content']; - } - break; - case T_STRING: - // This is a string, so it may be a type hint, but it could - // also be a constant used as a default value. - $prevComma = false; - for ($t = $i; $t >= $opener; $t--) { - if ($tokens[$t]['code'] === T_COMMA) { - $prevComma = $t; - break; + break; + case 'T_SELF': + case 'T_PARENT': + case 'T_STATIC': + // Self is valid, the others invalid, but were probably intended as type hints. + if (isset($defaultStart) === false) { + $typeHint .= $tokens[$i]['content']; } - } - - if ($prevComma !== false) { - $nextEquals = false; - for ($t = $prevComma; $t < $i; $t++) { - if ($tokens[$t]['code'] === T_EQUAL) { - $nextEquals = $t; + break; + case 'T_STRING': + // This is a string, so it may be a type hint, but it could + // also be a constant used as a default value. + $prevComma = false; + for ($t = $i; $t >= $opener; $t--) { + if ($tokens[$t]['code'] === T_COMMA) { + $prevComma = $t; break; } } - if ($nextEquals !== false) { - break; - } - } - - if ($defaultStart === null) { - $typeHint .= $tokens[$i]['content']; - } - break; - case T_NS_SEPARATOR: - // Part of a type hint or default value. - if ($defaultStart === null) { - $typeHint .= $tokens[$i]['content']; - } - break; - case T_INLINE_THEN: - if ($defaultStart === null) { - $nullableType = true; - $typeHint .= $tokens[$i]['content']; - } - break; - case T_CLOSE_PARENTHESIS: - case T_COMMA: - // If it's null, then there must be no parameters for this - // method. - if ($currVar === null) { - continue; - } + if ($prevComma !== false) { + $nextEquals = false; + for ($t = $prevComma; $t < $i; $t++) { + if ($tokens[$t]['code'] === T_EQUAL) { + $nextEquals = $t; + break; + } + } - $vars[$paramCount] = array(); - $vars[$paramCount]['token'] = $currVar; - $vars[$paramCount]['name'] = $tokens[$currVar]['content']; - $vars[$paramCount]['content'] = trim($phpcsFile->getTokensAsString($paramStart, ($i - $paramStart))); - - if ($defaultStart !== null) { - $vars[$paramCount]['default'] - = trim($phpcsFile->getTokensAsString( - $defaultStart, - ($i - $defaultStart) - )); - } + if ($nextEquals !== false) { + break; + } + } - $vars[$paramCount]['pass_by_reference'] = $passByReference; - $vars[$paramCount]['variable_length'] = $variableLength; - $vars[$paramCount]['type_hint'] = $typeHint; - $vars[$paramCount]['nullable_type'] = $nullableType; + if ($defaultStart === null) { + $typeHint .= $tokens[$i]['content']; + } + break; + case 'T_NS_SEPARATOR': + // Part of a type hint or default value. + if ($defaultStart === null) { + $typeHint .= $tokens[$i]['content']; + } + break; + case 'T_INLINE_THEN': + if ($defaultStart === null) { + $nullableType = true; + $typeHint .= $tokens[$i]['content']; + } + break; + case 'T_CLOSE_PARENTHESIS': + case 'T_COMMA': + // If it's null, then there must be no parameters for this + // method. + if ($currVar === null) { + continue; + } - // Reset the vars, as we are about to process the next parameter. - $defaultStart = null; - $paramStart = ($i + 1); - $passByReference = false; - $variableLength = false; - $typeHint = ''; - $nullableType = false; + $vars[$paramCount] = array(); + $vars[$paramCount]['token'] = $currVar; + $vars[$paramCount]['name'] = $tokens[$currVar]['content']; + $vars[$paramCount]['content'] = trim($phpcsFile->getTokensAsString($paramStart, ($i - $paramStart))); + + if ($defaultStart !== null) { + $vars[$paramCount]['default'] + = trim($phpcsFile->getTokensAsString( + $defaultStart, + ($i - $defaultStart) + )); + } - $paramCount++; - break; - case T_EQUAL: - $defaultStart = ($i + 1); - break; + $vars[$paramCount]['pass_by_reference'] = $passByReference; + $vars[$paramCount]['variable_length'] = $variableLength; + $vars[$paramCount]['type_hint'] = $typeHint; + $vars[$paramCount]['nullable_type'] = $nullableType; + + // Reset the vars, as we are about to process the next parameter. + $defaultStart = null; + $paramStart = ($i + 1); + $passByReference = false; + $variableLength = false; + $typeHint = ''; + $nullableType = false; + + $paramCount++; + break; + case 'T_EQUAL': + $defaultStart = ($i + 1); + break; }//end switch }//end for @@ -1550,9 +1543,7 @@ public function getHashAlgorithmParameter(PHP_CodeSniffer_File $phpcsFile, $stac return false; } - /** - * Algorithm is a text string, so we need to remove the quotes. - */ + // Algorithm is a text string, so we need to remove the quotes. $algo = strtolower(trim($algoParam['raw'])); $algo = $this->stripQuotes($algo); diff --git a/PHPCompatibility/Sniffs/PHP/CaseSensitiveKeywordsSniff.php b/PHPCompatibility/Sniffs/PHP/CaseSensitiveKeywordsSniff.php index 470d7d42..dc1d5da1 100644 --- a/PHPCompatibility/Sniffs/PHP/CaseSensitiveKeywordsSniff.php +++ b/PHPCompatibility/Sniffs/PHP/CaseSensitiveKeywordsSniff.php @@ -32,10 +32,10 @@ class PHPCompatibility_Sniffs_PHP_CaseSensitiveKeywordsSniff extends PHPCompatib public function register() { return array( - T_SELF, - T_STATIC, - T_PARENT, - ); + T_SELF, + T_STATIC, + T_PARENT, + ); } /** @@ -50,12 +50,12 @@ public function register() public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) { if ($this->supportsBelow('5.4') === false) { - return; - } + return; + } $tokens = $phpcsFile->getTokens(); $tokenContentLC = strtolower($tokens[$stackPtr]['content']); - + if ($tokenContentLC !== $tokens[$stackPtr]['content']) { $phpcsFile->addError( 'The keyword \'%s\' was treated in a case-sensitive fashion in certain cases in PHP 5.4 or earlier. Use the lowercase version for consistent support.', diff --git a/PHPCompatibility/Sniffs/PHP/ConstantArraysUsingConstSniff.php b/PHPCompatibility/Sniffs/PHP/ConstantArraysUsingConstSniff.php index 804f6e6d..340fa89c 100644 --- a/PHPCompatibility/Sniffs/PHP/ConstantArraysUsingConstSniff.php +++ b/PHPCompatibility/Sniffs/PHP/ConstantArraysUsingConstSniff.php @@ -4,9 +4,9 @@ * * PHP version 5.6 * - * @category PHP - * @package PHPCompatibility - * @author Juliette Reinders Folmer + * @category PHP + * @package PHPCompatibility + * @author Juliette Reinders Folmer */ /** diff --git a/PHPCompatibility/Sniffs/PHP/ConstantArraysUsingDefineSniff.php b/PHPCompatibility/Sniffs/PHP/ConstantArraysUsingDefineSniff.php index 188630cc..c6419229 100644 --- a/PHPCompatibility/Sniffs/PHP/ConstantArraysUsingDefineSniff.php +++ b/PHPCompatibility/Sniffs/PHP/ConstantArraysUsingDefineSniff.php @@ -4,9 +4,9 @@ * * PHP version 7.0 * - * @category PHP - * @package PHPCompatibility - * @author Wim Godden + * @category PHP + * @package PHPCompatibility + * @author Wim Godden */ /** @@ -16,9 +16,9 @@ * * PHP version 7.0 * - * @category PHP - * @package PHPCompatibility - * @author Wim Godden + * @category PHP + * @package PHPCompatibility + * @author Wim Godden */ class PHPCompatibility_Sniffs_PHP_ConstantArraysUsingDefineSniff extends PHPCompatibility_Sniff { diff --git a/PHPCompatibility/Sniffs/PHP/DefaultTimezoneRequiredSniff.php b/PHPCompatibility/Sniffs/PHP/DefaultTimezoneRequiredSniff.php deleted file mode 100644 index a777d1cc..00000000 --- a/PHPCompatibility/Sniffs/PHP/DefaultTimezoneRequiredSniff.php +++ /dev/null @@ -1,62 +0,0 @@ - - * @copyright 2012 Cu.be Solutions bvba - */ - -/** - * PHPCompatibility_Sniffs_PHP_DefaultTimeZoneRequiredSniff. - * - * Discourages the use of deprecated INI directives through ini_set() or ini_get(). - * - * @category PHP - * @package PHPCompatibility - * @author Wim Godden - * @copyright 2012 Cu.be Solutions bvba - */ -class PHPCompatibility_Sniffs_PHP_DefaultTimezoneRequiredSniff extends PHPCompatibility_Sniff -{ - /** - * Returns an array of tokens this test wants to listen for. - * Maybe not ideal to do this on each open tag. But I don't feel like digging further into PHP_CodeSniffer right now - * - * @return array - */ - public function register() - { - return array(T_OPEN_TAG); - - }//end register() - - /** - * Processes this test, when one of its tokens is encountered. - * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the current token in the - * stack passed in $tokens. - * - * @return void - */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) - { - if ($this->supportsAbove('5.4')) { - $ini_value = ini_get('date.timezone'); - if (is_string($ini_value) === false || $ini_value === '') { - $phpcsFile->addError( - 'Default timezone is required since PHP 5.4', - $stackPtr, - 'Missing' - ); - } - } - - }//end process() - - -}//end class diff --git a/PHPCompatibility/Sniffs/PHP/DeprecatedFunctionsSniff.php b/PHPCompatibility/Sniffs/PHP/DeprecatedFunctionsSniff.php index 5382992c..4aef141e 100644 --- a/PHPCompatibility/Sniffs/PHP/DeprecatedFunctionsSniff.php +++ b/PHPCompatibility/Sniffs/PHP/DeprecatedFunctionsSniff.php @@ -2,19 +2,17 @@ /** * PHPCompatibility_Sniffs_PHP_DeprecatedFunctionsSniff. * - * PHP version 7.0 - * - * @category PHP - * @package PHPCompatibility - * @author Wim Godden + * @category PHP + * @package PHPCompatibility + * @author Wim Godden */ /** * PHPCompatibility_Sniffs_PHP_DeprecatedFunctionsSniff. * - * @category PHP - * @package PHPCompatibility - * @author Wim Godden + * @category PHP + * @package PHPCompatibility + * @author Wim Godden */ class PHPCompatibility_Sniffs_PHP_DeprecatedFunctionsSniff extends PHPCompatibility_AbstractRemovedFeatureSniff { @@ -27,743 +25,743 @@ class PHPCompatibility_Sniffs_PHP_DeprecatedFunctionsSniff extends PHPCompatibil * @var array(string => array(string => bool|string|null)) */ protected $removedFunctions = array( - 'php_check_syntax' => array( - '5.0.5' => true, - 'alternative' => null - ), - 'call_user_method' => array( - '5.3' => false, - '5.4' => false, - '5.5' => false, - '5.6' => false, - '7.0' => true, - 'alternative' => 'call_user_func' - ), - 'call_user_method_array' => array( - '5.3' => false, - '5.4' => false, - '5.5' => false, - '5.6' => false, - '7.0' => true, - 'alternative' => 'call_user_func_array' - ), - 'define_syslog_variables' => array( - '5.3' => false, - '5.4' => true, - '5.5' => true, - '5.6' => true, - 'alternative' => null - ), - 'dl' => array( - '5.3' => false, - '5.4' => false, - '5.5' => false, - '5.6' => false, - 'alternative' => null - ), - 'ereg' => array( - '5.3' => false, - '5.4' => false, - '5.5' => false, - '5.6' => false, - '7.0' => true, - 'alternative' => 'preg_match' - ), - 'ereg_replace' => array( - '5.3' => false, - '5.4' => false, - '5.5' => false, - '5.6' => false, - '7.0' => true, - 'alternative' => 'preg_replace' - ), - 'eregi' => array( - '5.3' => false, - '5.4' => false, - '5.5' => false, - '5.6' => false, - '7.0' => true, - 'alternative' => 'preg_match' - ), - 'eregi_replace' => array( - '5.3' => false, - '5.4' => false, - '5.5' => false, - '5.6' => false, - '7.0' => true, - 'alternative' => 'preg_replace' - ), - 'imagepsbbox' => array( - '7.0' => true, - 'alternative' => null - ), - 'imagepsencodefont' => array( - '7.0' => true, - 'alternative' => null - ), - 'imagepsextendfont' => array( - '7.0' => true, - 'alternative' => null - ), - 'imagepsfreefont' => array( - '7.0' => true, - 'alternative' => null - ), - 'imagepsloadfont' => array( - '7.0' => true, - 'alternative' => null - ), - 'imagepsslantfont' => array( - '7.0' => true, - 'alternative' => null - ), - 'imagepstext' => array( - '7.0' => true, - 'alternative' => null - ), - 'import_request_variables' => array( - '5.3' => false, - '5.4' => true, - 'alternative' => null - ), - 'ldap_sort' => array( - '7.0' => false, - 'alternative' => null - ), - 'mcrypt_generic_end' => array( - '5.4' => false, - '5.5' => false, - '5.6' => false, - '7.0' => true, - 'alternative' => 'mcrypt_generic_deinit' - ), - 'mysql_db_query' => array( - '5.3' => false, - '5.4' => false, - '5.5' => false, - '5.6' => false, - '7.0' => true, - 'alternative' => 'mysqli_select_db and mysqli_query' - ), - 'mysql_escape_string' => array( - '5.3' => false, - '5.4' => false, - '5.5' => false, - '5.6' => false, - '7.0' => true, - 'alternative' => 'mysqli_real_escape_string' - ), - 'mysql_list_dbs' => array( - '5.4' => false, - '5.5' => false, - '5.6' => false, - '7.0' => true, - 'alternative' => null - ), - 'mysqli_bind_param' => array( - '5.3' => false, - '5.4' => true, - '5.5' => true, - '5.6' => true, - 'alternative' => 'mysqli_stmt_bind_param' - ), - 'mysqli_bind_result' => array( - '5.3' => false, - '5.4' => true, - '5.5' => true, - '5.6' => true, - 'alternative' => 'mysqli_stmt_bind_result' - ), - 'mysqli_client_encoding' => array( - '5.3' => false, - '5.4' => true, - '5.5' => true, - '5.6' => true, - 'alternative' => 'mysqli_character_set_name' - ), - 'mysqli_fetch' => array( - '5.3' => false, - '5.4' => true, - '5.5' => true, - '5.6' => true, - 'alternative' => 'mysqli_stmt_fetch' - ), - 'mysqli_param_count' => array( - '5.3' => false, - '5.4' => true, - '5.5' => true, - '5.6' => true, - 'alternative' => 'mysqli_stmt_param_count' - ), - 'mysqli_get_metadata' => array( - '5.3' => false, - '5.4' => true, - '5.5' => true, - '5.6' => true, - 'alternative' => 'mysqli_stmt_result_metadata' - ), - 'mysqli_send_long_data' => array( - '5.3' => false, - '5.4' => true, - '5.5' => true, - '5.6' => true, - 'alternative' => 'mysqli_stmt_send_long_data' - ), - 'magic_quotes_runtime' => array( - '5.3' => false, - '5.4' => false, - '5.5' => false, - '5.6' => false, - '7.0' => true, - 'alternative' => null - ), - 'session_register' => array( - '5.3' => false, - '5.4' => true, - '5.5' => true, - '5.6' => true, - 'alternative' => '$_SESSION' - ), - 'session_unregister' => array( - '5.3' => false, - '5.4' => true, - '5.5' => true, - '5.6' => true, - 'alternative' => '$_SESSION' - ), - 'session_is_registered' => array( - '5.3' => false, - '5.4' => true, - '5.5' => true, - '5.6' => true, - 'alternative' => '$_SESSION' - ), - 'set_magic_quotes_runtime' => array( - '5.3' => false, - '5.4' => false, - '5.5' => false, - '5.6' => false, - '7.0' => true, - 'alternative' => null - ), - 'set_socket_blocking' => array( - '5.3' => false, - '5.4' => false, - '5.5' => false, - '5.6' => false, - '7.0' => true, - 'alternative' => 'stream_set_blocking' - ), - 'split' => array( - '5.3' => false, - '5.4' => false, - '5.5' => false, - '5.6' => false, - '7.0' => true, - 'alternative' => 'preg_split' - ), - 'spliti' => array( - '5.3' => false, - '5.4' => false, - '5.5' => false, - '5.6' => false, - '7.0' => true, - 'alternative' => 'preg_split' - ), - 'sql_regcase' => array( - '5.3' => false, - '5.4' => false, - '5.5' => false, - '5.6' => false, - '7.0' => true, - 'alternative' => null - ), - 'php_logo_guid' => array( - '5.5' => true, - '5.6' => true, - 'alternative' => null - ), - 'php_egg_logo_guid' => array( - '5.5' => true, - '5.6' => true, - 'alternative' => null - ), - 'php_real_logo_guid' => array( - '5.5' => true, - '5.6' => true, - 'alternative' => null - ), - 'zend_logo_guid' => array( - '5.5' => true, - '5.6' => true, - 'alternative' => null - ), - 'datefmt_set_timezone_id' => array( - '5.5' => false, - '5.6' => false, - '7.0' => true, - 'alternative' => 'datefmt_set_timezone' - ), - 'mcrypt_ecb' => array( - '5.5' => false, - '5.6' => false, - '7.0' => true, - 'alternative' => null - ), - 'mcrypt_cbc' => array( - '5.5' => false, - '5.6' => false, - '7.0' => true, - 'alternative' => null - ), - 'mcrypt_cfb' => array( - '5.5' => false, - '5.6' => false, - '7.0' => true, - 'alternative' => null - ), - 'mcrypt_ofb' => array( - '5.5' => false, - '5.6' => false, - '7.0' => true, - 'alternative' => null - ), - 'ocibindbyname' => array( - '5.4' => false, - '5.5' => false, - '5.6' => false, - 'alternative' => 'oci_bind_by_name' - ), - 'ocicancel' => array( - '5.4' => false, - '5.5' => false, - '5.6' => false, - 'alternative' => 'oci_cancel' - ), - 'ocicloselob' => array( - '5.4' => false, - '5.5' => false, - '5.6' => false, - 'alternative' => 'OCI-Lob::close' - ), - 'ocicollappend' => array( - '5.4' => false, - '5.5' => false, - '5.6' => false, - 'alternative' => 'OCI-Collection::append' - ), - 'ocicollassign' => array( - '5.4' => false, - '5.5' => false, - '5.6' => false, - 'alternative' => 'OCI-Collection::assign' - ), - 'ocicollassignelem' => array( - '5.4' => false, - '5.5' => false, - '5.6' => false, - 'alternative' => 'OCI-Collection::assignElem' - ), - 'ocicollgetelem' => array( - '5.4' => false, - '5.5' => false, - '5.6' => false, - 'alternative' => 'OCI-Collection::getElem' - ), - 'ocicollmax' => array( - '5.4' => false, - '5.5' => false, - '5.6' => false, - 'alternative' => 'OCI-Collection::max' - ), - 'ocicollsize' => array( - '5.4' => false, - '5.5' => false, - '5.6' => false, - 'alternative' => 'OCI-Collection::size' - ), - 'ocicolltrim' => array( - '5.4' => false, - '5.5' => false, - '5.6' => false, - 'alternative' => 'OCI-Collection::trim' - ), - 'ocicolumnisnull' => array( - '5.4' => false, - '5.5' => false, - '5.6' => false, - 'alternative' => 'oci_field_is_null' - ), - 'ocicolumnname' => array( - '5.4' => false, - '5.5' => false, - '5.6' => false, - 'alternative' => 'oci_field_name' - ), - 'ocicolumnprecision' => array( - '5.4' => false, - '5.5' => false, - '5.6' => false, - 'alternative' => 'oci_field_precision' - ), - 'ocicolumnscale' => array( - '5.4' => false, - '5.5' => false, - '5.6' => false, - 'alternative' => 'oci_field_scale' - ), - 'ocicolumnsize' => array( - '5.4' => false, - '5.5' => false, - '5.6' => false, - 'alternative' => 'oci_field_size' - ), - 'ocicolumntype' => array( - '5.4' => false, - '5.5' => false, - '5.6' => false, - 'alternative' => 'oci_field_type' - ), - 'ocicolumntyperaw' => array( - '5.4' => false, - '5.5' => false, - '5.6' => false, - 'alternative' => 'oci_field_type_raw' - ), - 'ocicommit' => array( - '5.4' => false, - '5.5' => false, - '5.6' => false, - 'alternative' => 'oci_commit' - ), - 'ocidefinebyname' => array( - '5.4' => false, - '5.5' => false, - '5.6' => false, - 'alternative' => 'oci_define_by_name' - ), - 'ocierror' => array( - '5.4' => false, - '5.5' => false, - '5.6' => false, - 'alternative' => 'oci_error' - ), - 'ociexecute' => array( - '5.4' => false, - '5.5' => false, - '5.6' => false, - 'alternative' => 'oci_execute' - ), - 'ocifetch' => array( - '5.4' => false, - '5.5' => false, - '5.6' => false, - 'alternative' => 'oci_fetch' - ), - 'ocifetchinto' => array( - '5.4' => false, - '5.5' => false, - '5.6' => false, - 'alternative' => null - ), - 'ocifetchstatement' => array( - '5.4' => false, - '5.5' => false, - '5.6' => false, - 'alternative' => 'oci_fetch_all' - ), - 'ocifreecollection' => array( - '5.4' => false, - '5.5' => false, - '5.6' => false, - 'alternative' => 'OCI-Collection::free' - ), - 'ocifreecursor' => array( - '5.4' => false, - '5.5' => false, - '5.6' => false, - 'alternative' => 'oci_free_statement' - ), - 'ocifreedesc' => array( - '5.4' => false, - '5.5' => false, - '5.6' => false, - 'alternative' => 'OCI-Lob::free' - ), - 'ocifreestatement' => array( - '5.4' => false, - '5.5' => false, - '5.6' => false, - 'alternative' => 'oci_free_statement' - ), - 'ociinternaldebug' => array( - '5.4' => false, - '5.5' => false, - '5.6' => false, - 'alternative' => 'oci_internal_debug' - ), - 'ociloadlob' => array( - '5.4' => false, - '5.5' => false, - '5.6' => false, - 'alternative' => 'OCI-Lob::load' - ), - 'ocilogoff' => array( - '5.4' => false, - '5.5' => false, - '5.6' => false, - 'alternative' => 'oci_close' - ), - 'ocilogon' => array( - '5.4' => false, - '5.5' => false, - '5.6' => false, - 'alternative' => 'oci_connect' - ), - 'ocinewcollection' => array( - '5.4' => false, - '5.5' => false, - '5.6' => false, - 'alternative' => 'oci_new_collection' - ), - 'ocinewcursor' => array( - '5.4' => false, - '5.5' => false, - '5.6' => false, - 'alternative' => 'oci_new_cursor' - ), - 'ocinewdescriptor' => array( - '5.4' => false, - '5.5' => false, - '5.6' => false, - 'alternative' => 'oci_new_descriptor' - ), - 'ocinlogon' => array( - '5.4' => false, - '5.5' => false, - '5.6' => false, - 'alternative' => 'oci_new_connect' - ), - 'ocinumcols' => array( - '5.4' => false, - '5.5' => false, - '5.6' => false, - 'alternative' => 'oci_num_fields' - ), - 'ociparse' => array( - '5.4' => false, - '5.5' => false, - '5.6' => false, - 'alternative' => 'oci_parse' - ), - 'ociplogon' => array( - '5.4' => false, - '5.5' => false, - '5.6' => false, - 'alternative' => 'oci_pconnect' - ), - 'ociresult' => array( - '5.4' => false, - '5.5' => false, - '5.6' => false, - 'alternative' => 'oci_result' - ), - 'ocirollback' => array( - '5.4' => false, - '5.5' => false, - '5.6' => false, - 'alternative' => 'oci_rollback' - ), - 'ocirowcount' => array( - '5.4' => false, - '5.5' => false, - '5.6' => false, - 'alternative' => 'oci_num_rows' - ), - 'ocisavelob' => array( - '5.4' => false, - '5.5' => false, - '5.6' => false, - 'alternative' => 'OCI-Lob::save' - ), - 'ocisavelobfile' => array( - '5.4' => false, - '5.5' => false, - '5.6' => false, - 'alternative' => 'OCI-Lob::import' - ), - 'ociserverversion' => array( - '5.4' => false, - '5.5' => false, - '5.6' => false, - 'alternative' => 'oci_server_version' - ), - 'ocisetprefetch' => array( - '5.4' => false, - '5.5' => false, - '5.6' => false, - 'alternative' => 'oci_set_prefetch' - ), - 'ocistatementtype' => array( - '5.4' => false, - '5.5' => false, - '5.6' => false, - 'alternative' => 'oci_statement_type' - ), - 'ociwritelobtofile' => array( - '5.4' => false, - '5.5' => false, - '5.6' => false, - 'alternative' => 'OCI-Lob::export' - ), - 'ociwritetemporarylob' => array( - '5.4' => false, - '5.5' => false, - '5.6' => false, - 'alternative' => 'OCI-Lob::writeTemporary' - ), - 'mysqli_get_cache_stats' => array( - '5.4' => true, - 'alternative' => null - ), + 'php_check_syntax' => array( + '5.0.5' => true, + 'alternative' => null, + ), + 'call_user_method' => array( + '5.3' => false, + '5.4' => false, + '5.5' => false, + '5.6' => false, + '7.0' => true, + 'alternative' => 'call_user_func', + ), + 'call_user_method_array' => array( + '5.3' => false, + '5.4' => false, + '5.5' => false, + '5.6' => false, + '7.0' => true, + 'alternative' => 'call_user_func_array', + ), + 'define_syslog_variables' => array( + '5.3' => false, + '5.4' => true, + '5.5' => true, + '5.6' => true, + 'alternative' => null, + ), + 'dl' => array( + '5.3' => false, + '5.4' => false, + '5.5' => false, + '5.6' => false, + 'alternative' => null, + ), + 'ereg' => array( + '5.3' => false, + '5.4' => false, + '5.5' => false, + '5.6' => false, + '7.0' => true, + 'alternative' => 'preg_match', + ), + 'ereg_replace' => array( + '5.3' => false, + '5.4' => false, + '5.5' => false, + '5.6' => false, + '7.0' => true, + 'alternative' => 'preg_replace', + ), + 'eregi' => array( + '5.3' => false, + '5.4' => false, + '5.5' => false, + '5.6' => false, + '7.0' => true, + 'alternative' => 'preg_match', + ), + 'eregi_replace' => array( + '5.3' => false, + '5.4' => false, + '5.5' => false, + '5.6' => false, + '7.0' => true, + 'alternative' => 'preg_replace', + ), + 'imagepsbbox' => array( + '7.0' => true, + 'alternative' => null, + ), + 'imagepsencodefont' => array( + '7.0' => true, + 'alternative' => null, + ), + 'imagepsextendfont' => array( + '7.0' => true, + 'alternative' => null, + ), + 'imagepsfreefont' => array( + '7.0' => true, + 'alternative' => null, + ), + 'imagepsloadfont' => array( + '7.0' => true, + 'alternative' => null, + ), + 'imagepsslantfont' => array( + '7.0' => true, + 'alternative' => null, + ), + 'imagepstext' => array( + '7.0' => true, + 'alternative' => null, + ), + 'import_request_variables' => array( + '5.3' => false, + '5.4' => true, + 'alternative' => null, + ), + 'ldap_sort' => array( + '7.0' => false, + 'alternative' => null, + ), + 'mcrypt_generic_end' => array( + '5.4' => false, + '5.5' => false, + '5.6' => false, + '7.0' => true, + 'alternative' => 'mcrypt_generic_deinit', + ), + 'mysql_db_query' => array( + '5.3' => false, + '5.4' => false, + '5.5' => false, + '5.6' => false, + '7.0' => true, + 'alternative' => 'mysqli_select_db and mysqli_query', + ), + 'mysql_escape_string' => array( + '5.3' => false, + '5.4' => false, + '5.5' => false, + '5.6' => false, + '7.0' => true, + 'alternative' => 'mysqli_real_escape_string', + ), + 'mysql_list_dbs' => array( + '5.4' => false, + '5.5' => false, + '5.6' => false, + '7.0' => true, + 'alternative' => null, + ), + 'mysqli_bind_param' => array( + '5.3' => false, + '5.4' => true, + '5.5' => true, + '5.6' => true, + 'alternative' => 'mysqli_stmt_bind_param', + ), + 'mysqli_bind_result' => array( + '5.3' => false, + '5.4' => true, + '5.5' => true, + '5.6' => true, + 'alternative' => 'mysqli_stmt_bind_result', + ), + 'mysqli_client_encoding' => array( + '5.3' => false, + '5.4' => true, + '5.5' => true, + '5.6' => true, + 'alternative' => 'mysqli_character_set_name', + ), + 'mysqli_fetch' => array( + '5.3' => false, + '5.4' => true, + '5.5' => true, + '5.6' => true, + 'alternative' => 'mysqli_stmt_fetch', + ), + 'mysqli_param_count' => array( + '5.3' => false, + '5.4' => true, + '5.5' => true, + '5.6' => true, + 'alternative' => 'mysqli_stmt_param_count', + ), + 'mysqli_get_metadata' => array( + '5.3' => false, + '5.4' => true, + '5.5' => true, + '5.6' => true, + 'alternative' => 'mysqli_stmt_result_metadata', + ), + 'mysqli_send_long_data' => array( + '5.3' => false, + '5.4' => true, + '5.5' => true, + '5.6' => true, + 'alternative' => 'mysqli_stmt_send_long_data', + ), + 'magic_quotes_runtime' => array( + '5.3' => false, + '5.4' => false, + '5.5' => false, + '5.6' => false, + '7.0' => true, + 'alternative' => null, + ), + 'session_register' => array( + '5.3' => false, + '5.4' => true, + '5.5' => true, + '5.6' => true, + 'alternative' => '$_SESSION', + ), + 'session_unregister' => array( + '5.3' => false, + '5.4' => true, + '5.5' => true, + '5.6' => true, + 'alternative' => '$_SESSION', + ), + 'session_is_registered' => array( + '5.3' => false, + '5.4' => true, + '5.5' => true, + '5.6' => true, + 'alternative' => '$_SESSION', + ), + 'set_magic_quotes_runtime' => array( + '5.3' => false, + '5.4' => false, + '5.5' => false, + '5.6' => false, + '7.0' => true, + 'alternative' => null, + ), + 'set_socket_blocking' => array( + '5.3' => false, + '5.4' => false, + '5.5' => false, + '5.6' => false, + '7.0' => true, + 'alternative' => 'stream_set_blocking', + ), + 'split' => array( + '5.3' => false, + '5.4' => false, + '5.5' => false, + '5.6' => false, + '7.0' => true, + 'alternative' => 'preg_split', + ), + 'spliti' => array( + '5.3' => false, + '5.4' => false, + '5.5' => false, + '5.6' => false, + '7.0' => true, + 'alternative' => 'preg_split', + ), + 'sql_regcase' => array( + '5.3' => false, + '5.4' => false, + '5.5' => false, + '5.6' => false, + '7.0' => true, + 'alternative' => null, + ), + 'php_logo_guid' => array( + '5.5' => true, + '5.6' => true, + 'alternative' => null, + ), + 'php_egg_logo_guid' => array( + '5.5' => true, + '5.6' => true, + 'alternative' => null, + ), + 'php_real_logo_guid' => array( + '5.5' => true, + '5.6' => true, + 'alternative' => null, + ), + 'zend_logo_guid' => array( + '5.5' => true, + '5.6' => true, + 'alternative' => null, + ), + 'datefmt_set_timezone_id' => array( + '5.5' => false, + '5.6' => false, + '7.0' => true, + 'alternative' => 'datefmt_set_timezone', + ), + 'mcrypt_ecb' => array( + '5.5' => false, + '5.6' => false, + '7.0' => true, + 'alternative' => null, + ), + 'mcrypt_cbc' => array( + '5.5' => false, + '5.6' => false, + '7.0' => true, + 'alternative' => null, + ), + 'mcrypt_cfb' => array( + '5.5' => false, + '5.6' => false, + '7.0' => true, + 'alternative' => null, + ), + 'mcrypt_ofb' => array( + '5.5' => false, + '5.6' => false, + '7.0' => true, + 'alternative' => null, + ), + 'ocibindbyname' => array( + '5.4' => false, + '5.5' => false, + '5.6' => false, + 'alternative' => 'oci_bind_by_name', + ), + 'ocicancel' => array( + '5.4' => false, + '5.5' => false, + '5.6' => false, + 'alternative' => 'oci_cancel', + ), + 'ocicloselob' => array( + '5.4' => false, + '5.5' => false, + '5.6' => false, + 'alternative' => 'OCI-Lob::close', + ), + 'ocicollappend' => array( + '5.4' => false, + '5.5' => false, + '5.6' => false, + 'alternative' => 'OCI-Collection::append', + ), + 'ocicollassign' => array( + '5.4' => false, + '5.5' => false, + '5.6' => false, + 'alternative' => 'OCI-Collection::assign', + ), + 'ocicollassignelem' => array( + '5.4' => false, + '5.5' => false, + '5.6' => false, + 'alternative' => 'OCI-Collection::assignElem', + ), + 'ocicollgetelem' => array( + '5.4' => false, + '5.5' => false, + '5.6' => false, + 'alternative' => 'OCI-Collection::getElem', + ), + 'ocicollmax' => array( + '5.4' => false, + '5.5' => false, + '5.6' => false, + 'alternative' => 'OCI-Collection::max', + ), + 'ocicollsize' => array( + '5.4' => false, + '5.5' => false, + '5.6' => false, + 'alternative' => 'OCI-Collection::size', + ), + 'ocicolltrim' => array( + '5.4' => false, + '5.5' => false, + '5.6' => false, + 'alternative' => 'OCI-Collection::trim', + ), + 'ocicolumnisnull' => array( + '5.4' => false, + '5.5' => false, + '5.6' => false, + 'alternative' => 'oci_field_is_null', + ), + 'ocicolumnname' => array( + '5.4' => false, + '5.5' => false, + '5.6' => false, + 'alternative' => 'oci_field_name', + ), + 'ocicolumnprecision' => array( + '5.4' => false, + '5.5' => false, + '5.6' => false, + 'alternative' => 'oci_field_precision', + ), + 'ocicolumnscale' => array( + '5.4' => false, + '5.5' => false, + '5.6' => false, + 'alternative' => 'oci_field_scale', + ), + 'ocicolumnsize' => array( + '5.4' => false, + '5.5' => false, + '5.6' => false, + 'alternative' => 'oci_field_size', + ), + 'ocicolumntype' => array( + '5.4' => false, + '5.5' => false, + '5.6' => false, + 'alternative' => 'oci_field_type', + ), + 'ocicolumntyperaw' => array( + '5.4' => false, + '5.5' => false, + '5.6' => false, + 'alternative' => 'oci_field_type_raw', + ), + 'ocicommit' => array( + '5.4' => false, + '5.5' => false, + '5.6' => false, + 'alternative' => 'oci_commit', + ), + 'ocidefinebyname' => array( + '5.4' => false, + '5.5' => false, + '5.6' => false, + 'alternative' => 'oci_define_by_name', + ), + 'ocierror' => array( + '5.4' => false, + '5.5' => false, + '5.6' => false, + 'alternative' => 'oci_error', + ), + 'ociexecute' => array( + '5.4' => false, + '5.5' => false, + '5.6' => false, + 'alternative' => 'oci_execute', + ), + 'ocifetch' => array( + '5.4' => false, + '5.5' => false, + '5.6' => false, + 'alternative' => 'oci_fetch', + ), + 'ocifetchinto' => array( + '5.4' => false, + '5.5' => false, + '5.6' => false, + 'alternative' => null, + ), + 'ocifetchstatement' => array( + '5.4' => false, + '5.5' => false, + '5.6' => false, + 'alternative' => 'oci_fetch_all', + ), + 'ocifreecollection' => array( + '5.4' => false, + '5.5' => false, + '5.6' => false, + 'alternative' => 'OCI-Collection::free', + ), + 'ocifreecursor' => array( + '5.4' => false, + '5.5' => false, + '5.6' => false, + 'alternative' => 'oci_free_statement', + ), + 'ocifreedesc' => array( + '5.4' => false, + '5.5' => false, + '5.6' => false, + 'alternative' => 'OCI-Lob::free', + ), + 'ocifreestatement' => array( + '5.4' => false, + '5.5' => false, + '5.6' => false, + 'alternative' => 'oci_free_statement', + ), + 'ociinternaldebug' => array( + '5.4' => false, + '5.5' => false, + '5.6' => false, + 'alternative' => 'oci_internal_debug', + ), + 'ociloadlob' => array( + '5.4' => false, + '5.5' => false, + '5.6' => false, + 'alternative' => 'OCI-Lob::load', + ), + 'ocilogoff' => array( + '5.4' => false, + '5.5' => false, + '5.6' => false, + 'alternative' => 'oci_close', + ), + 'ocilogon' => array( + '5.4' => false, + '5.5' => false, + '5.6' => false, + 'alternative' => 'oci_connect', + ), + 'ocinewcollection' => array( + '5.4' => false, + '5.5' => false, + '5.6' => false, + 'alternative' => 'oci_new_collection', + ), + 'ocinewcursor' => array( + '5.4' => false, + '5.5' => false, + '5.6' => false, + 'alternative' => 'oci_new_cursor', + ), + 'ocinewdescriptor' => array( + '5.4' => false, + '5.5' => false, + '5.6' => false, + 'alternative' => 'oci_new_descriptor', + ), + 'ocinlogon' => array( + '5.4' => false, + '5.5' => false, + '5.6' => false, + 'alternative' => 'oci_new_connect', + ), + 'ocinumcols' => array( + '5.4' => false, + '5.5' => false, + '5.6' => false, + 'alternative' => 'oci_num_fields', + ), + 'ociparse' => array( + '5.4' => false, + '5.5' => false, + '5.6' => false, + 'alternative' => 'oci_parse', + ), + 'ociplogon' => array( + '5.4' => false, + '5.5' => false, + '5.6' => false, + 'alternative' => 'oci_pconnect', + ), + 'ociresult' => array( + '5.4' => false, + '5.5' => false, + '5.6' => false, + 'alternative' => 'oci_result', + ), + 'ocirollback' => array( + '5.4' => false, + '5.5' => false, + '5.6' => false, + 'alternative' => 'oci_rollback', + ), + 'ocirowcount' => array( + '5.4' => false, + '5.5' => false, + '5.6' => false, + 'alternative' => 'oci_num_rows', + ), + 'ocisavelob' => array( + '5.4' => false, + '5.5' => false, + '5.6' => false, + 'alternative' => 'OCI-Lob::save', + ), + 'ocisavelobfile' => array( + '5.4' => false, + '5.5' => false, + '5.6' => false, + 'alternative' => 'OCI-Lob::import', + ), + 'ociserverversion' => array( + '5.4' => false, + '5.5' => false, + '5.6' => false, + 'alternative' => 'oci_server_version', + ), + 'ocisetprefetch' => array( + '5.4' => false, + '5.5' => false, + '5.6' => false, + 'alternative' => 'oci_set_prefetch', + ), + 'ocistatementtype' => array( + '5.4' => false, + '5.5' => false, + '5.6' => false, + 'alternative' => 'oci_statement_type', + ), + 'ociwritelobtofile' => array( + '5.4' => false, + '5.5' => false, + '5.6' => false, + 'alternative' => 'OCI-Lob::export', + ), + 'ociwritetemporarylob' => array( + '5.4' => false, + '5.5' => false, + '5.6' => false, + 'alternative' => 'OCI-Lob::writeTemporary', + ), + 'mysqli_get_cache_stats' => array( + '5.4' => true, + 'alternative' => null, + ), - 'mcrypt_create_iv' => array( - '7.1' => false, - 'alternative' => 'OpenSSL' - ), - 'mcrypt_decrypt' => array( - '7.1' => false, - 'alternative' => 'OpenSSL' - ), - 'mcrypt_enc_get_algorithms_name' => array( - '7.1' => false, - 'alternative' => 'OpenSSL' - ), - 'mcrypt_enc_get_block_size' => array( - '7.1' => false, - 'alternative' => 'OpenSSL' - ), - 'mcrypt_enc_get_iv_size' => array( - '7.1' => false, - 'alternative' => 'OpenSSL' - ), - 'mcrypt_enc_get_key_size' => array( - '7.1' => false, - 'alternative' => 'OpenSSL' - ), - 'mcrypt_enc_get_modes_name' => array( - '7.1' => false, - 'alternative' => 'OpenSSL' - ), - 'mcrypt_enc_get_supported_key_sizes' => array( - '7.1' => false, - 'alternative' => 'OpenSSL' - ), - 'mcrypt_enc_is_block_algorithm_mode' => array( - '7.1' => false, - 'alternative' => 'OpenSSL' - ), - 'mcrypt_enc_is_block_algorithm' => array( - '7.1' => false, - 'alternative' => 'OpenSSL' - ), - 'mcrypt_enc_is_block_mode' => array( - '7.1' => false, - 'alternative' => 'OpenSSL' - ), - 'mcrypt_enc_self_test' => array( - '7.1' => false, - 'alternative' => 'OpenSSL' - ), - 'mcrypt_encrypt' => array( - '7.1' => false, - 'alternative' => 'OpenSSL' - ), - 'mcrypt_generic_deinit' => array( - '7.1' => false, - 'alternative' => 'OpenSSL' - ), - 'mcrypt_generic_init' => array( - '7.1' => false, - 'alternative' => 'OpenSSL' - ), - 'mcrypt_generic' => array( - '7.1' => false, - 'alternative' => 'OpenSSL' - ), - 'mcrypt_get_block_size' => array( - '7.1' => false, - 'alternative' => 'OpenSSL' - ), - 'mcrypt_get_cipher_name' => array( - '7.1' => false, - 'alternative' => 'OpenSSL' - ), - 'mcrypt_get_iv_size' => array( - '7.1' => false, - 'alternative' => 'OpenSSL' - ), - 'mcrypt_get_key_size' => array( - '7.1' => false, - 'alternative' => 'OpenSSL' - ), - 'mcrypt_list_algorithms' => array( - '7.1' => false, - 'alternative' => 'OpenSSL' - ), - 'mcrypt_list_modes' => array( - '7.1' => false, - 'alternative' => 'OpenSSL' - ), - 'mcrypt_module_close' => array( - '7.1' => false, - 'alternative' => 'OpenSSL' - ), - 'mcrypt_module_get_algo_block_size' => array( - '7.1' => false, - 'alternative' => 'OpenSSL' - ), - 'mcrypt_module_get_algo_key_size' => array( - '7.1' => false, - 'alternative' => 'OpenSSL' - ), - 'mcrypt_module_get_supported_key_sizes' => array( - '7.1' => false, - 'alternative' => 'OpenSSL' - ), - 'mcrypt_module_is_block_algorithm_mode' => array( - '7.1' => false, - 'alternative' => 'OpenSSL' - ), - 'mcrypt_module_is_block_algorithm' => array( - '7.1' => false, - 'alternative' => 'OpenSSL' - ), - 'mcrypt_module_is_block_mode' => array( - '7.1' => false, - 'alternative' => 'OpenSSL' - ), - 'mcrypt_module_open' => array( - '7.1' => false, - 'alternative' => 'OpenSSL' - ), - 'mcrypt_module_self_test' => array( - '7.1' => false, - 'alternative' => 'OpenSSL' - ), - 'mdecrypt_generic' => array( - '7.1' => false, - 'alternative' => 'OpenSSL' - ), - 'jpeg2wbmp' => array( - '7.2' => false, - 'alternative' => 'imagecreatefromjpeg() and imagewbmp()' - ), - 'png2wbmp' => array( - '7.2' => false, - 'alternative' => 'imagecreatefrompng() or imagewbmp()' - ), - ); + 'mcrypt_create_iv' => array( + '7.1' => false, + 'alternative' => 'OpenSSL', + ), + 'mcrypt_decrypt' => array( + '7.1' => false, + 'alternative' => 'OpenSSL', + ), + 'mcrypt_enc_get_algorithms_name' => array( + '7.1' => false, + 'alternative' => 'OpenSSL', + ), + 'mcrypt_enc_get_block_size' => array( + '7.1' => false, + 'alternative' => 'OpenSSL', + ), + 'mcrypt_enc_get_iv_size' => array( + '7.1' => false, + 'alternative' => 'OpenSSL', + ), + 'mcrypt_enc_get_key_size' => array( + '7.1' => false, + 'alternative' => 'OpenSSL', + ), + 'mcrypt_enc_get_modes_name' => array( + '7.1' => false, + 'alternative' => 'OpenSSL', + ), + 'mcrypt_enc_get_supported_key_sizes' => array( + '7.1' => false, + 'alternative' => 'OpenSSL', + ), + 'mcrypt_enc_is_block_algorithm_mode' => array( + '7.1' => false, + 'alternative' => 'OpenSSL', + ), + 'mcrypt_enc_is_block_algorithm' => array( + '7.1' => false, + 'alternative' => 'OpenSSL', + ), + 'mcrypt_enc_is_block_mode' => array( + '7.1' => false, + 'alternative' => 'OpenSSL', + ), + 'mcrypt_enc_self_test' => array( + '7.1' => false, + 'alternative' => 'OpenSSL', + ), + 'mcrypt_encrypt' => array( + '7.1' => false, + 'alternative' => 'OpenSSL', + ), + 'mcrypt_generic_deinit' => array( + '7.1' => false, + 'alternative' => 'OpenSSL', + ), + 'mcrypt_generic_init' => array( + '7.1' => false, + 'alternative' => 'OpenSSL', + ), + 'mcrypt_generic' => array( + '7.1' => false, + 'alternative' => 'OpenSSL', + ), + 'mcrypt_get_block_size' => array( + '7.1' => false, + 'alternative' => 'OpenSSL', + ), + 'mcrypt_get_cipher_name' => array( + '7.1' => false, + 'alternative' => 'OpenSSL', + ), + 'mcrypt_get_iv_size' => array( + '7.1' => false, + 'alternative' => 'OpenSSL', + ), + 'mcrypt_get_key_size' => array( + '7.1' => false, + 'alternative' => 'OpenSSL', + ), + 'mcrypt_list_algorithms' => array( + '7.1' => false, + 'alternative' => 'OpenSSL', + ), + 'mcrypt_list_modes' => array( + '7.1' => false, + 'alternative' => 'OpenSSL', + ), + 'mcrypt_module_close' => array( + '7.1' => false, + 'alternative' => 'OpenSSL', + ), + 'mcrypt_module_get_algo_block_size' => array( + '7.1' => false, + 'alternative' => 'OpenSSL', + ), + 'mcrypt_module_get_algo_key_size' => array( + '7.1' => false, + 'alternative' => 'OpenSSL', + ), + 'mcrypt_module_get_supported_key_sizes' => array( + '7.1' => false, + 'alternative' => 'OpenSSL', + ), + 'mcrypt_module_is_block_algorithm_mode' => array( + '7.1' => false, + 'alternative' => 'OpenSSL', + ), + 'mcrypt_module_is_block_algorithm' => array( + '7.1' => false, + 'alternative' => 'OpenSSL', + ), + 'mcrypt_module_is_block_mode' => array( + '7.1' => false, + 'alternative' => 'OpenSSL', + ), + 'mcrypt_module_open' => array( + '7.1' => false, + 'alternative' => 'OpenSSL', + ), + 'mcrypt_module_self_test' => array( + '7.1' => false, + 'alternative' => 'OpenSSL', + ), + 'mdecrypt_generic' => array( + '7.1' => false, + 'alternative' => 'OpenSSL', + ), + 'jpeg2wbmp' => array( + '7.2' => false, + 'alternative' => 'imagecreatefromjpeg() and imagewbmp()', + ), + 'png2wbmp' => array( + '7.2' => false, + 'alternative' => 'imagecreatefrompng() or imagewbmp()', + ), + ); /** @@ -795,12 +793,13 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) $tokens = $phpcsFile->getTokens(); $ignore = array( - T_DOUBLE_COLON, - T_OBJECT_OPERATOR, - T_FUNCTION, - T_CONST, - T_USE, - T_NS_SEPARATOR, + T_DOUBLE_COLON, + T_OBJECT_OPERATOR, + T_FUNCTION, + T_CLASS, + T_CONST, + T_USE, + T_NS_SEPARATOR, ); $prevToken = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true); diff --git a/PHPCompatibility/Sniffs/PHP/DeprecatedIniDirectivesSniff.php b/PHPCompatibility/Sniffs/PHP/DeprecatedIniDirectivesSniff.php index 8581987a..b07b8482 100644 --- a/PHPCompatibility/Sniffs/PHP/DeprecatedIniDirectivesSniff.php +++ b/PHPCompatibility/Sniffs/PHP/DeprecatedIniDirectivesSniff.php @@ -2,8 +2,6 @@ /** * PHPCompatibility_Sniffs_PHP_DeprecatedIniDirectivesSniff. * - * PHP version 5.4 - * * @category PHP * @package PHPCompatibility * @author Wim Godden @@ -37,37 +35,37 @@ class PHPCompatibility_Sniffs_PHP_DeprecatedIniDirectivesSniff extends PHPCompat ), 'ifx.allow_persistent' => array( - '5.2.1' => true + '5.2.1' => true, ), 'ifx.blobinfile' => array( - '5.2.1' => true + '5.2.1' => true, ), 'ifx.byteasvarchar' => array( - '5.2.1' => true + '5.2.1' => true, ), 'ifx.charasvarchar' => array( - '5.2.1' => true + '5.2.1' => true, ), 'ifx.default_host' => array( - '5.2.1' => true + '5.2.1' => true, ), 'ifx.default_password' => array( - '5.2.1' => true + '5.2.1' => true, ), 'ifx.default_user' => array( - '5.2.1' => true + '5.2.1' => true, ), 'ifx.max_links' => array( - '5.2.1' => true + '5.2.1' => true, ), 'ifx.max_persistent' => array( - '5.2.1' => true + '5.2.1' => true, ), 'ifx.nullformat' => array( - '5.2.1' => true + '5.2.1' => true, ), 'ifx.textasvarchar' => array( - '5.2.1' => true + '5.2.1' => true, ), 'zend.ze1_compatibility_mode' => array( @@ -76,11 +74,11 @@ class PHPCompatibility_Sniffs_PHP_DeprecatedIniDirectivesSniff extends PHPCompat 'allow_call_time_pass_reference' => array( '5.3' => false, - '5.4' => true + '5.4' => true, ), 'define_syslog_variables' => array( '5.3' => false, - '5.4' => true + '5.4' => true, ), 'detect_unicode' => array( '5.4' => true, @@ -88,19 +86,19 @@ class PHPCompatibility_Sniffs_PHP_DeprecatedIniDirectivesSniff extends PHPCompat ), 'highlight.bg' => array( '5.3' => false, - '5.4' => true + '5.4' => true, ), 'magic_quotes_gpc' => array( '5.3' => false, - '5.4' => true + '5.4' => true, ), 'magic_quotes_runtime' => array( '5.3' => false, - '5.4' => true + '5.4' => true, ), 'magic_quotes_sybase' => array( '5.3' => false, - '5.4' => true + '5.4' => true, ), 'mbstring.script_encoding' => array( '5.4' => true, @@ -108,100 +106,100 @@ class PHPCompatibility_Sniffs_PHP_DeprecatedIniDirectivesSniff extends PHPCompat ), 'register_globals' => array( '5.3' => false, - '5.4' => true + '5.4' => true, ), 'register_long_arrays' => array( '5.3' => false, - '5.4' => true + '5.4' => true, ), 'safe_mode' => array( '5.3' => false, - '5.4' => true + '5.4' => true, ), 'safe_mode_allowed_env_vars' => array( '5.3' => false, - '5.4' => true + '5.4' => true, ), 'safe_mode_exec_dir' => array( '5.3' => false, - '5.4' => true + '5.4' => true, ), 'safe_mode_gid' => array( '5.3' => false, - '5.4' => true + '5.4' => true, ), 'safe_mode_include_dir' => array( '5.3' => false, - '5.4' => true + '5.4' => true, ), 'safe_mode_protected_env_vars' => array( '5.3' => false, - '5.4' => true + '5.4' => true, ), 'session.bug_compat_42' => array( '5.3' => false, - '5.4' => true + '5.4' => true, ), 'session.bug_compat_warn' => array( '5.3' => false, - '5.4' => true + '5.4' => true, ), 'y2k_compliance' => array( '5.3' => false, - '5.4' => true + '5.4' => true, ), 'always_populate_raw_post_data' => array( '5.6' => false, - '7.0' => true + '7.0' => true, ), 'iconv.input_encoding' => array( - '5.6' => false + '5.6' => false, ), 'iconv.output_encoding' => array( - '5.6' => false + '5.6' => false, ), 'iconv.internal_encoding' => array( - '5.6' => false + '5.6' => false, ), 'mbstring.http_input' => array( - '5.6' => false + '5.6' => false, ), 'mbstring.http_output' => array( - '5.6' => false + '5.6' => false, ), 'mbstring.internal_encoding' => array( - '5.6' => false + '5.6' => false, ), 'asp_tags' => array( - '7.0' => true + '7.0' => true, ), 'xsl.security_prefs' => array( - '7.0' => true + '7.0' => true, ), 'mcrypt.algorithms_dir' => array( - '7.1' => false + '7.1' => false, ), 'mcrypt.modes_dir' => array( - '7.1' => false + '7.1' => false, ), 'session.entropy_file' => array( - '7.1' => true + '7.1' => true, ), 'session.entropy_length' => array( - '7.1' => true + '7.1' => true, ), 'session.hash_function' => array( - '7.1' => true + '7.1' => true, ), 'session.hash_bits_per_character' => array( - '7.1' => true + '7.1' => true, ), 'mbstring.func_overload' => array( - '7.2' => false + '7.2' => false, ), ); @@ -230,11 +228,11 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) $tokens = $phpcsFile->getTokens(); $ignore = array( - T_DOUBLE_COLON, - T_OBJECT_OPERATOR, - T_FUNCTION, - T_CONST, - ); + T_DOUBLE_COLON, + T_OBJECT_OPERATOR, + T_FUNCTION, + T_CONST, + ); $prevToken = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true); if (in_array($tokens[$prevToken]['code'], $ignore) === true) { diff --git a/PHPCompatibility/Sniffs/PHP/DeprecatedNewReferenceSniff.php b/PHPCompatibility/Sniffs/PHP/DeprecatedNewReferenceSniff.php index dd8ff5ee..de93722b 100644 --- a/PHPCompatibility/Sniffs/PHP/DeprecatedNewReferenceSniff.php +++ b/PHPCompatibility/Sniffs/PHP/DeprecatedNewReferenceSniff.php @@ -47,23 +47,28 @@ public function register() */ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) { - if ($this->supportsAbove('5.3')) { - $tokens = $phpcsFile->getTokens(); - if ($tokens[$stackPtr - 1]['type'] == 'T_BITWISE_AND' || $tokens[$stackPtr - 2]['type'] == 'T_BITWISE_AND') { - $error = 'Assigning the return value of new by reference is deprecated in PHP 5.3'; - $isError = false; - $errorCode = 'Deprecated'; + if ($this->supportsAbove('5.3') === false) { + return; + } + + $tokens = $phpcsFile->getTokens(); + $prevNonEmpty = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr - 1), null, true); + if ($prevNonEmpty === false || $tokens[$prevNonEmpty]['type'] !== 'T_BITWISE_AND') { + return; + } - if ($this->supportsAbove('7.0') === true) { - $error .= ' and forbidden in PHP 7.0'; - $isError = true; - $errorCode = 'Forbidden'; - } + $error = 'Assigning the return value of new by reference is deprecated in PHP 5.3'; + $isError = false; + $errorCode = 'Deprecated'; - $this->addMessage($phpcsFile, $error, $stackPtr, $isError, $errorCode); - } + if ($this->supportsAbove('7.0') === true) { + $error .= ' and forbidden in PHP 7.0'; + $isError = true; + $errorCode = 'Forbidden'; } + $this->addMessage($phpcsFile, $error, $stackPtr, $isError, $errorCode); + }//end process() }//end class diff --git a/PHPCompatibility/Sniffs/PHP/DeprecatedPHP4StyleConstructorsSniff.php b/PHPCompatibility/Sniffs/PHP/DeprecatedPHP4StyleConstructorsSniff.php index b319eafa..7c1d68df 100644 --- a/PHPCompatibility/Sniffs/PHP/DeprecatedPHP4StyleConstructorsSniff.php +++ b/PHPCompatibility/Sniffs/PHP/DeprecatedPHP4StyleConstructorsSniff.php @@ -4,27 +4,43 @@ * * PHP version 7.0 * - * @category PHP - * @package PHPCompatibility - * @author Koen Eelen + * @category PHP + * @package PHPCompatibility + * @author Koen Eelen */ /** * PHPCompatibility_Sniffs_PHP_DeprecatedPHP4StyleConstructorsSniff. * - * @category PHP - * @package PHPCompatibility - * @author Koen Eelen + * PHP version 7.0 + * + * @category PHP + * @package PHPCompatibility + * @author Koen Eelen */ class PHPCompatibility_Sniffs_PHP_DeprecatedPHP4StyleConstructorsSniff extends PHPCompatibility_Sniff { + /** + * Returns an array of tokens this test wants to listen for. + * + * @return array + */ public function register() { return array(T_CLASS); - }//end register() + } + /** + * Processes this test, when one of its tokens is encountered. + * + * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the current token in the + * stack passed in $tokens. + * + * @return void + */ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) { if ($this->supportsAbove('7.0') === false) { @@ -76,7 +92,7 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) if ($funcNameLc === $classNameLc) { $oldConstructorFound = true; - $oldConstructorPos = $phpcsFile->findNext(T_STRING, $nextFunc); + $oldConstructorPos = $nextFunc; } // If both have been found, no need to continue looping through the functions. diff --git a/PHPCompatibility/Sniffs/PHP/EmptyNonVariableSniff.php b/PHPCompatibility/Sniffs/PHP/EmptyNonVariableSniff.php index b95b85ba..04821172 100644 --- a/PHPCompatibility/Sniffs/PHP/EmptyNonVariableSniff.php +++ b/PHPCompatibility/Sniffs/PHP/EmptyNonVariableSniff.php @@ -4,8 +4,9 @@ * * PHP version 5.5 * - * @category PHP - * @package PHPCompatibility + * @category PHP + * @package PHPCompatibility + * @author Juliette Reinders Folmer */ /** @@ -15,9 +16,9 @@ * * PHP version 5.5 * - * @category PHP - * @package PHPCompatibility - * @author Juliette Reinders Folmer + * @category PHP + * @package PHPCompatibility + * @author Juliette Reinders Folmer */ class PHPCompatibility_Sniffs_PHP_EmptyNonVariableSniff extends PHPCompatibility_Sniff { diff --git a/PHPCompatibility/Sniffs/PHP/ForbiddenBreakContinueOutsideLoopSniff.php b/PHPCompatibility/Sniffs/PHP/ForbiddenBreakContinueOutsideLoopSniff.php index 9eca9bf5..d7afde84 100644 --- a/PHPCompatibility/Sniffs/PHP/ForbiddenBreakContinueOutsideLoopSniff.php +++ b/PHPCompatibility/Sniffs/PHP/ForbiddenBreakContinueOutsideLoopSniff.php @@ -2,7 +2,7 @@ /** * PHPCompatibility_Sniffs_PHP_ForbiddenBreakContinueOutsideLoop. * - * PHP version 7 + * PHP version 7.0 * * @category PHP * @package PHPCompatibility @@ -14,7 +14,7 @@ * * Forbids use of break or continue statements outside of looping structures. * - * PHP version 7 + * PHP version 7.0 * * @category PHP * @package PHPCompatibility @@ -81,8 +81,7 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) return; } } - } - else { + } else { // Deal with older PHPCS versions. if (isset($token['scope_condition']) === true && isset($this->backCompat[$tokens[$token['scope_condition']]['code']]) === true) { return; diff --git a/PHPCompatibility/Sniffs/PHP/ForbiddenBreakContinueVariableArgumentsSniff.php b/PHPCompatibility/Sniffs/PHP/ForbiddenBreakContinueVariableArgumentsSniff.php index a42c3c12..ae12b6a2 100644 --- a/PHPCompatibility/Sniffs/PHP/ForbiddenBreakContinueVariableArgumentsSniff.php +++ b/PHPCompatibility/Sniffs/PHP/ForbiddenBreakContinueVariableArgumentsSniff.php @@ -63,7 +63,7 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) } $tokens = $phpcsFile->getTokens(); - $nextSemicolonToken = $phpcsFile->findNext(T_SEMICOLON, ($stackPtr), null, false); + $nextSemicolonToken = $phpcsFile->findNext(array(T_SEMICOLON, T_CLOSE_TAG), ($stackPtr), null, false); $errorType = ''; for ($curToken = $stackPtr + 1; $curToken < $nextSemicolonToken; $curToken++) { if ($tokens[$curToken]['type'] === 'T_STRING') { @@ -74,12 +74,12 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) $errorType = 'variableArgument'; break; } - } - else if (in_array($tokens[$curToken]['type'], array('T_VARIABLE', 'T_FUNCTION', 'T_CLOSURE'), true)) { + + } elseif (in_array($tokens[$curToken]['type'], array('T_VARIABLE', 'T_FUNCTION', 'T_CLOSURE'), true)) { $errorType = 'variableArgument'; break; - } - else if ($tokens[$curToken]['type'] === 'T_LNUMBER' && $tokens[$curToken]['content'] === '0') { + + } elseif ($tokens[$curToken]['type'] === 'T_LNUMBER' && $tokens[$curToken]['content'] === '0') { $errorType = 'zeroArgument'; break; } diff --git a/PHPCompatibility/Sniffs/PHP/ForbiddenCallTimePassByReferenceSniff.php b/PHPCompatibility/Sniffs/PHP/ForbiddenCallTimePassByReferenceSniff.php index da002a85..04bead8e 100644 --- a/PHPCompatibility/Sniffs/PHP/ForbiddenCallTimePassByReferenceSniff.php +++ b/PHPCompatibility/Sniffs/PHP/ForbiddenCallTimePassByReferenceSniff.php @@ -9,7 +9,6 @@ * @author Gary Rogers * @author Florian Grandel * @copyright 2009 Florian Grandel - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ /** @@ -24,7 +23,6 @@ * @author Gary Rogers * @author Florian Grandel * @copyright 2009 Florian Grandel - * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ class PHPCompatibility_Sniffs_PHP_ForbiddenCallTimePassByReferenceSniff extends PHPCompatibility_Sniff { @@ -61,10 +59,8 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) // within their definitions. For example: function myFunction... // "myFunction" is T_STRING but we should skip because it is not a // function or method *call*. - $findTokens = array_merge( - PHP_CodeSniffer_Tokens::$emptyTokens, - array(T_BITWISE_AND) - ); + $findTokens = PHP_CodeSniffer_Tokens::$emptyTokens; + $findTokens[] = T_BITWISE_AND; $prevNonEmpty = $phpcsFile->findPrevious( $findTokens, @@ -87,7 +83,7 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) ); if ($openBracket === false || $tokens[$openBracket]['code'] !== T_OPEN_PARENTHESIS - || isset($tokens[$openBracket]['parenthesis_closer']) === false + || isset($tokens[$openBracket]['parenthesis_closer']) === false ) { return; } @@ -111,7 +107,7 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) $isError = false; $errorCode = 'Deprecated'; - if($this->supportsAbove('5.4')) { + if ($this->supportsAbove('5.4')) { $error .= ' and prohibited since PHP 5.4'; $isError = true; $errorCode = 'NotAllowed'; @@ -123,6 +119,16 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) }//end process() + /** + * Determine whether a parameter is passed by reference. + * + * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. + * @param array $parameter Information on the current parameter + * to be examined. + * @param int $nestingLevel Target nesting level. + * + * @return bool + */ protected function isCallTimePassByReferenceParam(PHP_CodeSniffer_File $phpcsFile, $parameter, $nestingLevel) { $tokens = $phpcsFile->getTokens(); @@ -138,8 +144,8 @@ protected function isCallTimePassByReferenceParam(PHP_CodeSniffer_File $phpcsFil // Make sure the variable belongs directly to this function call // and is not inside a nested function call or array. - if (isset($tokens[$nextVariable]['nested_parenthesis']) === false || - (count($tokens[$nextVariable]['nested_parenthesis']) !== $nestingLevel) + if (isset($tokens[$nextVariable]['nested_parenthesis']) === false + || (count($tokens[$nextVariable]['nested_parenthesis']) !== $nestingLevel) ) { continue; } @@ -210,15 +216,15 @@ protected function isCallTimePassByReferenceParam(PHP_CodeSniffer_File $phpcsFil $searchStartToken, true ); - if ($tokens[$tokenBeforePlus]['code'] === T_DOUBLE_COLON || - $tokens[$tokenBeforePlus]['code'] === T_OBJECT_OPERATOR + if ($tokens[$tokenBeforePlus]['code'] === T_DOUBLE_COLON + || $tokens[$tokenBeforePlus]['code'] === T_OBJECT_OPERATOR ) { break; } // If not a class constant: fall through. default: - // Deal with T_POW_EQUAL which doesn't exist in PHPCS 1.x + // Deal with T_POW_EQUAL which doesn't exist in PHPCS 1.x. if (defined('T_POW_EQUAL') && $tokens[$tokenBefore]['type'] === 'T_POW_EQUAL') { break; } @@ -226,8 +232,7 @@ protected function isCallTimePassByReferenceParam(PHP_CodeSniffer_File $phpcsFil // The found T_BITWISE_AND represents a pass-by-reference. return true; } - - } while($nextVariable < $searchEndToken); + } while ($nextVariable < $searchEndToken); // This code should never be reached, but here in case of weird bugs ;-) return false; diff --git a/PHPCompatibility/Sniffs/PHP/ForbiddenClosureUseVariableNamesSniff.php b/PHPCompatibility/Sniffs/PHP/ForbiddenClosureUseVariableNamesSniff.php index 357cb8b2..285c0e3f 100644 --- a/PHPCompatibility/Sniffs/PHP/ForbiddenClosureUseVariableNamesSniff.php +++ b/PHPCompatibility/Sniffs/PHP/ForbiddenClosureUseVariableNamesSniff.php @@ -47,67 +47,67 @@ public function register() public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) { if ($this->supportsAbove('7.1') === false) { - return; - } - - $tokens = $phpcsFile->getTokens(); - - // Verify this use statement is used with a closure - if so, it has to have parenthesis before it. - $previousNonEmpty = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr - 1), null, true, null, true); - if ($previousNonEmpty === false || $tokens[$previousNonEmpty]['code'] !== T_CLOSE_PARENTHESIS - || isset($tokens[$previousNonEmpty]['parenthesis_opener']) === false - ) { - return; - } - - // ... and (a variable within) parenthesis after it. - $nextNonEmpty = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr + 1), null, true, null, true); - if ($nextNonEmpty === false || $tokens[$nextNonEmpty]['code'] !== T_OPEN_PARENTHESIS) { - return; - } - - if (isset($tokens[$nextNonEmpty]['parenthesis_closer']) === false) { - // Live coding. - return; - } - - $closurePtr = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($tokens[$previousNonEmpty]['parenthesis_opener'] - 1), null, true ); - if ($tokens[$closurePtr]['code'] !== T_CLOSURE) { - return; - } - - // Get the parameters declared by the closure. - $closureParams = $this->getMethodParameters($phpcsFile, $closurePtr); - - $errorMsg = 'Variables bound to a closure via the use construct cannot use the same name as superglobals, $this, or a declared parameter since PHP 7.1. Found: %s'; - - for ($i = ($nextNonEmpty + 1); $i < $tokens[$nextNonEmpty]['parenthesis_closer']; $i++) { - if ($tokens[$i]['code'] !== T_VARIABLE) { - continue; - } - - $variableName = $tokens[$i]['content']; - - if ($variableName === '$this') { - $phpcsFile->addError($errorMsg, $i, 'FoundThis', array($variableName)); - continue; - } - - if (in_array($variableName, $this->superglobals, true) === true) { - $phpcsFile->addError($errorMsg, $i, 'FoundSuperglobal', array($variableName)); - continue; - } - - // Check whether it is one of the parameters declared by the closure. - if (empty($closureParams) === false) { - foreach ($closureParams as $param) { - if ($param['name'] === $variableName) { - $phpcsFile->addError($errorMsg, $i, 'FoundShadowParam', array($variableName)); - continue 2; - } - } - } - } + return; + } + + $tokens = $phpcsFile->getTokens(); + + // Verify this use statement is used with a closure - if so, it has to have parenthesis before it. + $previousNonEmpty = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr - 1), null, true, null, true); + if ($previousNonEmpty === false || $tokens[$previousNonEmpty]['code'] !== T_CLOSE_PARENTHESIS + || isset($tokens[$previousNonEmpty]['parenthesis_opener']) === false + ) { + return; + } + + // ... and (a variable within) parenthesis after it. + $nextNonEmpty = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr + 1), null, true, null, true); + if ($nextNonEmpty === false || $tokens[$nextNonEmpty]['code'] !== T_OPEN_PARENTHESIS) { + return; + } + + if (isset($tokens[$nextNonEmpty]['parenthesis_closer']) === false) { + // Live coding. + return; + } + + $closurePtr = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($tokens[$previousNonEmpty]['parenthesis_opener'] - 1), null, true); + if ($closurePtr === false || $tokens[$closurePtr]['code'] !== T_CLOSURE) { + return; + } + + // Get the parameters declared by the closure. + $closureParams = $this->getMethodParameters($phpcsFile, $closurePtr); + + $errorMsg = 'Variables bound to a closure via the use construct cannot use the same name as superglobals, $this, or a declared parameter since PHP 7.1. Found: %s'; + + for ($i = ($nextNonEmpty + 1); $i < $tokens[$nextNonEmpty]['parenthesis_closer']; $i++) { + if ($tokens[$i]['code'] !== T_VARIABLE) { + continue; + } + + $variableName = $tokens[$i]['content']; + + if ($variableName === '$this') { + $phpcsFile->addError($errorMsg, $i, 'FoundThis', array($variableName)); + continue; + } + + if (in_array($variableName, $this->superglobals, true) === true) { + $phpcsFile->addError($errorMsg, $i, 'FoundSuperglobal', array($variableName)); + continue; + } + + // Check whether it is one of the parameters declared by the closure. + if (empty($closureParams) === false) { + foreach ($closureParams as $param) { + if ($param['name'] === $variableName) { + $phpcsFile->addError($errorMsg, $i, 'FoundShadowParam', array($variableName)); + continue 2; + } + } + } + } }//end process() diff --git a/PHPCompatibility/Sniffs/PHP/ForbiddenEmptyListAssignmentSniff.php b/PHPCompatibility/Sniffs/PHP/ForbiddenEmptyListAssignmentSniff.php index 15cb9df8..f9eaf01e 100644 --- a/PHPCompatibility/Sniffs/PHP/ForbiddenEmptyListAssignmentSniff.php +++ b/PHPCompatibility/Sniffs/PHP/ForbiddenEmptyListAssignmentSniff.php @@ -4,9 +4,9 @@ * * PHP version 7.0 * - * @category PHP - * @package PHPCompatibility - * @author Wim Godden + * @category PHP + * @package PHPCompatibility + * @author Wim Godden */ /** @@ -16,9 +16,9 @@ * * PHP version 7.0 * - * @category PHP - * @package PHPCompatibility - * @author Wim Godden + * @category PHP + * @package PHPCompatibility + * @author Wim Godden */ class PHPCompatibility_Sniffs_PHP_ForbiddenEmptyListAssignmentSniff extends PHPCompatibility_Sniff { @@ -72,10 +72,11 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) $close = $tokens[$open]['parenthesis_closer']; $error = true; - if(($close - $open) > 1) { + if (($close - $open) > 1) { for ($cnt = $open + 1; $cnt < $close; $cnt++) { if (isset($this->ignoreTokens[$tokens[$cnt]['code']]) === false) { $error = false; + break; } } } diff --git a/PHPCompatibility/Sniffs/PHP/ForbiddenFunctionParametersWithSameNameSniff.php b/PHPCompatibility/Sniffs/PHP/ForbiddenFunctionParametersWithSameNameSniff.php index 9f7e25c8..5d4343e0 100644 --- a/PHPCompatibility/Sniffs/PHP/ForbiddenFunctionParametersWithSameNameSniff.php +++ b/PHPCompatibility/Sniffs/PHP/ForbiddenFunctionParametersWithSameNameSniff.php @@ -4,9 +4,9 @@ * * PHP version 7.0 * - * @category PHP - * @package PHPCompatibility - * @author Wim Godden + * @category PHP + * @package PHPCompatibility + * @author Wim Godden */ /** @@ -16,9 +16,9 @@ * * PHP version 7.0 * - * @category PHP - * @package PHPCompatibility - * @author Wim Godden + * @category PHP + * @package PHPCompatibility + * @author Wim Godden */ class PHPCompatibility_Sniffs_PHP_ForbiddenFunctionParametersWithSameNameSniff extends PHPCompatibility_Sniff { @@ -71,7 +71,7 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) $paramNames[] = strtolower($param['name']); } - if (count($paramNames) != count(array_unique($paramNames))) { + if (count($paramNames) !== count(array_unique($paramNames))) { $phpcsFile->addError( 'Functions can not have multiple parameters with the same name since PHP 7.0', $stackPtr, diff --git a/PHPCompatibility/Sniffs/PHP/ForbiddenGlobalVariableVariableSniff.php b/PHPCompatibility/Sniffs/PHP/ForbiddenGlobalVariableVariableSniff.php index c11895de..0ff87e1a 100644 --- a/PHPCompatibility/Sniffs/PHP/ForbiddenGlobalVariableVariableSniff.php +++ b/PHPCompatibility/Sniffs/PHP/ForbiddenGlobalVariableVariableSniff.php @@ -4,9 +4,9 @@ * * PHP version 7.0 * - * @category PHP - * @package PHPCompatibility - * @author Wim Godden + * @category PHP + * @package PHPCompatibility + * @author Wim Godden */ /** @@ -16,9 +16,9 @@ * * PHP version 7.0 * - * @category PHP - * @package PHPCompatibility - * @author Wim Godden + * @category PHP + * @package PHPCompatibility + * @author Wim Godden */ class PHPCompatibility_Sniffs_PHP_ForbiddenGlobalVariableVariableSniff extends PHPCompatibility_Sniff { @@ -49,7 +49,7 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) } $tokens = $phpcsFile->getTokens(); - $endOfStatement = $phpcsFile->findNext(T_SEMICOLON, ($stackPtr + 1)); + $endOfStatement = $phpcsFile->findNext(array(T_SEMICOLON, T_CLOSE_TAG), ($stackPtr + 1)); if ($endOfStatement === false) { // No semi-colon - live coding. return; diff --git a/PHPCompatibility/Sniffs/PHP/ForbiddenNamesAsDeclaredSniff.php b/PHPCompatibility/Sniffs/PHP/ForbiddenNamesAsDeclaredSniff.php index d36b0569..0587ff6c 100644 --- a/PHPCompatibility/Sniffs/PHP/ForbiddenNamesAsDeclaredSniff.php +++ b/PHPCompatibility/Sniffs/PHP/ForbiddenNamesAsDeclaredSniff.php @@ -2,7 +2,7 @@ /** * PHPCompatibility_Sniffs_PHP_ForbiddenNamesAsDeclaredClassSniff. * - * PHP version 7 + * PHP version 7.0+ * * @category PHP * @package PHPCompatibility @@ -17,7 +17,7 @@ * * @see http://php.net/manual/en/reserved.other-reserved-words.php * - * PHP version 7 + * PHP version 7.0+ * * @category PHP * @package PHPCompatibility @@ -34,7 +34,7 @@ class PHPCompatibility_Sniffs_PHP_ForbiddenNamesAsDeclaredSniff extends PHPCompa protected $forbiddenTokens = array( T_NULL => '7.0', T_TRUE => '7.0', - T_FALSE => '7.0' + T_FALSE => '7.0', ); /** @@ -148,7 +148,7 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) return; } - } else if ($tokenCode === T_NAMESPACE) { + } elseif ($tokenCode === T_NAMESPACE) { $namespaceName = $this->getDeclaredNamespaceName($phpcsFile, $stackPtr); if ($namespaceName === false || $namespaceName === '') { @@ -164,7 +164,7 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) break; } } - } else if ($tokenCode === T_STRING) { + } elseif ($tokenCode === T_STRING) { // Traits and namespaces which are not yet tokenized as T_TRAIT/T_NAMESPACE. $nextNonEmpty = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr + 1), null, true); if ($nextNonEmpty === false) { @@ -176,8 +176,11 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) if ($nextNonEmptyCode !== T_STRING && isset($this->forbiddenTokens[$nextNonEmptyCode]) === true) { $name = $tokens[$nextNonEmpty]['content']; $nameLc = strtolower($tokens[$nextNonEmpty]['content']); - } else if ($nextNonEmptyCode === T_STRING) { + } elseif ($nextNonEmptyCode === T_STRING) { $endOfStatement = $phpcsFile->findNext(array(T_SEMICOLON, T_OPEN_CURLY_BRACKET), ($stackPtr + 1)); + if ($endOfStatement === false) { + return; + } do { $nextNonEmptyLc = strtolower($tokens[$nextNonEmpty]['content']); diff --git a/PHPCompatibility/Sniffs/PHP/ForbiddenNamesAsInvokedFunctionsSniff.php b/PHPCompatibility/Sniffs/PHP/ForbiddenNamesAsInvokedFunctionsSniff.php index 0f8d6f51..ee758601 100644 --- a/PHPCompatibility/Sniffs/PHP/ForbiddenNamesAsInvokedFunctionsSniff.php +++ b/PHPCompatibility/Sniffs/PHP/ForbiddenNamesAsInvokedFunctionsSniff.php @@ -2,8 +2,6 @@ /** * PHPCompatibility_Sniffs_PHP_ForbiddenNamesAsInvokedFunctionsSniff. * - * PHP version 5.4 - * * @category PHP * @package PHPCompatibility * @author Jansen Price @@ -15,8 +13,6 @@ * * Prohibits the use of reserved keywords invoked as functions. * - * PHP version 5.4 - * * @category PHP * @package PHPCompatibility * @author Jansen Price @@ -63,7 +59,7 @@ class PHPCompatibility_Sniffs_PHP_ForbiddenNamesAsInvokedFunctionsSniff extends 'callable' => '5.4', 'insteadof' => '5.4', 'trait' => '5.4', - 'finally' => '5.5' + 'finally' => '5.5', ); /** @@ -125,12 +121,12 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) // after it, but only if it is preceded by a right curly brace. if ($tokenCode === T_CATCH) { if ($prev !== false && $tokens[$prev]['code'] === T_CLOSE_CURLY_BRACKET) { - // Ok, it's fine + // Ok, it's fine. return; } } - if ($isString) { + if ($isString === true) { $version = $this->targetedStringTokens[$tokenContentLc]; } else { $version = $this->targetedTokens[$tokenCode]; diff --git a/PHPCompatibility/Sniffs/PHP/ForbiddenNamesSniff.php b/PHPCompatibility/Sniffs/PHP/ForbiddenNamesSniff.php index e946d2ba..c4744853 100644 --- a/PHPCompatibility/Sniffs/PHP/ForbiddenNamesSniff.php +++ b/PHPCompatibility/Sniffs/PHP/ForbiddenNamesSniff.php @@ -2,8 +2,6 @@ /** * PHPCompatibility_Sniffs_PHP_ForbiddenNamesSniff. * - * PHP version 5.4 - * * @category PHP * @package PHPCompatibility * @author Wim Godden @@ -15,8 +13,6 @@ * * Prohibits the use of reserved keywords as class, function, namespace or constant names. * - * PHP version 5.4 - * * @category PHP * @package PHPCompatibility * @author Wim Godden @@ -116,7 +112,7 @@ class PHPCompatibility_Sniffs_PHP_ForbiddenNamesSniff extends PHPCompatibility_S private $allowed_modifiers = array(); /** - * targetedTokens + * Targeted tokens. * * @var array */ @@ -143,7 +139,8 @@ public function register() $this->isLowPHPCS = version_compare(PHP_CodeSniffer::VERSION, '2.0', '<'); $this->allowed_modifiers = array_combine( - PHP_CodeSniffer_Tokens::$scopeModifiers, PHP_CodeSniffer_Tokens::$scopeModifiers + PHP_CodeSniffer_Tokens::$scopeModifiers, + PHP_CodeSniffer_Tokens::$scopeModifiers ); $this->allowed_modifiers[T_FINAL] = T_FINAL; @@ -167,7 +164,7 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); - /** + /* * We distinguish between the class, function and namespace names vs the define statements. */ if ($tokens[$stackPtr]['type'] === 'T_STRING') { @@ -212,7 +209,7 @@ public function processNonString(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $to * - `use function HelloWorld` => move to the next token (HelloWorld) to verify. * - `use const HelloWorld` => move to the next token (HelloWorld) to verify. */ - else if ($tokens[$stackPtr]['type'] === 'T_USE' + elseif ($tokens[$stackPtr]['type'] === 'T_USE' && isset($this->validUseNames[strtolower($tokens[$nextNonEmpty]['content'])]) === true ) { $maybeUseNext = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($nextNonEmpty + 1), null, true, null, true); @@ -230,7 +227,7 @@ public function processNonString(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $to * - `use HelloWorld { sayHello as protected; }` => valid, bow out. * - `use HelloWorld { sayHello as private myPrivateHello; }` => move to the next token to verify. */ - else if ($tokens[$stackPtr]['type'] === 'T_AS' + elseif ($tokens[$stackPtr]['type'] === 'T_AS' && isset($this->allowed_modifiers[$tokens[$nextNonEmpty]['code']]) === true && $this->inUseScope($phpcsFile, $stackPtr) === true ) { @@ -245,7 +242,7 @@ public function processNonString(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $to /* * Deal with functions declared to return by reference. */ - else if ($tokens[$stackPtr]['type'] === 'T_FUNCTION' + elseif ($tokens[$stackPtr]['type'] === 'T_FUNCTION' && $tokens[$nextNonEmpty]['type'] === 'T_BITWISE_AND' ) { $maybeUseNext = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($nextNonEmpty + 1), null, true, null, true); @@ -260,7 +257,7 @@ public function processNonString(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $to /* * Deal with nested namespaces. */ - else if ($tokens[$stackPtr]['type'] === 'T_NAMESPACE') { + elseif ($tokens[$stackPtr]['type'] === 'T_NAMESPACE') { if ($tokens[$stackPtr + 1]['code'] === T_NS_SEPARATOR) { // Not a namespace declaration, but use of, i.e. namespace\someFunction(); return; @@ -301,15 +298,12 @@ public function processNonString(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $to * "As of PHP 7.0.0 these keywords are allowed as property, constant, and method names * of classes, interfaces and traits, except that class may not be used as constant name." */ - if ( - (( - $tokens[$stackPtr]['type'] === 'T_FUNCTION' - && $this->inClassScope($phpcsFile, $stackPtr, false) === true - ) || ( - $tokens[$stackPtr]['type'] === 'T_CONST' + if ((($tokens[$stackPtr]['type'] === 'T_FUNCTION' + && $this->inClassScope($phpcsFile, $stackPtr, false) === true) + || ($tokens[$stackPtr]['type'] === 'T_CONST' && $this->isClassConstant($phpcsFile, $stackPtr) === true - && $nextContentLc !== 'class' - )) && $this->supportsBelow('5.6') === false + && $nextContentLc !== 'class') + ) && $this->supportsBelow('5.6') === false ) { return; } diff --git a/PHPCompatibility/Sniffs/PHP/ForbiddenNegativeBitshiftSniff.php b/PHPCompatibility/Sniffs/PHP/ForbiddenNegativeBitshiftSniff.php index 3a022106..cbde790e 100644 --- a/PHPCompatibility/Sniffs/PHP/ForbiddenNegativeBitshiftSniff.php +++ b/PHPCompatibility/Sniffs/PHP/ForbiddenNegativeBitshiftSniff.php @@ -4,9 +4,9 @@ * * PHP version 7.0 * - * @category PHP - * @package PHPCompatibility - * @author Wim Godden + * @category PHP + * @package PHPCompatibility + * @author Wim Godden */ /** @@ -14,9 +14,11 @@ * * Bitwise shifts by negative number will throw an ArithmeticError in PHP 7.0. * - * @category PHP - * @package PHPCompatibility - * @author Wim Godden + * PHP version 7.0 + * + * @category PHP + * @package PHPCompatibility + * @author Wim Godden */ class PHPCompatibility_Sniffs_PHP_ForbiddenNegativeBitshiftSniff extends PHPCompatibility_Sniff { @@ -48,12 +50,12 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) } $nextNumber = $phpcsFile->findNext(T_LNUMBER, $stackPtr + 1, null, false, null, true); - if($nextNumber === false || ($stackPtr + 1) === $nextNumber) { + if ($nextNumber === false || ($stackPtr + 1) === $nextNumber) { return; } $hasMinusSign = $phpcsFile->findNext(T_MINUS, $stackPtr + 1, $nextNumber, false, null, true); - if($hasMinusSign === false) { + if ($hasMinusSign === false) { return; } diff --git a/PHPCompatibility/Sniffs/PHP/ForbiddenSwitchWithMultipleDefaultBlocksSniff.php b/PHPCompatibility/Sniffs/PHP/ForbiddenSwitchWithMultipleDefaultBlocksSniff.php index 472c8549..b99cb554 100644 --- a/PHPCompatibility/Sniffs/PHP/ForbiddenSwitchWithMultipleDefaultBlocksSniff.php +++ b/PHPCompatibility/Sniffs/PHP/ForbiddenSwitchWithMultipleDefaultBlocksSniff.php @@ -4,9 +4,9 @@ * * PHP version 7.0 * - * @category PHP - * @package PHPCompatibility - * @author Wim Godden + * @category PHP + * @package PHPCompatibility + * @author Wim Godden */ /** @@ -16,9 +16,9 @@ * * PHP version 7.0 * - * @category PHP - * @package PHPCompatibility - * @author Wim Godden + * @category PHP + * @package PHPCompatibility + * @author Wim Godden */ class PHPCompatibility_Sniffs_PHP_ForbiddenSwitchWithMultipleDefaultBlocksSniff extends PHPCompatibility_Sniff { @@ -57,7 +57,7 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) $defaultToken = $stackPtr; $defaultCount = 0; $targetLevel = $tokens[$stackPtr]['level'] + 1; - while ($defaultCount < 2 && $defaultToken = $phpcsFile->findNext(array(T_DEFAULT), $defaultToken + 1, $tokens[$stackPtr]['scope_closer'])) { + while ($defaultCount < 2 && ($defaultToken = $phpcsFile->findNext(array(T_DEFAULT), $defaultToken + 1, $tokens[$stackPtr]['scope_closer'])) !== false) { // Same level or one below (= two default cases after each other). if ($tokens[$defaultToken]['level'] === $targetLevel || $tokens[$defaultToken]['level'] === ($targetLevel + 1)) { $defaultCount++; diff --git a/PHPCompatibility/Sniffs/PHP/InternalInterfacesSniff.php b/PHPCompatibility/Sniffs/PHP/InternalInterfacesSniff.php index de9e0456..7ef586e1 100644 --- a/PHPCompatibility/Sniffs/PHP/InternalInterfacesSniff.php +++ b/PHPCompatibility/Sniffs/PHP/InternalInterfacesSniff.php @@ -2,19 +2,17 @@ /** * PHPCompatibility_Sniffs_PHP_InternalInterfacesSniff. * - * PHP version 5.5 - * - * @category PHP - * @package PHPCompatibility - * @author Juliette Reinders Folmer + * @category PHP + * @package PHPCompatibility + * @author Juliette Reinders Folmer */ /** * PHPCompatibility_Sniffs_PHP_InternalInterfacesSniff. * - * @category PHP - * @package PHPCompatibility - * @author Juliette Reinders Folmer + * @category PHP + * @package PHPCompatibility + * @author Juliette Reinders Folmer */ class PHPCompatibility_Sniffs_PHP_InternalInterfacesSniff extends PHPCompatibility_Sniff { diff --git a/PHPCompatibility/Sniffs/PHP/LateStaticBindingSniff.php b/PHPCompatibility/Sniffs/PHP/LateStaticBindingSniff.php index 5444db96..99a98a25 100644 --- a/PHPCompatibility/Sniffs/PHP/LateStaticBindingSniff.php +++ b/PHPCompatibility/Sniffs/PHP/LateStaticBindingSniff.php @@ -2,17 +2,21 @@ /** * PHPCompatibility_Sniffs_PHP_LateStaticBindingSniff. * - * @category PHP - * @package PHPCompatibility - * @author Juliette Reinders Folmer + * PHP version 5.3 + * + * @category PHP + * @package PHPCompatibility + * @author Juliette Reinders Folmer */ /** * PHPCompatibility_Sniffs_PHP_LateStaticBindingSniff. * - * @category PHP - * @package PHPCompatibility - * @author Juliette Reinders Folmer + * PHP version 5.3 + * + * @category PHP + * @package PHPCompatibility + * @author Juliette Reinders Folmer */ class PHPCompatibility_Sniffs_PHP_LateStaticBindingSniff extends PHPCompatibility_Sniff { diff --git a/PHPCompatibility/Sniffs/PHP/LongArraysSniff.php b/PHPCompatibility/Sniffs/PHP/LongArraysSniff.php deleted file mode 100644 index fdebf384..00000000 --- a/PHPCompatibility/Sniffs/PHP/LongArraysSniff.php +++ /dev/null @@ -1,114 +0,0 @@ - - * @copyright 2012 Ben Selby - */ - -/** - * PHPCompatibility_Sniffs_PHP_LongArraysSniff. - * - * Marks the use of HTTP_*_VARS as deprecated - * - * PHP version 5.3 - * - * @category PHP - * @package PHPCompatibility - * @author Ben Selby - * @copyright 2012 Ben Selby - */ -class PHPCompatibility_Sniffs_PHP_LongArraysSniff extends PHPCompatibility_Sniff -{ - /** - * Array of HTTP_*_VARS that are now deprecated - * - * @var array - */ - protected $deprecated = array( - 'HTTP_POST_VARS', - 'HTTP_GET_VARS', - 'HTTP_ENV_VARS', - 'HTTP_SERVER_VARS', - 'HTTP_COOKIE_VARS', - 'HTTP_SESSION_VARS', - 'HTTP_POST_FILES' - ); - - /** - * Returns an array of tokens this test wants to listen for. - * - * @return array - */ - public function register() - { - return array(T_VARIABLE); - } - - /** - * Processes this test, when one of its tokens is encountered. - * - * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. - * @param int $stackPtr The position of the current token in the - * stack passed in $tokens. - * - * @return void - */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) - { - if ($this->supportsAbove('5.3') === false) { - return; - } - - $tokens = $phpcsFile->getTokens(); - $varName = substr($tokens[$stackPtr]['content'], 1); - - // Check if the variable name is in our blacklist. - if (in_array($varName, $this->deprecated, true) === false) { - return; - } - - if ($this->inClassScope($phpcsFile, $stackPtr, false) === true) { - /* - * Check for class property definitions. - */ - $properties = array(); - try { - $properties = $phpcsFile->getMemberProperties($stackPtr); - } catch ( PHP_CodeSniffer_Exception $e) { - // If it's not an expected exception, throw it. - if ($e->getMessage() !== '$stackPtr is not a class member var') { - throw $e; - } - } - - if (isset($properties['scope'])) { - // Ok, so this was a class property declaration, not our concern. - return; - } - - /* - * Check for static usage of class properties shadowing the long arrays. - */ - $prevToken = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr - 1), null, true, null, true); - if ($tokens[$prevToken]['code'] === T_DOUBLE_COLON) { - return; - } - } - - // Still here, so throw an error/warning. - $error = "The use of long predefined variables has been deprecated in PHP 5.3%s; Found '%s'"; - $isError = $this->supportsAbove('5.4'); - $errorCode = $this->stringToErrorCode($varName).'Found'; - $data = array( - (($isError === true) ? ' and removed in PHP 5.4' : ''), - $tokens[$stackPtr]['content'], - ); - - $this->addMessage($phpcsFile, $error, $stackPtr, $isError, $errorCode, $data); - } -} diff --git a/PHPCompatibility/Sniffs/PHP/MbstringReplaceEModifierSniff.php b/PHPCompatibility/Sniffs/PHP/MbstringReplaceEModifierSniff.php index 21a270e1..0b1a6756 100644 --- a/PHPCompatibility/Sniffs/PHP/MbstringReplaceEModifierSniff.php +++ b/PHPCompatibility/Sniffs/PHP/MbstringReplaceEModifierSniff.php @@ -4,17 +4,19 @@ * * PHP version 7.1 * - * @category PHP - * @package PHPCompatibility - * @author Juliette Reinders Folmer + * @category PHP + * @package PHPCompatibility + * @author Juliette Reinders Folmer */ /** * PHPCompatibility_Sniffs_PHP_MbstringReplaceEModifierSniff. * - * @category PHP - * @package PHPCompatibility - * @author Juliette Reinders Folmer + * PHP version 7.1 + * + * @category PHP + * @package PHPCompatibility + * @author Juliette Reinders Folmer */ class PHPCompatibility_Sniffs_PHP_MbstringReplaceEModifierSniff extends PHPCompatibility_Sniff { @@ -63,7 +65,7 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) $functionNameLc = strtolower($tokens[$stackPtr]['content']); // Bow out if not one of the functions we're targetting. - if ( isset($this->functions[$functionNameLc]) === false ) { + if (isset($this->functions[$functionNameLc]) === false) { return; } @@ -81,7 +83,7 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) $options = ''; - /** + /* * Get the content of any string tokens in the options parameter and remove the quotes and variables. */ for ($i = $stringToken; $i <= $optionsParam['end']; $i++) { @@ -103,7 +105,7 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) if (strpos($options, 'e') !== false) { $error = 'The Mbstring regex "e" modifier is deprecated since PHP 7.1.'; - // The alternative mb_ereg_replace_callback() function is only available since 5.4.1 + // The alternative mb_ereg_replace_callback() function is only available since 5.4.1. if ($this->supportsBelow('5.4.1') === false) { $error .= ' Use mb_ereg_replace_callback() instead (PHP 5.4.1+).'; } diff --git a/PHPCompatibility/Sniffs/PHP/NewAnonymousClassesSniff.php b/PHPCompatibility/Sniffs/PHP/NewAnonymousClassesSniff.php index 3a8ec94b..5e006798 100644 --- a/PHPCompatibility/Sniffs/PHP/NewAnonymousClassesSniff.php +++ b/PHPCompatibility/Sniffs/PHP/NewAnonymousClassesSniff.php @@ -4,9 +4,9 @@ * * PHP version 7.0 * - * @category PHP - * @package PHPCompatibility - * @author Wim Godden + * @category PHP + * @package PHPCompatibility + * @author Wim Godden */ /** @@ -14,13 +14,23 @@ * * Anonymous classes are supported in PHP 7.0 * - * @category PHP - * @package PHPCompatibility - * @author Wim Godden + * PHP version 7.0 + * + * @category PHP + * @package PHPCompatibility + * @author Wim Godden */ class PHPCompatibility_Sniffs_PHP_NewAnonymousClassesSniff extends PHPCompatibility_Sniff { + /** + * Tokens which in various PHP versions indicate the `class` keyword. + * + * The dedicated anonymous class token is added from the `register()` + * method if the token is available. + * + * @var array + */ private $indicators = array( T_CLASS => T_CLASS, ); diff --git a/PHPCompatibility/Sniffs/PHP/NewArrayStringDereferencingSniff.php b/PHPCompatibility/Sniffs/PHP/NewArrayStringDereferencingSniff.php index 1e973606..985f360a 100644 --- a/PHPCompatibility/Sniffs/PHP/NewArrayStringDereferencingSniff.php +++ b/PHPCompatibility/Sniffs/PHP/NewArrayStringDereferencingSniff.php @@ -53,7 +53,7 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) $tokens = $phpcsFile->getTokens(); - switch($tokens[$stackPtr]['code']) { + switch ($tokens[$stackPtr]['code']) { case T_CONSTANT_ENCAPSED_STRING: $type = 'string literals'; $end = $stackPtr; diff --git a/PHPCompatibility/Sniffs/PHP/NewClassesSniff.php b/PHPCompatibility/Sniffs/PHP/NewClassesSniff.php index ab1ad619..5657f457 100644 --- a/PHPCompatibility/Sniffs/PHP/NewClassesSniff.php +++ b/PHPCompatibility/Sniffs/PHP/NewClassesSniff.php @@ -2,8 +2,6 @@ /** * PHPCompatibility_Sniffs_PHP_NewClassesSniff. * - * PHP version 5.5 - * * @category PHP * @package PHPCompatibility * @author Wim Godden @@ -16,7 +14,6 @@ * @category PHP * @package PHPCompatibility * @author Wim Godden - * @version 1.0.0 * @copyright 2013 Cu.be Solutions bvba */ class PHPCompatibility_Sniffs_PHP_NewClassesSniff extends PHPCompatibility_AbstractNewFeatureSniff @@ -31,160 +28,160 @@ class PHPCompatibility_Sniffs_PHP_NewClassesSniff extends PHPCompatibility_Abstr * @var array(string => array(string => bool)) */ protected $newClasses = array( - 'libXMLError' => array( - '5.0' => false, - '5.1' => true - ), - - 'DateTime' => array( - '5.1' => false, - '5.2' => true - ), - 'DateTimeZone' => array( - '5.1' => false, - '5.2' => true - ), - 'RegexIterator' => array( - '5.1' => false, - '5.2' => true - ), - 'RecursiveRegexIterator' => array( - '5.1' => false, - '5.2' => true - ), - - 'DateInterval' => array( - '5.2' => false, - '5.3' => true - ), - 'DatePeriod' => array( - '5.2' => false, - '5.3' => true - ), - 'Phar' => array( - '5.2' => false, - '5.3' => true - ), - 'PharData' => array( - '5.2' => false, - '5.3' => true - ), - 'PharFileInfo' => array( - '5.2' => false, - '5.3' => true - ), - 'FilesystemIterator' => array( - '5.2' => false, - '5.3' => true - ), - 'GlobIterator' => array( - '5.2' => false, - '5.3' => true - ), - 'MultipleIterator' => array( - '5.2' => false, - '5.3' => true - ), - 'RecursiveTreeIterator' => array( - '5.2' => false, - '5.3' => true - ), - 'SplDoublyLinkedList' => array( - '5.2' => false, - '5.3' => true - ), - 'SplFixedArray' => array( - '5.2' => false, - '5.3' => true - ), - 'SplHeap' => array( - '5.2' => false, - '5.3' => true - ), - 'SplMaxHeap' => array( - '5.2' => false, - '5.3' => true - ), - 'SplMinHeap' => array( - '5.2' => false, - '5.3' => true - ), - 'SplPriorityQueue' => array( - '5.2' => false, - '5.3' => true - ), - 'SplQueue' => array( - '5.2' => false, - '5.3' => true - ), - 'SplStack' => array( - '5.2' => false, - '5.3' => true - ), - - 'CallbackFilterIterator' => array( - '5.3' => false, - '5.4' => true - ), - 'RecursiveCallbackFilterIterator' => array( - '5.3' => false, - '5.4' => true - ), - 'ReflectionZendExtension' => array( - '5.3' => false, - '5.4' => true - ), - 'SessionHandler' => array( - '5.3' => false, - '5.4' => true - ), - 'SNMP' => array( - '5.3' => false, - '5.4' => true - ), - 'Transliterator' => array( - '5.3' => false, - '5.4' => true - ), - 'Spoofchecker' => array( - '5.3' => false, - '5.4' => true - ), - - 'CURLFile' => array( - '5.4' => false, - '5.5' => true - ), - 'DateTimeImmutable' => array( - '5.4' => false, - '5.5' => true - ), - 'IntlCalendar' => array( - '5.4' => false, - '5.5' => true - ), - 'IntlGregorianCalendar' => array( - '5.4' => false, - '5.5' => true - ), - 'IntlTimeZone' => array( - '5.4' => false, - '5.5' => true - ), - 'IntlBreakIterator' => array( - '5.4' => false, - '5.5' => true - ), - 'IntlRuleBasedBreakIterator' => array( - '5.4' => false, - '5.5' => true - ), - 'IntlCodePointBreakIterator' => array( - '5.4' => false, - '5.5' => true - ), - - ); + 'libXMLError' => array( + '5.0' => false, + '5.1' => true, + ), + + 'DateTime' => array( + '5.1' => false, + '5.2' => true, + ), + 'DateTimeZone' => array( + '5.1' => false, + '5.2' => true, + ), + 'RegexIterator' => array( + '5.1' => false, + '5.2' => true, + ), + 'RecursiveRegexIterator' => array( + '5.1' => false, + '5.2' => true, + ), + + 'DateInterval' => array( + '5.2' => false, + '5.3' => true, + ), + 'DatePeriod' => array( + '5.2' => false, + '5.3' => true, + ), + 'Phar' => array( + '5.2' => false, + '5.3' => true, + ), + 'PharData' => array( + '5.2' => false, + '5.3' => true, + ), + 'PharFileInfo' => array( + '5.2' => false, + '5.3' => true, + ), + 'FilesystemIterator' => array( + '5.2' => false, + '5.3' => true, + ), + 'GlobIterator' => array( + '5.2' => false, + '5.3' => true, + ), + 'MultipleIterator' => array( + '5.2' => false, + '5.3' => true, + ), + 'RecursiveTreeIterator' => array( + '5.2' => false, + '5.3' => true, + ), + 'SplDoublyLinkedList' => array( + '5.2' => false, + '5.3' => true, + ), + 'SplFixedArray' => array( + '5.2' => false, + '5.3' => true, + ), + 'SplHeap' => array( + '5.2' => false, + '5.3' => true, + ), + 'SplMaxHeap' => array( + '5.2' => false, + '5.3' => true, + ), + 'SplMinHeap' => array( + '5.2' => false, + '5.3' => true, + ), + 'SplPriorityQueue' => array( + '5.2' => false, + '5.3' => true, + ), + 'SplQueue' => array( + '5.2' => false, + '5.3' => true, + ), + 'SplStack' => array( + '5.2' => false, + '5.3' => true, + ), + + 'CallbackFilterIterator' => array( + '5.3' => false, + '5.4' => true, + ), + 'RecursiveCallbackFilterIterator' => array( + '5.3' => false, + '5.4' => true, + ), + 'ReflectionZendExtension' => array( + '5.3' => false, + '5.4' => true, + ), + 'SessionHandler' => array( + '5.3' => false, + '5.4' => true, + ), + 'SNMP' => array( + '5.3' => false, + '5.4' => true, + ), + 'Transliterator' => array( + '5.3' => false, + '5.4' => true, + ), + 'Spoofchecker' => array( + '5.3' => false, + '5.4' => true, + ), + + 'CURLFile' => array( + '5.4' => false, + '5.5' => true, + ), + 'DateTimeImmutable' => array( + '5.4' => false, + '5.5' => true, + ), + 'IntlCalendar' => array( + '5.4' => false, + '5.5' => true, + ), + 'IntlGregorianCalendar' => array( + '5.4' => false, + '5.5' => true, + ), + 'IntlTimeZone' => array( + '5.4' => false, + '5.5' => true, + ), + 'IntlBreakIterator' => array( + '5.4' => false, + '5.5' => true, + ), + 'IntlRuleBasedBreakIterator' => array( + '5.4' => false, + '5.5' => true, + ), + 'IntlCodePointBreakIterator' => array( + '5.4' => false, + '5.5' => true, + ), + + ); /** * A list of new Exception classes, not present in older versions. @@ -201,136 +198,134 @@ class PHPCompatibility_Sniffs_PHP_NewClassesSniff extends PHPCompatibility_Abstr */ protected $newExceptions = array( 'Exception' => array( - '5.0' => false, - '5.1' => true + // According to the docs introduced in PHP 5.1, but this appears to be. + // an error. Class was introduced with try/catch keywords in PHP 5.0. + '4.4' => false, + '5.0' => true, ), 'ErrorException' => array( '5.0' => false, - '5.1' => true + '5.1' => true, ), 'BadFunctionCallException' => array( '5.0' => false, - '5.1' => true + '5.1' => true, ), 'BadMethodCallException' => array( '5.0' => false, - '5.1' => true + '5.1' => true, ), 'DomainException' => array( '5.0' => false, - '5.1' => true + '5.1' => true, ), 'InvalidArgumentException' => array( '5.0' => false, - '5.1' => true + '5.1' => true, ), 'LengthException' => array( '5.0' => false, - '5.1' => true + '5.1' => true, ), 'LogicException' => array( '5.0' => false, - '5.1' => true + '5.1' => true, ), 'OutOfBoundsException' => array( '5.0' => false, - '5.1' => true + '5.1' => true, ), 'OutOfRangeException' => array( '5.0' => false, - '5.1' => true + '5.1' => true, ), 'OverflowException' => array( '5.0' => false, - '5.1' => true + '5.1' => true, ), 'RangeException' => array( '5.0' => false, - '5.1' => true + '5.1' => true, ), 'RuntimeException' => array( '5.0' => false, - '5.1' => true + '5.1' => true, ), 'UnderflowException' => array( '5.0' => false, - '5.1' => true + '5.1' => true, ), 'UnexpectedValueException' => array( '5.0' => false, - '5.1' => true + '5.1' => true, ), 'DOMException' => array( - // According to the docs introduced in PHP 5.0, but Exception was only introduced in 5.1. - '5.0' => false, - '5.1' => true + '4.4' => false, + '5.0' => true, ), 'mysqli_sql_exception' => array( - // According to the docs introduced in PHP 5.0, but Exception was only introduced in 5.1. - '5.0' => false, - '5.1' => true + '4.4' => false, + '5.0' => true, ), 'PDOException' => array( '5.0' => false, - '5.1' => true + '5.1' => true, ), 'ReflectionException' => array( - // According to the docs introduced in PHP 5.0, but Exception was only introduced in 5.1. - '5.0' => false, - '5.1' => true + '4.4' => false, + '5.0' => true, ), 'SoapFault' => array( - // According to the docs introduced in PHP 5.0.1, but Exception was only introduced in 5.1. - '5.0' => false, - '5.1' => true + '4.4' => false, + '5.0' => true, ), 'PharException' => array( '5.2' => false, - '5.3' => true + '5.3' => true, ), 'SNMPException' => array( '5.3' => false, - '5.4' => true + '5.4' => true, ), 'IntlException' => array( '5.5.0' => false, - '5.5.1' => true + '5.5.1' => true, ), 'Error' => array( '5.6' => false, - '7.0' => true + '7.0' => true, ), 'ArithmeticError' => array( '5.6' => false, - '7.0' => true + '7.0' => true, ), 'AssertionError' => array( '5.6' => false, - '7.0' => true + '7.0' => true, ), 'DivisionByZeroError' => array( '5.6' => false, - '7.0' => true + '7.0' => true, ), 'ParseError' => array( '5.6' => false, - '7.0' => true + '7.0' => true, ), 'TypeError' => array( '5.6' => false, - '7.0' => true + '7.0' => true, ), 'UI\Exception\InvalidArgumentException' => array( '5.6' => false, - '7.0' => true + '7.0' => true, ), 'UI\Exception\RuntimeException' => array( '5.6' => false, - '7.0' => true + '7.0' => true, ), ); @@ -381,7 +376,7 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); - switch($tokens[$stackPtr]['type']) { + switch ($tokens[$stackPtr]['type']) { case 'T_FUNCTION': case 'T_CLOSURE': $this->processFunctionToken($phpcsFile, $stackPtr); @@ -415,11 +410,11 @@ private function processSingularToken(PHP_CodeSniffer_File $phpcsFile, $stackPtr if ($tokens[$stackPtr]['type'] === 'T_NEW') { $FQClassName = $this->getFQClassNameFromNewToken($phpcsFile, $stackPtr); - } - else if ($tokens[$stackPtr]['type'] === 'T_CLASS' || $tokens[$stackPtr]['type'] === 'T_ANON_CLASS') { + + } elseif ($tokens[$stackPtr]['type'] === 'T_CLASS' || $tokens[$stackPtr]['type'] === 'T_ANON_CLASS') { $FQClassName = $this->getFQExtendedClassName($phpcsFile, $stackPtr); - } - else if ($tokens[$stackPtr]['type'] === 'T_DOUBLE_COLON') { + + } elseif ($tokens[$stackPtr]['type'] === 'T_DOUBLE_COLON') { $FQClassName = $this->getFQClassNameFromDoubleColonToken($phpcsFile, $stackPtr); } @@ -510,7 +505,7 @@ private function processCatchToken(PHP_CodeSniffer_File $phpcsFile, $stackPtr) T_CLOSE_CURLY_BRACKET => false, // Shouldn't be needed as we expect a var before this. ); - for ($i = ($opener + 1); $i < $closer; $i++ ) { + for ($i = ($opener + 1); $i < $closer; $i++) { if (isset($listen[$tokens[$i]['code']]) === false) { continue; } diff --git a/PHPCompatibility/Sniffs/PHP/NewClosureSniff.php b/PHPCompatibility/Sniffs/PHP/NewClosureSniff.php index 2a62d972..a3a036aa 100644 --- a/PHPCompatibility/Sniffs/PHP/NewClosureSniff.php +++ b/PHPCompatibility/Sniffs/PHP/NewClosureSniff.php @@ -4,9 +4,9 @@ * * PHP version 5.3 * - * @category PHP - * @package PHPCompatibility - * @author Wim Godden + * @category PHP + * @package PHPCompatibility + * @author Wim Godden */ /** @@ -16,9 +16,9 @@ * * PHP version 5.3 * - * @category PHP - * @package PHPCompatibility - * @author Wim Godden + * @category PHP + * @package PHPCompatibility + * @author Wim Godden */ class PHPCompatibility_Sniffs_PHP_NewClosureSniff extends PHPCompatibility_Sniff { @@ -44,8 +44,6 @@ public function register() */ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) { - $tokens = $phpcsFile->getTokens(); - if ($this->supportsBelow('5.2')) { $phpcsFile->addError( 'Closures / anonymous functions are not available in PHP 5.2 or earlier', @@ -84,7 +82,7 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) $thisFound = $this->findThisUsageInClosure($phpcsFile, $stackPtr, ($thisFound + 1)); - } while($thisFound !== false); + } while ($thisFound !== false); } } @@ -110,7 +108,7 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) /* * Closures only have access to $this if used within a class context. */ - else if ($this->inClassScope($phpcsFile, $stackPtr, false) === false) { + elseif ($this->inClassScope($phpcsFile, $stackPtr, false) === false) { $phpcsFile->addError( 'Closures / anonymous functions only have access to $this if used within a class', $thisFound, @@ -120,7 +118,7 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) $thisFound = $this->findThisUsageInClosure($phpcsFile, $stackPtr, ($thisFound + 1)); - } while($thisFound !== false); + } while ($thisFound !== false); } }//end process() diff --git a/PHPCompatibility/Sniffs/PHP/NewConstVisibilitySniff.php b/PHPCompatibility/Sniffs/PHP/NewConstVisibilitySniff.php index 4803ad75..2b930379 100644 --- a/PHPCompatibility/Sniffs/PHP/NewConstVisibilitySniff.php +++ b/PHPCompatibility/Sniffs/PHP/NewConstVisibilitySniff.php @@ -4,9 +4,9 @@ * * PHP version 7.1 * - * @category PHP - * @package PHPCompatibility - * @author Juliette Reinders Folmer + * @category PHP + * @package PHPCompatibility + * @author Juliette Reinders Folmer */ /** @@ -16,9 +16,9 @@ * * PHP version 7.1 * - * @category PHP - * @package PHPCompatibility - * @author Juliette Reinders Folmer + * @category PHP + * @package PHPCompatibility + * @author Juliette Reinders Folmer */ class PHPCompatibility_Sniffs_PHP_NewConstVisibilitySniff extends PHPCompatibility_Sniff { diff --git a/PHPCompatibility/Sniffs/PHP/NewExecutionDirectivesSniff.php b/PHPCompatibility/Sniffs/PHP/NewExecutionDirectivesSniff.php index 93060782..217c54e6 100644 --- a/PHPCompatibility/Sniffs/PHP/NewExecutionDirectivesSniff.php +++ b/PHPCompatibility/Sniffs/PHP/NewExecutionDirectivesSniff.php @@ -2,17 +2,17 @@ /** * PHPCompatibility_Sniffs_PHP_NewExecutionDirectivesSniff. * - * @category PHP - * @package PHPCompatibility - * @author Juliette Reinders Folmer + * @category PHP + * @package PHPCompatibility + * @author Juliette Reinders Folmer */ /** * PHPCompatibility_Sniffs_PHP_NewExecutionDirectivesSniff. * - * @category PHP - * @package PHPCompatibility - * @author Juliette Reinders Folmer + * @category PHP + * @package PHPCompatibility + * @author Juliette Reinders Folmer */ class PHPCompatibility_Sniffs_PHP_NewExecutionDirectivesSniff extends PHPCompatibility_AbstractNewFeatureSniff { @@ -26,24 +26,24 @@ class PHPCompatibility_Sniffs_PHP_NewExecutionDirectivesSniff extends PHPCompati * * @var array(string => array(string => int|string|null)) */ - protected $newDirectives = array ( - 'ticks' => array( - '3.1' => false, - '4.0' => true, - 'valid_value_callback' => 'isNumeric', - ), - 'encoding' => array( - '5.2' => false, - '5.3' => '--enable-zend-multibyte', // Directive ignored unless. - '5.4' => true, - 'valid_value_callback' => 'validEncoding', - ), - 'strict_types' => array( - '5.6' => false, - '7.0' => true, - 'valid_values' => array(1), - ), - ); + protected $newDirectives = array( + 'ticks' => array( + '3.1' => false, + '4.0' => true, + 'valid_value_callback' => 'isNumeric', + ), + 'encoding' => array( + '5.2' => false, + '5.3' => '--enable-zend-multibyte', // Directive ignored unless. + '5.4' => true, + 'valid_value_callback' => 'validEncoding', + ), + 'strict_types' => array( + '5.6' => false, + '7.0' => true, + 'valid_values' => array(1), + ), + ); /** @@ -82,21 +82,20 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) $tokens = $phpcsFile->getTokens(); if (isset($tokens[$stackPtr]['parenthesis_opener'], $tokens[$stackPtr]['parenthesis_closer']) === true) { - $openParenthesis = $tokens[$stackPtr]['parenthesis_opener']; - $closeParenthesis = $tokens[$stackPtr]['parenthesis_closer']; + $openParenthesis = $tokens[$stackPtr]['parenthesis_opener']; + $closeParenthesis = $tokens[$stackPtr]['parenthesis_closer']; + } else { + if (version_compare(PHP_CodeSniffer::VERSION, '2.3.4', '>=')) { + return; + } + + // Deal with PHPCS 1.x which does not set the parenthesis properly for declare statements. + $openParenthesis = $phpcsFile->findNext(T_OPEN_PARENTHESIS, ($stackPtr + 1), null, false, null, true); + if ($openParenthesis === false || isset($tokens[$openParenthesis]['parenthesis_closer']) === false) { + return; + } + $closeParenthesis = $tokens[$openParenthesis]['parenthesis_closer']; } - else { - if (version_compare(PHP_CodeSniffer::VERSION, '2.0', '>=')) { - return; - } - - // Deal with PHPCS 1.x which does not set the parenthesis properly for declare statements. - $openParenthesis = $phpcsFile->findNext(T_OPEN_PARENTHESIS, ($stackPtr + 1), null, false, null, true); - if ($openParenthesis === false || isset($tokens[$openParenthesis]['parenthesis_closer']) === false) { - return; - } - $closeParenthesis = $tokens[$openParenthesis]['parenthesis_closer']; - } $directivePtr = $phpcsFile->findNext(T_STRING, ($openParenthesis + 1), $closeParenthesis, false); if ($directivePtr === false) { @@ -113,8 +112,8 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) ); $phpcsFile->addError($error, $stackPtr, 'InvalidDirectiveFound', $data); - } - else { + + } else { // Check for valid directive for version. $itemInfo = array( 'name' => $directiveContent, @@ -230,7 +229,7 @@ public function addError(PHP_CodeSniffer_File $phpcsFile, $stackPtr, array $item { if ($errorInfo['not_in_version'] !== '') { parent::addError($phpcsFile, $stackPtr, $itemInfo, $errorInfo); - } else if ($errorInfo['conditional_version'] !== '') { + } elseif ($errorInfo['conditional_version'] !== '') { $error = 'Directive %s is present in PHP version %s but will be disregarded unless PHP is compiled with %s'; $errorCode = $this->stringToErrorCode($itemInfo['name']).'WithConditionFound'; $data = array( @@ -269,8 +268,7 @@ protected function addWarningOnInvalidValue($phpcsFile, $stackPtr, $directive) if (in_array($value, $this->newDirectives[$directive]['valid_values']) === false) { $isError = true; } - } - else if (isset($this->newDirectives[$directive]['valid_value_callback'])) { + } elseif (isset($this->newDirectives[$directive]['valid_value_callback'])) { $valid = call_user_func(array($this, $this->newDirectives[$directive]['valid_value_callback']), $value); if ($valid === false) { $isError = true; @@ -287,7 +285,7 @@ protected function addWarningOnInvalidValue($phpcsFile, $stackPtr, $directive) $phpcsFile->addWarning($error, $stackPtr, $errorCode, $data); } - }// addErrorOnInvalidValue() + }// addWarningOnInvalidValue() /** diff --git a/PHPCompatibility/Sniffs/PHP/NewFunctionArrayDereferencingSniff.php b/PHPCompatibility/Sniffs/PHP/NewFunctionArrayDereferencingSniff.php index 624b6a1e..686b6abf 100644 --- a/PHPCompatibility/Sniffs/PHP/NewFunctionArrayDereferencingSniff.php +++ b/PHPCompatibility/Sniffs/PHP/NewFunctionArrayDereferencingSniff.php @@ -2,17 +2,21 @@ /** * PHPCompatibility_Sniffs_PHP_NewFunctionArrayDereferencingSniff. * - * @category PHP - * @package PHPCompatibility - * @author Wim Godden + * PHP version 5.4 + * + * @category PHP + * @package PHPCompatibility + * @author Wim Godden */ /** * PHPCompatibility_Sniffs_PHP_NewFunctionArrayDereferencingSniff. * - * @category PHP - * @package PHPCompatibility - * @author Wim Godden + * PHP version 5.4 + * + * @category PHP + * @package PHPCompatibility + * @author Wim Godden */ class PHPCompatibility_Sniffs_PHP_NewFunctionArrayDereferencingSniff extends PHPCompatibility_Sniff { @@ -56,17 +60,17 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) // Is this T_STRING really a function or method call ? $prevToken = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr - 1), null, true); - if($prevToken !== false && in_array($tokens[$prevToken]['code'], array(T_DOUBLE_COLON, T_OBJECT_OPERATOR), true) === false) { + if ($prevToken !== false && in_array($tokens[$prevToken]['code'], array(T_DOUBLE_COLON, T_OBJECT_OPERATOR), true) === false) { $ignore = array( - T_FUNCTION, - T_CONST, - T_USE, - T_NEW, - T_CLASS, - T_INTERFACE, + T_FUNCTION, + T_CONST, + T_USE, + T_NEW, + T_CLASS, + T_INTERFACE, ); - if (in_array($tokens[$prevToken]['code'], $ignore) === true) { + if (in_array($tokens[$prevToken]['code'], $ignore, true) === true) { // Not a call to a PHP function or method. return; } diff --git a/PHPCompatibility/Sniffs/PHP/NewFunctionParametersSniff.php b/PHPCompatibility/Sniffs/PHP/NewFunctionParametersSniff.php index 9e53d592..49e30a73 100644 --- a/PHPCompatibility/Sniffs/PHP/NewFunctionParametersSniff.php +++ b/PHPCompatibility/Sniffs/PHP/NewFunctionParametersSniff.php @@ -2,17 +2,17 @@ /** * PHPCompatibility_Sniffs_PHP_NewFunctionParametersSniff. * - * @category PHP - * @package PHPCompatibility - * @author Wim Godden + * @category PHP + * @package PHPCompatibility + * @author Wim Godden */ /** * PHPCompatibility_Sniffs_PHP_newFunctionParametersSniff. * - * @category PHP - * @package PHPCompatibility - * @author Wim Godden + * @category PHP + * @package PHPCompatibility + * @author Wim Godden */ class PHPCompatibility_Sniffs_PHP_NewFunctionParametersSniff extends PHPCompatibility_AbstractNewFeatureSniff { @@ -26,715 +26,715 @@ class PHPCompatibility_Sniffs_PHP_NewFunctionParametersSniff extends PHPCompatib * @var array */ protected $newFunctionParameters = array( - 'array_filter' => array( - 2 => array( - 'name' => 'flag', - '5.5' => false, - '5.6' => true - ), - ), - 'array_slice' => array( - 1 => array( - 'name' => 'preserve_keys', - '5.0.1' => false, - '5.0.2' => true - ), - ), - 'array_unique' => array( - 1 => array( - 'name' => 'sort_flags', - '5.2.8' => false, - '5.2.9' => true - ), - ), - 'assert' => array( - 1 => array( - 'name' => 'description', - '5.4.7' => false, - '5.4.8' => true - ), - ), - 'base64_decode' => array( - 1 => array( - 'name' => 'strict', - '5.1' => false, - '5.2' => true - ), - ), - 'class_implements' => array( - 1 => array( - 'name' => 'autoload', - '5.0' => false, - '5.1' => true - ), - ), - 'class_parents' => array( - 1 => array( - 'name' => 'autoload', - '5.0' => false, - '5.1' => true - ), - ), - 'clearstatcache' => array( - 0 => array( - 'name' => 'clear_realpath_cache', - '5.2' => false, - '5.3' => true - ), - 1 => array( - 'name' => 'filename', - '5.2' => false, - '5.3' => true - ), - ), - 'copy' => array( - 2 => array( - 'name' => 'context', - '5.2' => false, - '5.3' => true - ), - ), - 'curl_multi_info_read' => array( - 1 => array( - 'name' => 'msgs_in_queue', - '5.1' => false, - '5.2' => true - ), - ), - 'debug_backtrace' => array( - 0 => array( - 'name' => 'options', - '5.2.4' => false, - '5.2.5' => true - ), - 1 => array( - 'name' => 'limit', - '5.3' => false, - '5.4' => true - ), - ), - 'debug_print_backtrace' => array( - 0 => array( - 'name' => 'options', - '5.3.5' => false, - '5.3.6' => true - ), - 1 => array( - 'name' => 'limit', - '5.3' => false, - '5.4' => true - ), - ), - 'dirname' => array( - 1 => array( - 'name' => 'levels', - '5.6' => false, - '7.0' => true - ), - ), - 'dns_get_record' => array( - 4 => array( - 'name' => 'raw', - '5.3' => false, - '5.4' => true - ), - ), - 'fgetcsv' => array( - 4 => array( - 'name' => 'escape', - '5.2' => false, - '5.3' => true - ), - ), - 'fputcsv' => array( - 4 => array( - 'name' => 'escape_char', - '5.5.3' => false, - '5.5.4' => true - ), - ), - 'file_get_contents' => array( - 3 => array( - 'name' => 'offset', - '5.0' => false, - '5.1' => true - ), - 4 => array( - 'name' => 'maxlen', - '5.0' => false, - '5.1' => true - ), - ), - 'filter_input_array' => array( - 2 => array( - 'name' => 'add_empty', - '5.3' => false, - '5.4' => true - ), - ), - 'filter_var_array' => array( - 2 => array( - 'name' => 'add_empty', - '5.3' => false, - '5.4' => true - ), - ), - 'gettimeofday' => array( - 0 => array( - 'name' => 'return_float', - '5.0' => false, - '5.1' => true - ), - ), - 'get_defined_functions' => array( - 0 => array( - 'name' => 'exclude_disabled', - '7.0.14' => false, - '7.0.15' => true - ), - ), - 'get_html_translation_table' => array( - 2 => array( - 'name' => 'encoding', - '5.3.3' => false, - '5.3.4' => true - ), - ), - 'get_loaded_extensions' => array( - 0 => array( - 'name' => 'zend_extensions', - '5.2.3' => false, - '5.2.4' => true - ), - ), - 'gzcompress' => array( - 2 => array( - 'name' => 'encoding', - '5.3' => false, - '5.4' => true - ), - ), - 'gzdeflate' => array( - 2 => array( - 'name' => 'encoding', - '5.3' => false, - '5.4' => true - ), - ), - 'htmlentities' => array( - 3 => array( - 'name' => 'double_encode', - '5.2.2' => false, - '5.2.3' => true - ), - ), - 'htmlspecialchars' => array( - 3 => array( - 'name' => 'double_encode', - '5.2.2' => false, - '5.2.3' => true - ), - ), - 'http_build_query' => array( - 2 => array( - 'name' => 'arg_separator', - '5.1.1' => false, - '5.1.2' => true - ), - 3 => array( - 'name' => 'enc_type', - '5.3' => false, - '5.4' => true - ), - ), - 'idn_to_ascii' => array( - 2 => array( - 'name' => 'variant', - '5.3' => false, - '5.4' => true - ), - 3 => array( - 'name' => 'idna_info', - '5.3' => false, - '5.4' => true - ), - ), - 'idn_to_utf8' => array( - 2 => array( - 'name' => 'variant', - '5.3' => false, - '5.4' => true - ), - 3 => array( - 'name' => 'idna_info', - '5.3' => false, - '5.4' => true - ), - ), - 'imagecolorset' => array( - 5 => array( - 'name' => 'alpha', - '5.3' => false, - '5.4' => true - ), - ), - 'imagepng' => array( - 2 => array( - 'name' => 'quality', - '5.1.1' => false, - '5.1.2' => true - ), - 3 => array( - 'name' => 'filters', - '5.1.2' => false, - '5.1.3' => true - ), - ), - 'imagerotate' => array( - 3 => array( - 'name' => 'ignore_transparent', - '5.0' => false, - '5.1' => true - ), - ), - 'imap_open' => array( - 4 => array( - 'name' => 'n_retries', - '5.1' => false, - '5.2' => true - ), - 5 => array( - 'name' => 'params', - '5.3.1' => false, - '5.3.2' => true - ), - ), - 'imap_reopen' => array( - 3 => array( - 'name' => 'n_retries', - '5.1' => false, - '5.2' => true - ), - ), - 'ini_get_all' => array( - 1 => array( - 'name' => 'details', - '5.2' => false, - '5.3' => true - ), - ), - 'is_a' => array( - 2 => array( - 'name' => 'allow_string', - '5.3.8' => false, - '5.3.9' => true - ), - ), - 'is_subclass_of' => array( - 2 => array( - 'name' => 'allow_string', - '5.3.8' => false, - '5.3.9' => true - ), - ), - 'iterator_to_array' => array( - 1 => array( - 'name' => 'use_keys', - '5.2.0' => false, - '5.2.1' => true - ), - ), - 'json_decode' => array( - 2 => array( - 'name' => 'depth', - '5.2' => false, - '5.3' => true - ), - 3 => array( - 'name' => 'options', - '5.3' => false, - '5.4' => true - ), - ), - 'json_encode' => array( - 1 => array( - 'name' => 'options', - '5.2' => false, - '5.3' => true - ), - 2 => array( - 'name' => 'depth', - '5.4' => false, - '5.5' => true - ), - ), - 'memory_get_peak_usage' => array( - 0 => array( - 'name' => 'real_usage', - '5.1' => false, - '5.2' => true - ), - ), - 'memory_get_usage' => array( - 0 => array( - 'name' => 'real_usage', - '5.1' => false, - '5.2' => true - ), - ), - 'mb_encode_numericentity' => array( - 3 => array( - 'name' => 'is_hex', - '5.3' => false, - '5.4' => true - ), - ), - 'mb_strrpos' => array( - /* - * Note: the actual position is 2, but the original 3rd - * parameter 'encoding' was moved to the 4th position. - * So the only way to detect if offset is used is when - * both offset and encoding are set. - */ - 3 => array( - 'name' => 'offset', - '5.1' => false, - '5.2' => true - ), - ), - 'mssql_connect' => array( - 3 => array( - 'name' => 'new_link', - '5.0' => false, - '5.1' => true - ), - ), - 'mysqli_commit' => array( - 1 => array( - 'name' => 'flags', - '5.4' => false, - '5.5' => true - ), - 2 => array( - 'name' => 'name', - '5.4' => false, - '5.5' => true - ), - ), - 'mysqli_rollback' => array( - 1 => array( - 'name' => 'flags', - '5.4' => false, - '5.5' => true - ), - 2 => array( - 'name' => 'name', - '5.4' => false, - '5.5' => true - ), - ), - 'nl2br' => array( - 1 => array( - 'name' => 'is_xhtml', - '5.2' => false, - '5.3' => true - ), - ), - 'openssl_decrypt' => array( - 4 => array( - 'name' => 'iv', - '5.3.2' => false, - '5.3.3' => true - ), - 5 => array( - 'name' => 'tag', - '7.0' => false, - '7.1' => true - ), - 6 => array( - 'name' => 'aad', - '7.0' => false, - '7.1' => true - ), - ), - 'openssl_encrypt' => array( - 4 => array( - 'name' => 'iv', - '5.3.2' => false, - '5.3.3' => true - ), - 5 => array( - 'name' => 'tag', - '7.0' => false, - '7.1' => true - ), - 6 => array( - 'name' => 'aad', - '7.0' => false, - '7.1' => true - ), - 7 => array( - 'name' => 'tag_length', - '7.0' => false, - '7.1' => true - ), - ), - 'openssl_pkcs7_verify' => array( - 5 => array( - 'name' => 'content', - '5.0' => false, - '5.1' => true - ), - ), - 'openssl_seal' => array( - 4 => array( - 'name' => 'method', - '5.2' => false, - '5.3' => true - ), - ), - 'openssl_verify' => array( - 3 => array( - 'name' => 'signature_alg', - '5.1' => false, - '5.2' => true - ), - ), - 'parse_ini_file' => array( - 2 => array( - 'name' => 'scanner_mode', - '5.2' => false, - '5.3' => true - ), - ), - 'parse_url' => array( - 1 => array( - 'name' => 'component', - '5.1.1' => false, - '5.1.2' => true - ), - ), - 'pg_lo_create' => array( - 1 => array( - 'name' => 'object_id', - '5.2' => false, - '5.3' => true - ), - ), - 'pg_lo_import' => array( - 2 => array( - 'name' => 'object_id', - '5.2' => false, - '5.3' => true - ), - ), - 'preg_replace' => array( - 4 => array( - 'name' => 'count', - '5.0' => false, - '5.1' => true - ), - ), - 'preg_replace_callback' => array( - 4 => array( - 'name' => 'count', - '5.0' => false, - '5.1' => true - ), - ), - 'round' => array( - 2 => array( - 'name' => 'mode', - '5.2' => false, - '5.3' => true - ), - ), - 'sem_acquire' => array( - 1 => array( - 'name' => 'nowait', - '5.6' => false, - '5.6.1' => true - ), - ), - 'session_regenerate_id' => array( - 0 => array( - 'name' => 'delete_old_session', - '5.0' => false, - '5.1' => true - ), - ), - 'session_set_cookie_params' => array( - 4 => array( - 'name' => 'httponly', - '5.1' => false, - '5.2' => true - ), - ), - 'session_set_save_handler' => array( - 6 => array( - 'name' => 'create_sid', - '5.5.0' => false, - '5.5.1' => true - ), - ), - 'session_start' => array( - 0 => array( - 'name' => 'options', - '5.6' => false, - '7.0' => true - ), - ), - 'setcookie' => array( - 6 => array( - 'name' => 'httponly', - '5.1' => false, - '5.2' => true - ), - ), - 'setrawcookie' => array( - 6 => array( - 'name' => 'httponly', - '5.1' => false, - '5.2' => true - ), - ), - 'simplexml_load_file' => array( - 4 => array( - 'name' => 'is_prefix', - '5.1' => false, - '5.2' => true - ), - ), - 'simplexml_load_string' => array( - 4 => array( - 'name' => 'is_prefix', - '5.1' => false, - '5.2' => true - ), - ), - 'spl_autoload_register' => array( - 2 => array( - 'name' => 'prepend', - '5.2' => false, - '5.3' => true - ), - ), - 'stream_context_create' => array( - 1 => array( - 'name' => 'params', - '5.2' => false, - '5.3' => true - ), - ), - 'stream_copy_to_stream' => array( - 3 => array( - 'name' => 'offset', - '5.0' => false, - '5.1' => true - ), - ), - 'stream_get_contents' => array( - 2 => array( - 'name' => 'offset', - '5.0' => false, - '5.1' => true - ), - ), - 'stream_wrapper_register' => array( - 2 => array( - 'name' => 'flags', - '5.2.3' => false, - '5.2.4' => true - ), - ), - 'stristr' => array( - 2 => array( - 'name' => 'before_needle', - '5.2' => false, - '5.3' => true - ), - ), - 'strstr' => array( - 2 => array( - 'name' => 'before_needle', - '5.2' => false, - '5.3' => true - ), - ), - 'str_word_count' => array( - 2 => array( - 'name' => 'charlist', - '5.0' => false, - '5.1' => true - ), - ), - 'substr_count' => array( - 2 => array( - 'name' => 'offset', - '5.0' => false, - '5.1' => true - ), - 3 => array( - 'name' => 'length', - '5.0' => false, - '5.1' => true - ), - ), - 'sybase_connect' => array( - 5 => array( - 'name' => 'new', - '5.2' => false, - '5.3' => true - ), - ), - 'timezone_transitions_get' => array( - 1 => array( - 'name' => 'timestamp_begin', - '5.2' => false, - '5.3' => true - ), - 2 => array( - 'name' => 'timestamp_end', - '5.2' => false, - '5.3' => true - ), - ), - 'timezone_identifiers_list' => array( - 0 => array( - 'name' => 'what', - '5.2' => false, - '5.3' => true - ), - 1 => array( - 'name' => 'country', - '5.2' => false, - '5.3' => true - ), - ), - 'token_get_all' => array( - 1 => array( - 'name' => 'flags', - '5.6' => false, - '7.0' => true - ), - ), - 'ucwords' => array( - 1 => array( - 'name' => 'delimiters', - '5.4.31' => false, - '5.5.15' => false, - '5.4.32' => true, - '5.5.16' => true - ), - ), - 'unserialize' => array( - 1 => array( - 'name' => 'options', - '5.6' => false, - '7.0' => true - ), - ), - ); + 'array_filter' => array( + 2 => array( + 'name' => 'flag', + '5.5' => false, + '5.6' => true, + ), + ), + 'array_slice' => array( + 1 => array( + 'name' => 'preserve_keys', + '5.0.1' => false, + '5.0.2' => true, + ), + ), + 'array_unique' => array( + 1 => array( + 'name' => 'sort_flags', + '5.2.8' => false, + '5.2.9' => true, + ), + ), + 'assert' => array( + 1 => array( + 'name' => 'description', + '5.4.7' => false, + '5.4.8' => true, + ), + ), + 'base64_decode' => array( + 1 => array( + 'name' => 'strict', + '5.1' => false, + '5.2' => true, + ), + ), + 'class_implements' => array( + 1 => array( + 'name' => 'autoload', + '5.0' => false, + '5.1' => true, + ), + ), + 'class_parents' => array( + 1 => array( + 'name' => 'autoload', + '5.0' => false, + '5.1' => true, + ), + ), + 'clearstatcache' => array( + 0 => array( + 'name' => 'clear_realpath_cache', + '5.2' => false, + '5.3' => true, + ), + 1 => array( + 'name' => 'filename', + '5.2' => false, + '5.3' => true, + ), + ), + 'copy' => array( + 2 => array( + 'name' => 'context', + '5.2' => false, + '5.3' => true, + ), + ), + 'curl_multi_info_read' => array( + 1 => array( + 'name' => 'msgs_in_queue', + '5.1' => false, + '5.2' => true, + ), + ), + 'debug_backtrace' => array( + 0 => array( + 'name' => 'options', + '5.2.4' => false, + '5.2.5' => true, + ), + 1 => array( + 'name' => 'limit', + '5.3' => false, + '5.4' => true, + ), + ), + 'debug_print_backtrace' => array( + 0 => array( + 'name' => 'options', + '5.3.5' => false, + '5.3.6' => true, + ), + 1 => array( + 'name' => 'limit', + '5.3' => false, + '5.4' => true, + ), + ), + 'dirname' => array( + 1 => array( + 'name' => 'levels', + '5.6' => false, + '7.0' => true, + ), + ), + 'dns_get_record' => array( + 4 => array( + 'name' => 'raw', + '5.3' => false, + '5.4' => true, + ), + ), + 'fgetcsv' => array( + 4 => array( + 'name' => 'escape', + '5.2' => false, + '5.3' => true, + ), + ), + 'fputcsv' => array( + 4 => array( + 'name' => 'escape_char', + '5.5.3' => false, + '5.5.4' => true, + ), + ), + 'file_get_contents' => array( + 3 => array( + 'name' => 'offset', + '5.0' => false, + '5.1' => true, + ), + 4 => array( + 'name' => 'maxlen', + '5.0' => false, + '5.1' => true, + ), + ), + 'filter_input_array' => array( + 2 => array( + 'name' => 'add_empty', + '5.3' => false, + '5.4' => true, + ), + ), + 'filter_var_array' => array( + 2 => array( + 'name' => 'add_empty', + '5.3' => false, + '5.4' => true, + ), + ), + 'gettimeofday' => array( + 0 => array( + 'name' => 'return_float', + '5.0' => false, + '5.1' => true, + ), + ), + 'get_defined_functions' => array( + 0 => array( + 'name' => 'exclude_disabled', + '7.0.14' => false, + '7.0.15' => true, + ), + ), + 'get_html_translation_table' => array( + 2 => array( + 'name' => 'encoding', + '5.3.3' => false, + '5.3.4' => true, + ), + ), + 'get_loaded_extensions' => array( + 0 => array( + 'name' => 'zend_extensions', + '5.2.3' => false, + '5.2.4' => true, + ), + ), + 'gzcompress' => array( + 2 => array( + 'name' => 'encoding', + '5.3' => false, + '5.4' => true, + ), + ), + 'gzdeflate' => array( + 2 => array( + 'name' => 'encoding', + '5.3' => false, + '5.4' => true, + ), + ), + 'htmlentities' => array( + 3 => array( + 'name' => 'double_encode', + '5.2.2' => false, + '5.2.3' => true, + ), + ), + 'htmlspecialchars' => array( + 3 => array( + 'name' => 'double_encode', + '5.2.2' => false, + '5.2.3' => true, + ), + ), + 'http_build_query' => array( + 2 => array( + 'name' => 'arg_separator', + '5.1.1' => false, + '5.1.2' => true, + ), + 3 => array( + 'name' => 'enc_type', + '5.3' => false, + '5.4' => true, + ), + ), + 'idn_to_ascii' => array( + 2 => array( + 'name' => 'variant', + '5.3' => false, + '5.4' => true, + ), + 3 => array( + 'name' => 'idna_info', + '5.3' => false, + '5.4' => true, + ), + ), + 'idn_to_utf8' => array( + 2 => array( + 'name' => 'variant', + '5.3' => false, + '5.4' => true, + ), + 3 => array( + 'name' => 'idna_info', + '5.3' => false, + '5.4' => true, + ), + ), + 'imagecolorset' => array( + 5 => array( + 'name' => 'alpha', + '5.3' => false, + '5.4' => true, + ), + ), + 'imagepng' => array( + 2 => array( + 'name' => 'quality', + '5.1.1' => false, + '5.1.2' => true, + ), + 3 => array( + 'name' => 'filters', + '5.1.2' => false, + '5.1.3' => true, + ), + ), + 'imagerotate' => array( + 3 => array( + 'name' => 'ignore_transparent', + '5.0' => false, + '5.1' => true, + ), + ), + 'imap_open' => array( + 4 => array( + 'name' => 'n_retries', + '5.1' => false, + '5.2' => true, + ), + 5 => array( + 'name' => 'params', + '5.3.1' => false, + '5.3.2' => true, + ), + ), + 'imap_reopen' => array( + 3 => array( + 'name' => 'n_retries', + '5.1' => false, + '5.2' => true, + ), + ), + 'ini_get_all' => array( + 1 => array( + 'name' => 'details', + '5.2' => false, + '5.3' => true, + ), + ), + 'is_a' => array( + 2 => array( + 'name' => 'allow_string', + '5.3.8' => false, + '5.3.9' => true, + ), + ), + 'is_subclass_of' => array( + 2 => array( + 'name' => 'allow_string', + '5.3.8' => false, + '5.3.9' => true, + ), + ), + 'iterator_to_array' => array( + 1 => array( + 'name' => 'use_keys', + '5.2.0' => false, + '5.2.1' => true, + ), + ), + 'json_decode' => array( + 2 => array( + 'name' => 'depth', + '5.2' => false, + '5.3' => true, + ), + 3 => array( + 'name' => 'options', + '5.3' => false, + '5.4' => true, + ), + ), + 'json_encode' => array( + 1 => array( + 'name' => 'options', + '5.2' => false, + '5.3' => true, + ), + 2 => array( + 'name' => 'depth', + '5.4' => false, + '5.5' => true, + ), + ), + 'memory_get_peak_usage' => array( + 0 => array( + 'name' => 'real_usage', + '5.1' => false, + '5.2' => true, + ), + ), + 'memory_get_usage' => array( + 0 => array( + 'name' => 'real_usage', + '5.1' => false, + '5.2' => true, + ), + ), + 'mb_encode_numericentity' => array( + 3 => array( + 'name' => 'is_hex', + '5.3' => false, + '5.4' => true, + ), + ), + 'mb_strrpos' => array( + /* + * Note: the actual position is 2, but the original 3rd + * parameter 'encoding' was moved to the 4th position. + * So the only way to detect if offset is used is when + * both offset and encoding are set. + */ + 3 => array( + 'name' => 'offset', + '5.1' => false, + '5.2' => true, + ), + ), + 'mssql_connect' => array( + 3 => array( + 'name' => 'new_link', + '5.0' => false, + '5.1' => true, + ), + ), + 'mysqli_commit' => array( + 1 => array( + 'name' => 'flags', + '5.4' => false, + '5.5' => true, + ), + 2 => array( + 'name' => 'name', + '5.4' => false, + '5.5' => true, + ), + ), + 'mysqli_rollback' => array( + 1 => array( + 'name' => 'flags', + '5.4' => false, + '5.5' => true, + ), + 2 => array( + 'name' => 'name', + '5.4' => false, + '5.5' => true, + ), + ), + 'nl2br' => array( + 1 => array( + 'name' => 'is_xhtml', + '5.2' => false, + '5.3' => true, + ), + ), + 'openssl_decrypt' => array( + 4 => array( + 'name' => 'iv', + '5.3.2' => false, + '5.3.3' => true, + ), + 5 => array( + 'name' => 'tag', + '7.0' => false, + '7.1' => true, + ), + 6 => array( + 'name' => 'aad', + '7.0' => false, + '7.1' => true, + ), + ), + 'openssl_encrypt' => array( + 4 => array( + 'name' => 'iv', + '5.3.2' => false, + '5.3.3' => true, + ), + 5 => array( + 'name' => 'tag', + '7.0' => false, + '7.1' => true, + ), + 6 => array( + 'name' => 'aad', + '7.0' => false, + '7.1' => true, + ), + 7 => array( + 'name' => 'tag_length', + '7.0' => false, + '7.1' => true, + ), + ), + 'openssl_pkcs7_verify' => array( + 5 => array( + 'name' => 'content', + '5.0' => false, + '5.1' => true, + ), + ), + 'openssl_seal' => array( + 4 => array( + 'name' => 'method', + '5.2' => false, + '5.3' => true, + ), + ), + 'openssl_verify' => array( + 3 => array( + 'name' => 'signature_alg', + '5.1' => false, + '5.2' => true, + ), + ), + 'parse_ini_file' => array( + 2 => array( + 'name' => 'scanner_mode', + '5.2' => false, + '5.3' => true, + ), + ), + 'parse_url' => array( + 1 => array( + 'name' => 'component', + '5.1.1' => false, + '5.1.2' => true, + ), + ), + 'pg_lo_create' => array( + 1 => array( + 'name' => 'object_id', + '5.2' => false, + '5.3' => true, + ), + ), + 'pg_lo_import' => array( + 2 => array( + 'name' => 'object_id', + '5.2' => false, + '5.3' => true, + ), + ), + 'preg_replace' => array( + 4 => array( + 'name' => 'count', + '5.0' => false, + '5.1' => true, + ), + ), + 'preg_replace_callback' => array( + 4 => array( + 'name' => 'count', + '5.0' => false, + '5.1' => true, + ), + ), + 'round' => array( + 2 => array( + 'name' => 'mode', + '5.2' => false, + '5.3' => true, + ), + ), + 'sem_acquire' => array( + 1 => array( + 'name' => 'nowait', + '5.6' => false, + '5.6.1' => true, + ), + ), + 'session_regenerate_id' => array( + 0 => array( + 'name' => 'delete_old_session', + '5.0' => false, + '5.1' => true, + ), + ), + 'session_set_cookie_params' => array( + 4 => array( + 'name' => 'httponly', + '5.1' => false, + '5.2' => true, + ), + ), + 'session_set_save_handler' => array( + 6 => array( + 'name' => 'create_sid', + '5.5.0' => false, + '5.5.1' => true, + ), + ), + 'session_start' => array( + 0 => array( + 'name' => 'options', + '5.6' => false, + '7.0' => true, + ), + ), + 'setcookie' => array( + 6 => array( + 'name' => 'httponly', + '5.1' => false, + '5.2' => true, + ), + ), + 'setrawcookie' => array( + 6 => array( + 'name' => 'httponly', + '5.1' => false, + '5.2' => true, + ), + ), + 'simplexml_load_file' => array( + 4 => array( + 'name' => 'is_prefix', + '5.1' => false, + '5.2' => true, + ), + ), + 'simplexml_load_string' => array( + 4 => array( + 'name' => 'is_prefix', + '5.1' => false, + '5.2' => true, + ), + ), + 'spl_autoload_register' => array( + 2 => array( + 'name' => 'prepend', + '5.2' => false, + '5.3' => true, + ), + ), + 'stream_context_create' => array( + 1 => array( + 'name' => 'params', + '5.2' => false, + '5.3' => true, + ), + ), + 'stream_copy_to_stream' => array( + 3 => array( + 'name' => 'offset', + '5.0' => false, + '5.1' => true, + ), + ), + 'stream_get_contents' => array( + 2 => array( + 'name' => 'offset', + '5.0' => false, + '5.1' => true, + ), + ), + 'stream_wrapper_register' => array( + 2 => array( + 'name' => 'flags', + '5.2.3' => false, + '5.2.4' => true, + ), + ), + 'stristr' => array( + 2 => array( + 'name' => 'before_needle', + '5.2' => false, + '5.3' => true, + ), + ), + 'strstr' => array( + 2 => array( + 'name' => 'before_needle', + '5.2' => false, + '5.3' => true, + ), + ), + 'str_word_count' => array( + 2 => array( + 'name' => 'charlist', + '5.0' => false, + '5.1' => true, + ), + ), + 'substr_count' => array( + 2 => array( + 'name' => 'offset', + '5.0' => false, + '5.1' => true, + ), + 3 => array( + 'name' => 'length', + '5.0' => false, + '5.1' => true, + ), + ), + 'sybase_connect' => array( + 5 => array( + 'name' => 'new', + '5.2' => false, + '5.3' => true, + ), + ), + 'timezone_transitions_get' => array( + 1 => array( + 'name' => 'timestamp_begin', + '5.2' => false, + '5.3' => true, + ), + 2 => array( + 'name' => 'timestamp_end', + '5.2' => false, + '5.3' => true, + ), + ), + 'timezone_identifiers_list' => array( + 0 => array( + 'name' => 'what', + '5.2' => false, + '5.3' => true, + ), + 1 => array( + 'name' => 'country', + '5.2' => false, + '5.3' => true, + ), + ), + 'token_get_all' => array( + 1 => array( + 'name' => 'flags', + '5.6' => false, + '7.0' => true, + ), + ), + 'ucwords' => array( + 1 => array( + 'name' => 'delimiters', + '5.4.31' => false, + '5.5.15' => false, + '5.4.32' => true, + '5.5.16' => true, + ), + ), + 'unserialize' => array( + 1 => array( + 'name' => 'options', + '5.6' => false, + '7.0' => true, + ), + ), + ); /** @@ -764,10 +764,10 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) $tokens = $phpcsFile->getTokens(); $ignore = array( - T_DOUBLE_COLON, - T_OBJECT_OPERATOR, - T_FUNCTION, - T_CONST, + T_DOUBLE_COLON, + T_OBJECT_OPERATOR, + T_FUNCTION, + T_CONST, ); $prevToken = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true); @@ -792,7 +792,7 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) $openParenthesis = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, $stackPtr + 1, null, true, null, true); $parameterOffsetFound = $parameterCount - 1; - foreach($this->newFunctionParameters[$functionLc] as $offset => $parameterDetails) { + foreach ($this->newFunctionParameters[$functionLc] as $offset => $parameterDetails) { if ($offset <= $parameterOffsetFound) { $itemInfo = array( 'name' => $function, diff --git a/PHPCompatibility/Sniffs/PHP/NewFunctionsSniff.php b/PHPCompatibility/Sniffs/PHP/NewFunctionsSniff.php index c8acd1d4..849c1031 100644 --- a/PHPCompatibility/Sniffs/PHP/NewFunctionsSniff.php +++ b/PHPCompatibility/Sniffs/PHP/NewFunctionsSniff.php @@ -2,17 +2,17 @@ /** * PHPCompatibility_Sniffs_PHP_NewFunctionsSniff. * - * @category PHP - * @package PHPCompatibility - * @author Wim Godden + * @category PHP + * @package PHPCompatibility + * @author Wim Godden */ /** * PHPCompatibility_Sniffs_PHP_newFunctionsSniff. * - * @category PHP - * @package PHPCompatibility - * @author Wim Godden + * @category PHP + * @package PHPCompatibility + * @author Wim Godden */ class PHPCompatibility_Sniffs_PHP_NewFunctionsSniff extends PHPCompatibility_AbstractNewFeatureSniff { @@ -25,1238 +25,1238 @@ class PHPCompatibility_Sniffs_PHP_NewFunctionsSniff extends PHPCompatibility_Abs * @var array(string => array(string => int|string|null)) */ protected $newFunctions = array( - 'array_fill_keys' => array( - '5.1' => false, - '5.2' => true - ), - 'error_get_last' => array( - '5.1' => false, - '5.2' => true - ), - 'image_type_to_extension' => array( - '5.1' => false, - '5.2' => true - ), - 'memory_get_peak_usage' => array( - '5.1' => false, - '5.2' => true - ), - 'sys_get_temp_dir' => array( - '5.1' => false, - '5.2' => true - ), - 'timezone_abbreviations_list' => array( - '5.1' => false, - '5.2' => true - ), - 'timezone_identifiers_list' => array( - '5.1' => false, - '5.2' => true - ), - 'timezone_name_from_abbr' => array( - '5.1' => false, - '5.2' => true - ), - 'stream_socket_shutdown' => array( - '5.1' => false, - '5.2' => true - ), - 'imagegrabscreen' => array( - '5.1' => false, - '5.2' => true - ), - 'imagegrabwindow' => array( - '5.1' => false, - '5.2' => true - ), - 'libxml_disable_entity_loader' => array( - '5.1' => false, - '5.2' => true - ), - 'mb_stripos' => array( - '5.1' => false, - '5.2' => true - ), - 'mb_stristr' => array( - '5.1' => false, - '5.2' => true - ), - 'mb_strrchr' => array( - '5.1' => false, - '5.2' => true - ), - 'mb_strrichr' => array( - '5.1' => false, - '5.2' => true - ), - 'mb_strripos' => array( - '5.1' => false, - '5.2' => true - ), - 'ming_setSWFCompression' => array( - '5.1' => false, - '5.2' => true - ), - 'openssl_csr_get_public_key' => array( - '5.1' => false, - '5.2' => true - ), - 'openssl_csr_get_subject' => array( - '5.1' => false, - '5.2' => true - ), - 'openssl_pkey_get_details' => array( - '5.1' => false, - '5.2' => true - ), - 'spl_object_hash' => array( - '5.1' => false, - '5.2' => true - ), - 'iterator_apply' => array( - '5.1' => false, - '5.2' => true - ), - 'preg_last_error' => array( - '5.1' => false, - '5.2' => true - ), - 'pg_field_table' => array( - '5.1' => false, - '5.2' => true - ), - 'posix_initgroups' => array( - '5.1' => false, - '5.2' => true - ), - 'gmp_nextprime' => array( - '5.1' => false, - '5.2' => true - ), - 'xmlwriter_full_end_element' => array( - '5.1' => false, - '5.2' => true - ), - 'xmlwriter_write_raw' => array( - '5.1' => false, - '5.2' => true - ), - 'xmlwriter_start_dtd_entity' => array( - '5.1' => false, - '5.2' => true - ), - 'xmlwriter_end_dtd_entity' => array( - '5.1' => false, - '5.2' => true - ), - 'xmlwriter_write_dtd_entity' => array( - '5.1' => false, - '5.2' => true - ), - 'filter_has_var' => array( - '5.1' => false, - '5.2' => true - ), - 'filter_id' => array( - '5.1' => false, - '5.2' => true - ), - 'filter_input_array' => array( - '5.1' => false, - '5.2' => true - ), - 'filter_input' => array( - '5.1' => false, - '5.2' => true - ), - 'filter_list' => array( - '5.1' => false, - '5.2' => true - ), - 'filter_var_array' => array( - '5.1' => false, - '5.2' => true - ), - 'filter_var' => array( - '5.1' => false, - '5.2' => true - ), - 'json_decode' => array( - '5.1' => false, - '5.2' => true - ), - 'json_encode' => array( - '5.1' => false, - '5.2' => true - ), - 'zip_close' => array( - '5.1' => false, - '5.2' => true - ), - 'zip_entry_close' => array( - '5.1' => false, - '5.2' => true - ), - 'zip_entry_compressedsize' => array( - '5.1' => false, - '5.2' => true - ), - 'zip_entry_compressionmethod' => array( - '5.1' => false, - '5.2' => true - ), - 'zip_entry_filesize' => array( - '5.1' => false, - '5.2' => true - ), - 'zip_entry_name' => array( - '5.1' => false, - '5.2' => true - ), - 'zip_entry_open' => array( - '5.1' => false, - '5.2' => true - ), - 'zip_entry_read' => array( - '5.1' => false, - '5.2' => true - ), - 'zip_open' => array( - '5.1' => false, - '5.2' => true - ), - 'zip_read' => array( - '5.1' => false, - '5.2' => true - ), + 'array_fill_keys' => array( + '5.1' => false, + '5.2' => true, + ), + 'error_get_last' => array( + '5.1' => false, + '5.2' => true, + ), + 'image_type_to_extension' => array( + '5.1' => false, + '5.2' => true, + ), + 'memory_get_peak_usage' => array( + '5.1' => false, + '5.2' => true, + ), + 'sys_get_temp_dir' => array( + '5.1' => false, + '5.2' => true, + ), + 'timezone_abbreviations_list' => array( + '5.1' => false, + '5.2' => true, + ), + 'timezone_identifiers_list' => array( + '5.1' => false, + '5.2' => true, + ), + 'timezone_name_from_abbr' => array( + '5.1' => false, + '5.2' => true, + ), + 'stream_socket_shutdown' => array( + '5.1' => false, + '5.2' => true, + ), + 'imagegrabscreen' => array( + '5.1' => false, + '5.2' => true, + ), + 'imagegrabwindow' => array( + '5.1' => false, + '5.2' => true, + ), + 'libxml_disable_entity_loader' => array( + '5.1' => false, + '5.2' => true, + ), + 'mb_stripos' => array( + '5.1' => false, + '5.2' => true, + ), + 'mb_stristr' => array( + '5.1' => false, + '5.2' => true, + ), + 'mb_strrchr' => array( + '5.1' => false, + '5.2' => true, + ), + 'mb_strrichr' => array( + '5.1' => false, + '5.2' => true, + ), + 'mb_strripos' => array( + '5.1' => false, + '5.2' => true, + ), + 'ming_setSWFCompression' => array( + '5.1' => false, + '5.2' => true, + ), + 'openssl_csr_get_public_key' => array( + '5.1' => false, + '5.2' => true, + ), + 'openssl_csr_get_subject' => array( + '5.1' => false, + '5.2' => true, + ), + 'openssl_pkey_get_details' => array( + '5.1' => false, + '5.2' => true, + ), + 'spl_object_hash' => array( + '5.1' => false, + '5.2' => true, + ), + 'iterator_apply' => array( + '5.1' => false, + '5.2' => true, + ), + 'preg_last_error' => array( + '5.1' => false, + '5.2' => true, + ), + 'pg_field_table' => array( + '5.1' => false, + '5.2' => true, + ), + 'posix_initgroups' => array( + '5.1' => false, + '5.2' => true, + ), + 'gmp_nextprime' => array( + '5.1' => false, + '5.2' => true, + ), + 'xmlwriter_full_end_element' => array( + '5.1' => false, + '5.2' => true, + ), + 'xmlwriter_write_raw' => array( + '5.1' => false, + '5.2' => true, + ), + 'xmlwriter_start_dtd_entity' => array( + '5.1' => false, + '5.2' => true, + ), + 'xmlwriter_end_dtd_entity' => array( + '5.1' => false, + '5.2' => true, + ), + 'xmlwriter_write_dtd_entity' => array( + '5.1' => false, + '5.2' => true, + ), + 'filter_has_var' => array( + '5.1' => false, + '5.2' => true, + ), + 'filter_id' => array( + '5.1' => false, + '5.2' => true, + ), + 'filter_input_array' => array( + '5.1' => false, + '5.2' => true, + ), + 'filter_input' => array( + '5.1' => false, + '5.2' => true, + ), + 'filter_list' => array( + '5.1' => false, + '5.2' => true, + ), + 'filter_var_array' => array( + '5.1' => false, + '5.2' => true, + ), + 'filter_var' => array( + '5.1' => false, + '5.2' => true, + ), + 'json_decode' => array( + '5.1' => false, + '5.2' => true, + ), + 'json_encode' => array( + '5.1' => false, + '5.2' => true, + ), + 'zip_close' => array( + '5.1' => false, + '5.2' => true, + ), + 'zip_entry_close' => array( + '5.1' => false, + '5.2' => true, + ), + 'zip_entry_compressedsize' => array( + '5.1' => false, + '5.2' => true, + ), + 'zip_entry_compressionmethod' => array( + '5.1' => false, + '5.2' => true, + ), + 'zip_entry_filesize' => array( + '5.1' => false, + '5.2' => true, + ), + 'zip_entry_name' => array( + '5.1' => false, + '5.2' => true, + ), + 'zip_entry_open' => array( + '5.1' => false, + '5.2' => true, + ), + 'zip_entry_read' => array( + '5.1' => false, + '5.2' => true, + ), + 'zip_open' => array( + '5.1' => false, + '5.2' => true, + ), + 'zip_read' => array( + '5.1' => false, + '5.2' => true, + ), - 'array_replace' => array( - '5.2' => false, - '5.3' => true - ), - 'array_replace_recursive' => array( - '5.2' => false, - '5.3' => true - ), - 'class_alias' => array( - '5.2' => false, - '5.3' => true - ), - 'forward_static_call' => array( - '5.2' => false, - '5.3' => true - ), - 'forward_static_call_array' => array( - '5.2' => false, - '5.3' => true - ), - 'gc_collect_cycles' => array( - '5.2' => false, - '5.3' => true - ), - 'gc_disable' => array( - '5.2' => false, - '5.3' => true - ), - 'gc_enable' => array( - '5.2' => false, - '5.3' => true - ), - 'gc_enabled' => array( - '5.2' => false, - '5.3' => true - ), - 'get_called_class' => array( - '5.2' => false, - '5.3' => true - ), - 'gethostname' => array( - '5.2' => false, - '5.3' => true - ), - 'header_remove' => array( - '5.2' => false, - '5.3' => true - ), - 'lcfirst' => array( - '5.2' => false, - '5.3' => true - ), - 'parse_ini_string' => array( - '5.2' => false, - '5.3' => true - ), - 'quoted_printable_encode' => array( - '5.2' => false, - '5.3' => true - ), - 'str_getcsv' => array( - '5.2' => false, - '5.3' => true - ), - 'stream_context_set_default' => array( - '5.2' => false, - '5.3' => true - ), - 'stream_supports_lock' => array( - '5.2' => false, - '5.3' => true - ), - 'stream_context_get_params' => array( - '5.2' => false, - '5.3' => true - ), - 'date_add' => array( - '5.2' => false, - '5.3' => true - ), - 'date_create_from_format' => array( - '5.2' => false, - '5.3' => true - ), - 'date_diff' => array( - '5.2' => false, - '5.3' => true - ), - 'date_get_last_errors' => array( - '5.2' => false, - '5.3' => true - ), - 'date_parse_from_format' => array( - '5.2' => false, - '5.3' => true - ), - 'date_sub' => array( - '5.2' => false, - '5.3' => true - ), - 'timezone_version_get' => array( - '5.2' => false, - '5.3' => true - ), - 'gmp_testbit' => array( - '5.2' => false, - '5.3' => true - ), - 'hash_copy' => array( - '5.2' => false, - '5.3' => true - ), - 'imap_gc' => array( - '5.2' => false, - '5.3' => true - ), - 'imap_utf8_to_mutf7' => array( - '5.2' => false, - '5.3' => true - ), - 'imap_mutf7_to_utf8' => array( - '5.2' => false, - '5.3' => true - ), - 'json_last_error' => array( - '5.2' => false, - '5.3' => true - ), - 'mysqli_get_cache_stats' => array( - '5.2' => false, - '5.3' => true - ), - 'mysqli_fetch_all' => array( - '5.2' => false, - '5.3' => true - ), - 'mysqli_get_connection_status' => array( - '5.2' => false, - '5.3' => true - ), - 'mysqli_poll' => array( - '5.2' => false, - '5.3' => true - ), - 'mysqli_read_async_query' => array( - '5.2' => false, - '5.3' => true - ), - 'openssl_random_pseudo_bytes' => array( - '5.2' => false, - '5.3' => true - ), - 'pcntl_signal_dispatch' => array( - '5.2' => false, - '5.3' => true - ), - 'pcntl_sigprocmask' => array( - '5.2' => false, - '5.3' => true - ), - 'pcntl_sigtimedwait' => array( - '5.2' => false, - '5.3' => true - ), - 'pcntl_sigwaitinfo' => array( - '5.2' => false, - '5.3' => true - ), - 'preg_filter' => array( - '5.2' => false, - '5.3' => true - ), - 'msg_queue_exists' => array( - '5.2' => false, - '5.3' => true - ), - 'shm_has_vars' => array( - '5.2' => false, - '5.3' => true - ), - 'acosh' => array( - '5.2' => false, - '5.3' => true - ), - 'asinh' => array( - '5.2' => false, - '5.3' => true - ), - 'atanh' => array( - '5.2' => false, - '5.3' => true - ), - 'expm1' => array( - '5.2' => false, - '5.3' => true - ), - 'log1p' => array( - '5.2' => false, - '5.3' => true - ), - 'enchant_broker_describe' => array( - '5.2' => false, - '5.3' => true - ), - 'enchant_broker_dict_exists' => array( - '5.2' => false, - '5.3' => true - ), - 'enchant_broker_free_dict' => array( - '5.2' => false, - '5.3' => true - ), - 'enchant_broker_free' => array( - '5.2' => false, - '5.3' => true - ), - 'enchant_broker_get_error' => array( - '5.2' => false, - '5.3' => true - ), - 'enchant_broker_init' => array( - '5.2' => false, - '5.3' => true - ), - 'enchant_broker_list_dicts' => array( - '5.2' => false, - '5.3' => true - ), - 'enchant_broker_request_dict' => array( - '5.2' => false, - '5.3' => true - ), - 'enchant_broker_request_pwl_dict' => array( - '5.2' => false, - '5.3' => true - ), - 'enchant_broker_set_ordering' => array( - '5.2' => false, - '5.3' => true - ), - 'enchant_dict_add_to_personal' => array( - '5.2' => false, - '5.3' => true - ), - 'enchant_dict_add_to_session' => array( - '5.2' => false, - '5.3' => true - ), - 'enchant_dict_check' => array( - '5.2' => false, - '5.3' => true - ), - 'enchant_dict_describe' => array( - '5.2' => false, - '5.3' => true - ), - 'enchant_dict_get_error' => array( - '5.2' => false, - '5.3' => true - ), - 'enchant_dict_is_in_session' => array( - '5.2' => false, - '5.3' => true - ), - 'enchant_dict_quick_check' => array( - '5.2' => false, - '5.3' => true - ), - 'enchant_dict_store_replacement' => array( - '5.2' => false, - '5.3' => true - ), - 'enchant_dict_suggest' => array( - '5.2' => false, - '5.3' => true - ), - 'finfo_buffer' => array( - '5.2' => false, - '5.3' => true - ), - 'finfo_close' => array( - '5.2' => false, - '5.3' => true - ), - 'finfo_file' => array( - '5.2' => false, - '5.3' => true - ), - 'finfo_open' => array( - '5.2' => false, - '5.3' => true - ), - 'finfo_set_flags' => array( - '5.2' => false, - '5.3' => true - ), - 'intl_error_name' => array( - '5.2' => false, - '5.3' => true - ), - 'intl_get_error_code' => array( - '5.2' => false, - '5.3' => true - ), - 'intl_get_error_message' => array( - '5.2' => false, - '5.3' => true - ), - 'intl_is_failure' => array( - '5.2' => false, - '5.3' => true - ), + 'array_replace' => array( + '5.2' => false, + '5.3' => true, + ), + 'array_replace_recursive' => array( + '5.2' => false, + '5.3' => true, + ), + 'class_alias' => array( + '5.2' => false, + '5.3' => true, + ), + 'forward_static_call' => array( + '5.2' => false, + '5.3' => true, + ), + 'forward_static_call_array' => array( + '5.2' => false, + '5.3' => true, + ), + 'gc_collect_cycles' => array( + '5.2' => false, + '5.3' => true, + ), + 'gc_disable' => array( + '5.2' => false, + '5.3' => true, + ), + 'gc_enable' => array( + '5.2' => false, + '5.3' => true, + ), + 'gc_enabled' => array( + '5.2' => false, + '5.3' => true, + ), + 'get_called_class' => array( + '5.2' => false, + '5.3' => true, + ), + 'gethostname' => array( + '5.2' => false, + '5.3' => true, + ), + 'header_remove' => array( + '5.2' => false, + '5.3' => true, + ), + 'lcfirst' => array( + '5.2' => false, + '5.3' => true, + ), + 'parse_ini_string' => array( + '5.2' => false, + '5.3' => true, + ), + 'quoted_printable_encode' => array( + '5.2' => false, + '5.3' => true, + ), + 'str_getcsv' => array( + '5.2' => false, + '5.3' => true, + ), + 'stream_context_set_default' => array( + '5.2' => false, + '5.3' => true, + ), + 'stream_supports_lock' => array( + '5.2' => false, + '5.3' => true, + ), + 'stream_context_get_params' => array( + '5.2' => false, + '5.3' => true, + ), + 'date_add' => array( + '5.2' => false, + '5.3' => true, + ), + 'date_create_from_format' => array( + '5.2' => false, + '5.3' => true, + ), + 'date_diff' => array( + '5.2' => false, + '5.3' => true, + ), + 'date_get_last_errors' => array( + '5.2' => false, + '5.3' => true, + ), + 'date_parse_from_format' => array( + '5.2' => false, + '5.3' => true, + ), + 'date_sub' => array( + '5.2' => false, + '5.3' => true, + ), + 'timezone_version_get' => array( + '5.2' => false, + '5.3' => true, + ), + 'gmp_testbit' => array( + '5.2' => false, + '5.3' => true, + ), + 'hash_copy' => array( + '5.2' => false, + '5.3' => true, + ), + 'imap_gc' => array( + '5.2' => false, + '5.3' => true, + ), + 'imap_utf8_to_mutf7' => array( + '5.2' => false, + '5.3' => true, + ), + 'imap_mutf7_to_utf8' => array( + '5.2' => false, + '5.3' => true, + ), + 'json_last_error' => array( + '5.2' => false, + '5.3' => true, + ), + 'mysqli_get_cache_stats' => array( + '5.2' => false, + '5.3' => true, + ), + 'mysqli_fetch_all' => array( + '5.2' => false, + '5.3' => true, + ), + 'mysqli_get_connection_status' => array( + '5.2' => false, + '5.3' => true, + ), + 'mysqli_poll' => array( + '5.2' => false, + '5.3' => true, + ), + 'mysqli_read_async_query' => array( + '5.2' => false, + '5.3' => true, + ), + 'openssl_random_pseudo_bytes' => array( + '5.2' => false, + '5.3' => true, + ), + 'pcntl_signal_dispatch' => array( + '5.2' => false, + '5.3' => true, + ), + 'pcntl_sigprocmask' => array( + '5.2' => false, + '5.3' => true, + ), + 'pcntl_sigtimedwait' => array( + '5.2' => false, + '5.3' => true, + ), + 'pcntl_sigwaitinfo' => array( + '5.2' => false, + '5.3' => true, + ), + 'preg_filter' => array( + '5.2' => false, + '5.3' => true, + ), + 'msg_queue_exists' => array( + '5.2' => false, + '5.3' => true, + ), + 'shm_has_vars' => array( + '5.2' => false, + '5.3' => true, + ), + 'acosh' => array( + '5.2' => false, + '5.3' => true, + ), + 'asinh' => array( + '5.2' => false, + '5.3' => true, + ), + 'atanh' => array( + '5.2' => false, + '5.3' => true, + ), + 'expm1' => array( + '5.2' => false, + '5.3' => true, + ), + 'log1p' => array( + '5.2' => false, + '5.3' => true, + ), + 'enchant_broker_describe' => array( + '5.2' => false, + '5.3' => true, + ), + 'enchant_broker_dict_exists' => array( + '5.2' => false, + '5.3' => true, + ), + 'enchant_broker_free_dict' => array( + '5.2' => false, + '5.3' => true, + ), + 'enchant_broker_free' => array( + '5.2' => false, + '5.3' => true, + ), + 'enchant_broker_get_error' => array( + '5.2' => false, + '5.3' => true, + ), + 'enchant_broker_init' => array( + '5.2' => false, + '5.3' => true, + ), + 'enchant_broker_list_dicts' => array( + '5.2' => false, + '5.3' => true, + ), + 'enchant_broker_request_dict' => array( + '5.2' => false, + '5.3' => true, + ), + 'enchant_broker_request_pwl_dict' => array( + '5.2' => false, + '5.3' => true, + ), + 'enchant_broker_set_ordering' => array( + '5.2' => false, + '5.3' => true, + ), + 'enchant_dict_add_to_personal' => array( + '5.2' => false, + '5.3' => true, + ), + 'enchant_dict_add_to_session' => array( + '5.2' => false, + '5.3' => true, + ), + 'enchant_dict_check' => array( + '5.2' => false, + '5.3' => true, + ), + 'enchant_dict_describe' => array( + '5.2' => false, + '5.3' => true, + ), + 'enchant_dict_get_error' => array( + '5.2' => false, + '5.3' => true, + ), + 'enchant_dict_is_in_session' => array( + '5.2' => false, + '5.3' => true, + ), + 'enchant_dict_quick_check' => array( + '5.2' => false, + '5.3' => true, + ), + 'enchant_dict_store_replacement' => array( + '5.2' => false, + '5.3' => true, + ), + 'enchant_dict_suggest' => array( + '5.2' => false, + '5.3' => true, + ), + 'finfo_buffer' => array( + '5.2' => false, + '5.3' => true, + ), + 'finfo_close' => array( + '5.2' => false, + '5.3' => true, + ), + 'finfo_file' => array( + '5.2' => false, + '5.3' => true, + ), + 'finfo_open' => array( + '5.2' => false, + '5.3' => true, + ), + 'finfo_set_flags' => array( + '5.2' => false, + '5.3' => true, + ), + 'intl_error_name' => array( + '5.2' => false, + '5.3' => true, + ), + 'intl_get_error_code' => array( + '5.2' => false, + '5.3' => true, + ), + 'intl_get_error_message' => array( + '5.2' => false, + '5.3' => true, + ), + 'intl_is_failure' => array( + '5.2' => false, + '5.3' => true, + ), - 'hex2bin' => array( - '5.3' => false, - '5.4' => true - ), - 'http_response_code' => array( - '5.3' => false, - '5.4' => true - ), - 'get_declared_traits' => array( - '5.3' => false, - '5.4' => true - ), - 'getimagesizefromstring' => array( - '5.3' => false, - '5.4' => true - ), - 'stream_set_chunk_size' => array( - '5.3' => false, - '5.4' => true - ), - 'socket_import_stream' => array( - '5.3' => false, - '5.4' => true - ), - 'trait_exists' => array( - '5.3' => false, - '5.4' => true - ), - 'header_register_callback' => array( - '5.3' => false, - '5.4' => true - ), - 'class_uses' => array( - '5.3' => false, - '5.4' => true - ), - 'session_status' => array( - '5.3' => false, - '5.4' => true - ), - 'session_register_shutdown' => array( - '5.3' => false, - '5.4' => true - ), - 'mysqli_error_list' => array( - '5.3' => false, - '5.4' => true - ), - 'mysqli_stmt_error_list' => array( - '5.3' => false, - '5.4' => true - ), - 'libxml_set_external_entity_loader' => array( - '5.3' => false, - '5.4' => true - ), - 'ldap_control_paged_result' => array( - '5.3' => false, - '5.4' => true - ), - 'ldap_control_paged_result_response' => array( - '5.3' => false, - '5.4' => true - ), - 'transliteral_create' => array( - '5.3' => false, - '5.4' => true - ), - 'transliteral_create_from_rules' => array( - '5.3' => false, - '5.4' => true - ), - 'transliteral_create_inverse' => array( - '5.3' => false, - '5.4' => true - ), - 'transliteral_get_error_code' => array( - '5.3' => false, - '5.4' => true - ), - 'transliteral_get_error_message' => array( - '5.3' => false, - '5.4' => true - ), - 'transliteral_list_ids' => array( - '5.3' => false, - '5.4' => true - ), - 'transliteral_transliterate' => array( - '5.3' => false, - '5.4' => true - ), - 'zlib_decode' => array( - '5.3' => false, - '5.4' => true - ), - 'zlib_encode' => array( - '5.3' => false, - '5.4' => true - ), + 'hex2bin' => array( + '5.3' => false, + '5.4' => true, + ), + 'http_response_code' => array( + '5.3' => false, + '5.4' => true, + ), + 'get_declared_traits' => array( + '5.3' => false, + '5.4' => true, + ), + 'getimagesizefromstring' => array( + '5.3' => false, + '5.4' => true, + ), + 'stream_set_chunk_size' => array( + '5.3' => false, + '5.4' => true, + ), + 'socket_import_stream' => array( + '5.3' => false, + '5.4' => true, + ), + 'trait_exists' => array( + '5.3' => false, + '5.4' => true, + ), + 'header_register_callback' => array( + '5.3' => false, + '5.4' => true, + ), + 'class_uses' => array( + '5.3' => false, + '5.4' => true, + ), + 'session_status' => array( + '5.3' => false, + '5.4' => true, + ), + 'session_register_shutdown' => array( + '5.3' => false, + '5.4' => true, + ), + 'mysqli_error_list' => array( + '5.3' => false, + '5.4' => true, + ), + 'mysqli_stmt_error_list' => array( + '5.3' => false, + '5.4' => true, + ), + 'libxml_set_external_entity_loader' => array( + '5.3' => false, + '5.4' => true, + ), + 'ldap_control_paged_result' => array( + '5.3' => false, + '5.4' => true, + ), + 'ldap_control_paged_result_response' => array( + '5.3' => false, + '5.4' => true, + ), + 'transliteral_create' => array( + '5.3' => false, + '5.4' => true, + ), + 'transliteral_create_from_rules' => array( + '5.3' => false, + '5.4' => true, + ), + 'transliteral_create_inverse' => array( + '5.3' => false, + '5.4' => true, + ), + 'transliteral_get_error_code' => array( + '5.3' => false, + '5.4' => true, + ), + 'transliteral_get_error_message' => array( + '5.3' => false, + '5.4' => true, + ), + 'transliteral_list_ids' => array( + '5.3' => false, + '5.4' => true, + ), + 'transliteral_transliterate' => array( + '5.3' => false, + '5.4' => true, + ), + 'zlib_decode' => array( + '5.3' => false, + '5.4' => true, + ), + 'zlib_encode' => array( + '5.3' => false, + '5.4' => true, + ), - 'array_column' => array( - '5.4' => false, - '5.5' => true - ), - 'boolval' => array( - '5.4' => false, - '5.5' => true - ), - 'json_last_error_msg' => array( - '5.4' => false, - '5.5' => true - ), - 'password_get_info' => array( - '5.4' => false, - '5.5' => true - ), - 'password_hash' => array( - '5.4' => false, - '5.5' => true - ), - 'password_needs_rehash' => array( - '5.4' => false, - '5.5' => true - ), - 'password_verify' => array( - '5.4' => false, - '5.5' => true - ), - 'hash_pbkdf2' => array( - '5.4' => false, - '5.5' => true - ), - 'openssl_pbkdf2' => array( - '5.4' => false, - '5.5' => true - ), - 'curl_escape' => array( - '5.4' => false, - '5.5' => true - ), - 'curl_file_create' => array( - '5.4' => false, - '5.5' => true - ), - 'curl_multi_setopt' => array( - '5.4' => false, - '5.5' => true - ), - 'curl_multi_strerror' => array( - '5.4' => false, - '5.5' => true - ), - 'curl_pause' => array( - '5.4' => false, - '5.5' => true - ), - 'curl_reset' => array( - '5.4' => false, - '5.5' => true - ), - 'curl_share_close' => array( - '5.4' => false, - '5.5' => true - ), - 'curl_share_init' => array( - '5.4' => false, - '5.5' => true - ), - 'curl_share_setopt' => array( - '5.4' => false, - '5.5' => true - ), - 'curl_strerror' => array( - '5.4' => false, - '5.5' => true - ), - 'curl_unescape' => array( - '5.4' => false, - '5.5' => true - ), - 'imageaffinematrixconcat' => array( - '5.4' => false, - '5.5' => true - ), - 'imageaffinematrixget' => array( - '5.4' => false, - '5.5' => true - ), - 'imagecrop' => array( - '5.4' => false, - '5.5' => true - ), - 'imagecropauto' => array( - '5.4' => false, - '5.5' => true - ), - 'imageflip' => array( - '5.4' => false, - '5.5' => true - ), - 'imagepalettetotruecolor' => array( - '5.4' => false, - '5.5' => true - ), - 'imagescale' => array( - '5.4' => false, - '5.5' => true - ), - 'mysqli_begin_transaction' => array( - '5.4' => false, - '5.5' => true - ), - 'mysqli_release_savepoint' => array( - '5.4' => false, - '5.5' => true - ), - 'mysqli_savepoint' => array( - '5.4' => false, - '5.5' => true - ), - 'pg_escape_literal' => array( - '5.4' => false, - '5.5' => true - ), - 'pg_escape_identifier' => array( - '5.4' => false, - '5.5' => true - ), - 'socket_sendmsg' => array( - '5.4' => false, - '5.5' => true - ), - 'socket_recvmsg' => array( - '5.4' => false, - '5.5' => true - ), - 'socket_cmsg_space' => array( - '5.4' => false, - '5.5' => true - ), - 'cli_get_process_title' => array( - '5.4' => false, - '5.5' => true - ), - 'cli_set_process_title' => array( - '5.4' => false, - '5.5' => true - ), - 'datefmt_format_object' => array( - '5.4' => false, - '5.5' => true - ), - 'datefmt_get_calendar_object' => array( - '5.4' => false, - '5.5' => true - ), - 'datefmt_get_timezone' => array( - '5.4' => false, - '5.5' => true - ), - 'datefmt_set_timezone' => array( - '5.4' => false, - '5.5' => true - ), - 'datefmt_get_calendar_object' => array( - '5.4' => false, - '5.5' => true - ), - 'intlcal_create_instance' => array( - '5.4' => false, - '5.5' => true - ), - 'intlcal_get_keyword_values_for_locale' => array( - '5.4' => false, - '5.5' => true - ), - 'intlcal_get_now' => array( - '5.4' => false, - '5.5' => true - ), - 'intlcal_get_available_locales' => array( - '5.4' => false, - '5.5' => true - ), - 'intlcal_get' => array( - '5.4' => false, - '5.5' => true - ), - 'intlcal_get_time' => array( - '5.4' => false, - '5.5' => true - ), - 'intlcal_set_time' => array( - '5.4' => false, - '5.5' => true - ), - 'intlcal_add' => array( - '5.4' => false, - '5.5' => true - ), - 'intlcal_set_time_zone' => array( - '5.4' => false, - '5.5' => true - ), - 'intlcal_after' => array( - '5.4' => false, - '5.5' => true - ), - 'intlcal_before' => array( - '5.4' => false, - '5.5' => true - ), - 'intlcal_set' => array( - '5.4' => false, - '5.5' => true - ), - 'intlcal_roll' => array( - '5.4' => false, - '5.5' => true - ), - 'intlcal_clear' => array( - '5.4' => false, - '5.5' => true - ), - 'intlcal_field_difference' => array( - '5.4' => false, - '5.5' => true - ), - 'intlcal_get_actual_maximum' => array( - '5.4' => false, - '5.5' => true - ), - 'intlcal_get_actual_minumum' => array( - '5.4' => false, - '5.5' => true - ), - 'intlcal_get_day_of_week_type' => array( - '5.4' => false, - '5.5' => true - ), - 'intlcal_get_first_day_of_week' => array( - '5.4' => false, - '5.5' => true - ), - 'intlcal_get_greatest_minimum' => array( - '5.4' => false, - '5.5' => true - ), - 'intlcal_get_least_maximum' => array( - '5.4' => false, - '5.5' => true - ), - 'intlcal_get_locale' => array( - '5.4' => false, - '5.5' => true - ), - 'intlcal_get_maximum' => array( - '5.4' => false, - '5.5' => true - ), - 'intlcal_get_minimal_days_in_first_week' => array( - '5.4' => false, - '5.5' => true - ), - 'intlcal_get_minimum' => array( - '5.4' => false, - '5.5' => true - ), - 'intlcal_get_time_zone' => array( - '5.4' => false, - '5.5' => true - ), - 'intlcal_get_type' => array( - '5.4' => false, - '5.5' => true - ), - 'intlcal_get_weekend_transition' => array( - '5.4' => false, - '5.5' => true - ), - 'intlcal_in_daylight_time' => array( - '5.4' => false, - '5.5' => true - ), - 'intlcal_is_equivalent_to' => array( - '5.4' => false, - '5.5' => true - ), - 'intlcal_is_lenient' => array( - '5.4' => false, - '5.5' => true - ), - 'intlcal_equals' => array( - '5.4' => false, - '5.5' => true - ), - 'intlcal_get_repeated_wall_time_option' => array( - '5.4' => false, - '5.5' => true - ), - 'intlcal_get_skipped_wall_time_option' => array( - '5.4' => false, - '5.5' => true - ), - 'intlcal_set_repeated_wall_time_option' => array( - '5.4' => false, - '5.5' => true - ), - 'intlcal_set_skipped_wall_time_option' => array( - '5.4' => false, - '5.5' => true - ), - 'intlcal_from_date_time' => array( - '5.4' => false, - '5.5' => true - ), - 'intlcal_to_date_time' => array( - '5.4' => false, - '5.5' => true - ), - 'intlcal_get_error_code' => array( - '5.4' => false, - '5.5' => true - ), - 'intlcal_get_error_message' => array( - '5.4' => false, - '5.5' => true - ), - 'intlgregcal_create_instance' => array( - '5.4' => false, - '5.5' => true - ), - 'intlgregcal_set_gregorian_change' => array( - '5.4' => false, - '5.5' => true - ), - 'intlgregcal_get_gregorian_change' => array( - '5.4' => false, - '5.5' => true - ), - 'intlgregcal_is_leap_year' => array( - '5.4' => false, - '5.5' => true - ), - 'intlz_create_time_zone' => array( - '5.4' => false, - '5.5' => true - ), - 'intlz_create_default' => array( - '5.4' => false, - '5.5' => true - ), - 'intlz_get_id' => array( - '5.4' => false, - '5.5' => true - ), - 'intlz_get_gmt' => array( - '5.4' => false, - '5.5' => true - ), - 'intlz_get_unknown' => array( - '5.4' => false, - '5.5' => true - ), - 'intlz_create_enumeration' => array( - '5.4' => false, - '5.5' => true - ), - 'intlz_count_equivalent_ids' => array( - '5.4' => false, - '5.5' => true - ), - 'intlz_create_time_zone_id_enumeration' => array( - '5.4' => false, - '5.5' => true - ), - 'intlz_get_canonical_id' => array( - '5.4' => false, - '5.5' => true - ), - 'intlz_get_region' => array( - '5.4' => false, - '5.5' => true - ), - 'intlz_get_tz_data_version' => array( - '5.4' => false, - '5.5' => true - ), - 'intlz_get_equivalent_id' => array( - '5.4' => false, - '5.5' => true - ), - 'intlz_use_daylight_time' => array( - '5.4' => false, - '5.5' => true - ), - 'intlz_get_offset' => array( - '5.4' => false, - '5.5' => true - ), - 'intlz_get_raw_offset' => array( - '5.4' => false, - '5.5' => true - ), - 'intlz_has_same_rules' => array( - '5.4' => false, - '5.5' => true - ), - 'intlz_get_display_name' => array( - '5.4' => false, - '5.5' => true - ), - 'intlz_get_dst_savings' => array( - '5.4' => false, - '5.5' => true - ), - 'intlz_from_date_time_zone' => array( - '5.4' => false, - '5.5' => true - ), - 'intlz_to_date_time_zone' => array( - '5.4' => false, - '5.5' => true - ), - 'intlz_get_error_code' => array( - '5.4' => false, - '5.5' => true - ), - 'intlz_get_error_message' => array( - '5.4' => false, - '5.5' => true - ), + 'array_column' => array( + '5.4' => false, + '5.5' => true, + ), + 'boolval' => array( + '5.4' => false, + '5.5' => true, + ), + 'json_last_error_msg' => array( + '5.4' => false, + '5.5' => true, + ), + 'password_get_info' => array( + '5.4' => false, + '5.5' => true, + ), + 'password_hash' => array( + '5.4' => false, + '5.5' => true, + ), + 'password_needs_rehash' => array( + '5.4' => false, + '5.5' => true, + ), + 'password_verify' => array( + '5.4' => false, + '5.5' => true, + ), + 'hash_pbkdf2' => array( + '5.4' => false, + '5.5' => true, + ), + 'openssl_pbkdf2' => array( + '5.4' => false, + '5.5' => true, + ), + 'curl_escape' => array( + '5.4' => false, + '5.5' => true, + ), + 'curl_file_create' => array( + '5.4' => false, + '5.5' => true, + ), + 'curl_multi_setopt' => array( + '5.4' => false, + '5.5' => true, + ), + 'curl_multi_strerror' => array( + '5.4' => false, + '5.5' => true, + ), + 'curl_pause' => array( + '5.4' => false, + '5.5' => true, + ), + 'curl_reset' => array( + '5.4' => false, + '5.5' => true, + ), + 'curl_share_close' => array( + '5.4' => false, + '5.5' => true, + ), + 'curl_share_init' => array( + '5.4' => false, + '5.5' => true, + ), + 'curl_share_setopt' => array( + '5.4' => false, + '5.5' => true, + ), + 'curl_strerror' => array( + '5.4' => false, + '5.5' => true, + ), + 'curl_unescape' => array( + '5.4' => false, + '5.5' => true, + ), + 'imageaffinematrixconcat' => array( + '5.4' => false, + '5.5' => true, + ), + 'imageaffinematrixget' => array( + '5.4' => false, + '5.5' => true, + ), + 'imagecrop' => array( + '5.4' => false, + '5.5' => true, + ), + 'imagecropauto' => array( + '5.4' => false, + '5.5' => true, + ), + 'imageflip' => array( + '5.4' => false, + '5.5' => true, + ), + 'imagepalettetotruecolor' => array( + '5.4' => false, + '5.5' => true, + ), + 'imagescale' => array( + '5.4' => false, + '5.5' => true, + ), + 'mysqli_begin_transaction' => array( + '5.4' => false, + '5.5' => true, + ), + 'mysqli_release_savepoint' => array( + '5.4' => false, + '5.5' => true, + ), + 'mysqli_savepoint' => array( + '5.4' => false, + '5.5' => true, + ), + 'pg_escape_literal' => array( + '5.4' => false, + '5.5' => true, + ), + 'pg_escape_identifier' => array( + '5.4' => false, + '5.5' => true, + ), + 'socket_sendmsg' => array( + '5.4' => false, + '5.5' => true, + ), + 'socket_recvmsg' => array( + '5.4' => false, + '5.5' => true, + ), + 'socket_cmsg_space' => array( + '5.4' => false, + '5.5' => true, + ), + 'cli_get_process_title' => array( + '5.4' => false, + '5.5' => true, + ), + 'cli_set_process_title' => array( + '5.4' => false, + '5.5' => true, + ), + 'datefmt_format_object' => array( + '5.4' => false, + '5.5' => true, + ), + 'datefmt_get_calendar_object' => array( + '5.4' => false, + '5.5' => true, + ), + 'datefmt_get_timezone' => array( + '5.4' => false, + '5.5' => true, + ), + 'datefmt_set_timezone' => array( + '5.4' => false, + '5.5' => true, + ), + 'datefmt_get_calendar_object' => array( + '5.4' => false, + '5.5' => true, + ), + 'intlcal_create_instance' => array( + '5.4' => false, + '5.5' => true, + ), + 'intlcal_get_keyword_values_for_locale' => array( + '5.4' => false, + '5.5' => true, + ), + 'intlcal_get_now' => array( + '5.4' => false, + '5.5' => true, + ), + 'intlcal_get_available_locales' => array( + '5.4' => false, + '5.5' => true, + ), + 'intlcal_get' => array( + '5.4' => false, + '5.5' => true, + ), + 'intlcal_get_time' => array( + '5.4' => false, + '5.5' => true, + ), + 'intlcal_set_time' => array( + '5.4' => false, + '5.5' => true, + ), + 'intlcal_add' => array( + '5.4' => false, + '5.5' => true, + ), + 'intlcal_set_time_zone' => array( + '5.4' => false, + '5.5' => true, + ), + 'intlcal_after' => array( + '5.4' => false, + '5.5' => true, + ), + 'intlcal_before' => array( + '5.4' => false, + '5.5' => true, + ), + 'intlcal_set' => array( + '5.4' => false, + '5.5' => true, + ), + 'intlcal_roll' => array( + '5.4' => false, + '5.5' => true, + ), + 'intlcal_clear' => array( + '5.4' => false, + '5.5' => true, + ), + 'intlcal_field_difference' => array( + '5.4' => false, + '5.5' => true, + ), + 'intlcal_get_actual_maximum' => array( + '5.4' => false, + '5.5' => true, + ), + 'intlcal_get_actual_minumum' => array( + '5.4' => false, + '5.5' => true, + ), + 'intlcal_get_day_of_week_type' => array( + '5.4' => false, + '5.5' => true, + ), + 'intlcal_get_first_day_of_week' => array( + '5.4' => false, + '5.5' => true, + ), + 'intlcal_get_greatest_minimum' => array( + '5.4' => false, + '5.5' => true, + ), + 'intlcal_get_least_maximum' => array( + '5.4' => false, + '5.5' => true, + ), + 'intlcal_get_locale' => array( + '5.4' => false, + '5.5' => true, + ), + 'intlcal_get_maximum' => array( + '5.4' => false, + '5.5' => true, + ), + 'intlcal_get_minimal_days_in_first_week' => array( + '5.4' => false, + '5.5' => true, + ), + 'intlcal_get_minimum' => array( + '5.4' => false, + '5.5' => true, + ), + 'intlcal_get_time_zone' => array( + '5.4' => false, + '5.5' => true, + ), + 'intlcal_get_type' => array( + '5.4' => false, + '5.5' => true, + ), + 'intlcal_get_weekend_transition' => array( + '5.4' => false, + '5.5' => true, + ), + 'intlcal_in_daylight_time' => array( + '5.4' => false, + '5.5' => true, + ), + 'intlcal_is_equivalent_to' => array( + '5.4' => false, + '5.5' => true, + ), + 'intlcal_is_lenient' => array( + '5.4' => false, + '5.5' => true, + ), + 'intlcal_equals' => array( + '5.4' => false, + '5.5' => true, + ), + 'intlcal_get_repeated_wall_time_option' => array( + '5.4' => false, + '5.5' => true, + ), + 'intlcal_get_skipped_wall_time_option' => array( + '5.4' => false, + '5.5' => true, + ), + 'intlcal_set_repeated_wall_time_option' => array( + '5.4' => false, + '5.5' => true, + ), + 'intlcal_set_skipped_wall_time_option' => array( + '5.4' => false, + '5.5' => true, + ), + 'intlcal_from_date_time' => array( + '5.4' => false, + '5.5' => true, + ), + 'intlcal_to_date_time' => array( + '5.4' => false, + '5.5' => true, + ), + 'intlcal_get_error_code' => array( + '5.4' => false, + '5.5' => true, + ), + 'intlcal_get_error_message' => array( + '5.4' => false, + '5.5' => true, + ), + 'intlgregcal_create_instance' => array( + '5.4' => false, + '5.5' => true, + ), + 'intlgregcal_set_gregorian_change' => array( + '5.4' => false, + '5.5' => true, + ), + 'intlgregcal_get_gregorian_change' => array( + '5.4' => false, + '5.5' => true, + ), + 'intlgregcal_is_leap_year' => array( + '5.4' => false, + '5.5' => true, + ), + 'intlz_create_time_zone' => array( + '5.4' => false, + '5.5' => true, + ), + 'intlz_create_default' => array( + '5.4' => false, + '5.5' => true, + ), + 'intlz_get_id' => array( + '5.4' => false, + '5.5' => true, + ), + 'intlz_get_gmt' => array( + '5.4' => false, + '5.5' => true, + ), + 'intlz_get_unknown' => array( + '5.4' => false, + '5.5' => true, + ), + 'intlz_create_enumeration' => array( + '5.4' => false, + '5.5' => true, + ), + 'intlz_count_equivalent_ids' => array( + '5.4' => false, + '5.5' => true, + ), + 'intlz_create_time_zone_id_enumeration' => array( + '5.4' => false, + '5.5' => true, + ), + 'intlz_get_canonical_id' => array( + '5.4' => false, + '5.5' => true, + ), + 'intlz_get_region' => array( + '5.4' => false, + '5.5' => true, + ), + 'intlz_get_tz_data_version' => array( + '5.4' => false, + '5.5' => true, + ), + 'intlz_get_equivalent_id' => array( + '5.4' => false, + '5.5' => true, + ), + 'intlz_use_daylight_time' => array( + '5.4' => false, + '5.5' => true, + ), + 'intlz_get_offset' => array( + '5.4' => false, + '5.5' => true, + ), + 'intlz_get_raw_offset' => array( + '5.4' => false, + '5.5' => true, + ), + 'intlz_has_same_rules' => array( + '5.4' => false, + '5.5' => true, + ), + 'intlz_get_display_name' => array( + '5.4' => false, + '5.5' => true, + ), + 'intlz_get_dst_savings' => array( + '5.4' => false, + '5.5' => true, + ), + 'intlz_from_date_time_zone' => array( + '5.4' => false, + '5.5' => true, + ), + 'intlz_to_date_time_zone' => array( + '5.4' => false, + '5.5' => true, + ), + 'intlz_get_error_code' => array( + '5.4' => false, + '5.5' => true, + ), + 'intlz_get_error_message' => array( + '5.4' => false, + '5.5' => true, + ), - 'gmp_root' => array( - '5.5' => false, - '5.6' => true - ), - 'gmp_rootrem' => array( - '5.5' => false, - '5.6' => true - ), - 'hash_equals' => array( - '5.5' => false, - '5.6' => true - ), - 'ldap_escape' => array( - '5.5' => false, - '5.6' => true - ), - 'ldap_modify_batch' => array( - '5.4.25' => false, - '5.5.9' => false, - '5.4.26' => true, - '5.5.10' => true, - '5.6.0' => true, - ), - 'mysqli_get_links_stats' => array( - '5.5' => false, - '5.6' => true - ), - 'openssl_get_cert_locations' => array( - '5.5' => false, - '5.6' => true - ), - 'openssl_x509_fingerprint' => array( - '5.5' => false, - '5.6' => true - ), - 'openssl_spki_new' => array( - '5.5' => false, - '5.6' => true - ), - 'openssl_spki_verify' => array( - '5.5' => false, - '5.6' => true - ), - 'openssl_spki_export_challenge' => array( - '5.5' => false, - '5.6' => true - ), - 'openssl_spki_export' => array( - '5.5' => false, - '5.6' => true - ), - 'pg_connect_poll' => array( - '5.5' => false, - '5.6' => true - ), - 'pg_consume_input' => array( - '5.5' => false, - '5.6' => true - ), - 'pg_flush' => array( - '5.5' => false, - '5.6' => true - ), - 'pg_socket' => array( - '5.5' => false, - '5.6' => true - ), - 'session_abort' => array( - '5.5' => false, - '5.6' => true - ), - 'session_reset' => array( - '5.5' => false, - '5.6' => true - ), + 'gmp_root' => array( + '5.5' => false, + '5.6' => true, + ), + 'gmp_rootrem' => array( + '5.5' => false, + '5.6' => true, + ), + 'hash_equals' => array( + '5.5' => false, + '5.6' => true, + ), + 'ldap_escape' => array( + '5.5' => false, + '5.6' => true, + ), + 'ldap_modify_batch' => array( + '5.4.25' => false, + '5.5.9' => false, + '5.4.26' => true, + '5.5.10' => true, + '5.6.0' => true, + ), + 'mysqli_get_links_stats' => array( + '5.5' => false, + '5.6' => true, + ), + 'openssl_get_cert_locations' => array( + '5.5' => false, + '5.6' => true, + ), + 'openssl_x509_fingerprint' => array( + '5.5' => false, + '5.6' => true, + ), + 'openssl_spki_new' => array( + '5.5' => false, + '5.6' => true, + ), + 'openssl_spki_verify' => array( + '5.5' => false, + '5.6' => true, + ), + 'openssl_spki_export_challenge' => array( + '5.5' => false, + '5.6' => true, + ), + 'openssl_spki_export' => array( + '5.5' => false, + '5.6' => true, + ), + 'pg_connect_poll' => array( + '5.5' => false, + '5.6' => true, + ), + 'pg_consume_input' => array( + '5.5' => false, + '5.6' => true, + ), + 'pg_flush' => array( + '5.5' => false, + '5.6' => true, + ), + 'pg_socket' => array( + '5.5' => false, + '5.6' => true, + ), + 'session_abort' => array( + '5.5' => false, + '5.6' => true, + ), + 'session_reset' => array( + '5.5' => false, + '5.6' => true, + ), - 'random_bytes' => array( - '5.6' => false, - '7.0' => true - ), - 'random_int' => array( - '5.6' => false, - '7.0' => true - ), - 'error_clear_last' => array( - '5.6' => false, - '7.0' => true - ), - 'gmp_random_seed' => array( - '5.6' => false, - '7.0' => true - ), - 'intdiv' => array( - '5.6' => false, - '7.0' => true - ), - 'preg_replace_callback_array' => array( - '5.6' => false, - '7.0' => true - ), - 'gc_mem_caches' => array( - '5.6' => false, - '7.0' => true - ), - 'get_resources' => array( - '5.6' => false, - '7.0' => true - ), - 'posix_setrlimit' => array( - '5.6' => false, - '7.0' => true - ), - 'inflate_add' => array( - '5.6' => false, - '7.0' => true - ), - 'deflate_add' => array( - '5.6' => false, - '7.0' => true - ), - 'inflate_init' => array( - '5.6' => false, - '7.0' => true - ), - 'deflate_init' => array( - '5.6' => false, - '7.0' => true - ), + 'random_bytes' => array( + '5.6' => false, + '7.0' => true, + ), + 'random_int' => array( + '5.6' => false, + '7.0' => true, + ), + 'error_clear_last' => array( + '5.6' => false, + '7.0' => true, + ), + 'gmp_random_seed' => array( + '5.6' => false, + '7.0' => true, + ), + 'intdiv' => array( + '5.6' => false, + '7.0' => true, + ), + 'preg_replace_callback_array' => array( + '5.6' => false, + '7.0' => true, + ), + 'gc_mem_caches' => array( + '5.6' => false, + '7.0' => true, + ), + 'get_resources' => array( + '5.6' => false, + '7.0' => true, + ), + 'posix_setrlimit' => array( + '5.6' => false, + '7.0' => true, + ), + 'inflate_add' => array( + '5.6' => false, + '7.0' => true, + ), + 'deflate_add' => array( + '5.6' => false, + '7.0' => true, + ), + 'inflate_init' => array( + '5.6' => false, + '7.0' => true, + ), + 'deflate_init' => array( + '5.6' => false, + '7.0' => true, + ), - 'socket_export_stream' => array( - '7.0.6' => false, - '7.0.7' => true - ), + 'socket_export_stream' => array( + '7.0.6' => false, + '7.0.7' => true, + ), - 'curl_multi_errno' => array( - '7.0' => false, - '7.1' => true - ), - 'curl_share_errno' => array( - '7.0' => false, - '7.1' => true - ), - 'curl_share_strerror' => array( - '7.0' => false, - '7.1' => true - ), - 'is_iterable' => array( - '7.0' => false, - '7.1' => true - ), - 'pcntl_async_signals' => array( - '7.0' => false, - '7.1' => true - ), - 'session_create_id' => array( - '7.0' => false, - '7.1' => true - ), - 'session_gc' => array( - '7.0' => false, - '7.1' => true - ), + 'curl_multi_errno' => array( + '7.0' => false, + '7.1' => true, + ), + 'curl_share_errno' => array( + '7.0' => false, + '7.1' => true, + ), + 'curl_share_strerror' => array( + '7.0' => false, + '7.1' => true, + ), + 'is_iterable' => array( + '7.0' => false, + '7.1' => true, + ), + 'pcntl_async_signals' => array( + '7.0' => false, + '7.1' => true, + ), + 'session_create_id' => array( + '7.0' => false, + '7.1' => true, + ), + 'session_gc' => array( + '7.0' => false, + '7.1' => true, + ), - 'socket_addrinfo_lookup' => array( - '7.1' => false, - '7.2' => true - ), - 'socket_addrinfo_connect' => array( - '7.1' => false, - '7.2' => true - ), - 'socket_addrinfo_bind' => array( - '7.1' => false, - '7.2' => true - ), - 'socket_addrinfo_explain' => array( - '7.1' => false, - '7.2' => true - ), - ); + 'socket_addrinfo_lookup' => array( + '7.1' => false, + '7.2' => true, + ), + 'socket_addrinfo_connect' => array( + '7.1' => false, + '7.2' => true, + ), + 'socket_addrinfo_bind' => array( + '7.1' => false, + '7.2' => true, + ), + 'socket_addrinfo_explain' => array( + '7.1' => false, + '7.2' => true, + ), + ); /** @@ -1287,18 +1287,18 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) $tokens = $phpcsFile->getTokens(); $ignore = array( - T_DOUBLE_COLON, - T_OBJECT_OPERATOR, - T_FUNCTION, - T_CONST, + T_DOUBLE_COLON, + T_OBJECT_OPERATOR, + T_FUNCTION, + T_CONST, ); $prevToken = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true); if (in_array($tokens[$prevToken]['code'], $ignore) === true) { // Not a call to a PHP function. return; - } - else if($tokens[$prevToken]['code'] === T_NS_SEPARATOR && $tokens[$prevToken - 1]['code'] === T_STRING) { + + } elseif ($tokens[$prevToken]['code'] === T_NS_SEPARATOR && $tokens[$prevToken - 1]['code'] === T_STRING) { // Namespaced function. return; } diff --git a/PHPCompatibility/Sniffs/PHP/NewGroupUseDeclarationsSniff.php b/PHPCompatibility/Sniffs/PHP/NewGroupUseDeclarationsSniff.php index 0ca90efc..492e6036 100644 --- a/PHPCompatibility/Sniffs/PHP/NewGroupUseDeclarationsSniff.php +++ b/PHPCompatibility/Sniffs/PHP/NewGroupUseDeclarationsSniff.php @@ -4,17 +4,19 @@ * * PHP version 7.0 * - * @category PHP - * @package PHPCompatibility - * @author Wim Godden + * @category PHP + * @package PHPCompatibility + * @author Wim Godden */ /** * PHPCompatibility_Sniffs_PHP_NewGroupUseDeclarationsSniff. * - * @category PHP - * @package PHPCompatibility - * @author Wim Godden + * PHP version 7.0 + * + * @category PHP + * @package PHPCompatibility + * @author Wim Godden */ class PHPCompatibility_Sniffs_PHP_NewGroupUseDeclarationsSniff extends PHPCompatibility_Sniff { @@ -60,8 +62,8 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) $prevToken = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($hasCurlyBrace - 1), null, true); if ($prevToken === false || $tokens[$prevToken]['code'] !== T_NS_SEPARATOR) { - return; - } + return; + } } // Still here ? In that case, it is a group use statement. diff --git a/PHPCompatibility/Sniffs/PHP/NewHashAlgorithmsSniff.php b/PHPCompatibility/Sniffs/PHP/NewHashAlgorithmsSniff.php index a89f6b39..fa5c0c9b 100644 --- a/PHPCompatibility/Sniffs/PHP/NewHashAlgorithmsSniff.php +++ b/PHPCompatibility/Sniffs/PHP/NewHashAlgorithmsSniff.php @@ -2,17 +2,17 @@ /** * PHPCompatibility_Sniffs_PHP_NewHashAlgorithmsSniff. * - * @category PHP - * @package PHPCompatibility - * @author Juliette Reinders Folmer + * @category PHP + * @package PHPCompatibility + * @author Juliette Reinders Folmer */ /** * PHPCompatibility_Sniffs_PHP_NewHashAlgorithmsSniff. * - * @category PHP - * @package PHPCompatibility - * @author Juliette Reinders Folmer + * @category PHP + * @package PHPCompatibility + * @author Juliette Reinders Folmer */ class PHPCompatibility_Sniffs_PHP_NewHashAlgorithmsSniff extends PHPCompatibility_AbstractNewFeatureSniff { diff --git a/PHPCompatibility/Sniffs/PHP/NewHeredocInitializeSniff.php b/PHPCompatibility/Sniffs/PHP/NewHeredocInitializeSniff.php index 3742a232..0dd3fefd 100644 --- a/PHPCompatibility/Sniffs/PHP/NewHeredocInitializeSniff.php +++ b/PHPCompatibility/Sniffs/PHP/NewHeredocInitializeSniff.php @@ -58,14 +58,14 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) } $prevNonEmpty = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($equalSign - 1), null, true, null, true); - if ($prevNonEmpty === false || - ($tokens[$prevNonEmpty]['code'] !== T_VARIABLE && $tokens[$prevNonEmpty]['code'] !== T_STRING) + if ($prevNonEmpty === false + || ($tokens[$prevNonEmpty]['code'] !== T_VARIABLE + && $tokens[$prevNonEmpty]['code'] !== T_STRING) ) { // Not a variable or constant assignment. return; } - switch ($tokens[$prevNonEmpty]['type']) { /* * Check class constant assignments. @@ -102,7 +102,7 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) return; } - // Still here ? Then we have a static variable assignment + // Still here ? Then we have a static variable assignment. $this->throwError($phpcsFile, $stackPtr, 'staticvar'); } return; @@ -121,7 +121,7 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) */ protected function throwError(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $type) { - switch($type) { + switch ($type) { case 'const': $phrase = 'class constants'; break; diff --git a/PHPCompatibility/Sniffs/PHP/NewIniDirectivesSniff.php b/PHPCompatibility/Sniffs/PHP/NewIniDirectivesSniff.php index 45df0b0c..856160fc 100644 --- a/PHPCompatibility/Sniffs/PHP/NewIniDirectivesSniff.php +++ b/PHPCompatibility/Sniffs/PHP/NewIniDirectivesSniff.php @@ -2,8 +2,6 @@ /** * PHPCompatibility_Sniffs_PHP_NewIniDirectivesSniff. * - * PHP version 5.5 - * * @category PHP * @package PHPCompatibility * @author Wim Godden @@ -187,7 +185,7 @@ class PHPCompatibility_Sniffs_PHP_NewIniDirectivesSniff extends PHPCompatibility 'allow_url_include' => array( '5.1' => false, - '5.2' => true + '5.2' => true, ), 'filter.default' => array( '5.1' => false, @@ -199,25 +197,25 @@ class PHPCompatibility_Sniffs_PHP_NewIniDirectivesSniff extends PHPCompatibility ), 'pcre.backtrack_limit' => array( '5.1' => false, - '5.2' => true + '5.2' => true, ), 'pcre.recursion_limit' => array( '5.1' => false, - '5.2' => true + '5.2' => true, ), 'session.cookie_httponly' => array( '5.1' => false, - '5.2' => true + '5.2' => true, ), 'cgi.check_shebang_line' => array( '5.2.0' => false, - '5.2.1' => true + '5.2.1' => true, ), 'max_input_nesting_level' => array( '5.2.2' => false, - '5.2.3' => true + '5.2.3' => true, ), 'mysqli.allow_local_infile' => array( @@ -487,11 +485,11 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) $tokens = $phpcsFile->getTokens(); $ignore = array( - T_DOUBLE_COLON, - T_OBJECT_OPERATOR, - T_FUNCTION, - T_CONST, - ); + T_DOUBLE_COLON, + T_OBJECT_OPERATOR, + T_FUNCTION, + T_CONST, + ); $prevToken = $phpcsFile->findPrevious(T_WHITESPACE, ($stackPtr - 1), null, true); if (in_array($tokens[$prevToken]['code'], $ignore) === true) { diff --git a/PHPCompatibility/Sniffs/PHP/NewInterfacesSniff.php b/PHPCompatibility/Sniffs/PHP/NewInterfacesSniff.php index 90c50124..1a910b04 100644 --- a/PHPCompatibility/Sniffs/PHP/NewInterfacesSniff.php +++ b/PHPCompatibility/Sniffs/PHP/NewInterfacesSniff.php @@ -2,19 +2,17 @@ /** * PHPCompatibility_Sniffs_PHP_NewInterfacesSniff. * - * PHP version 5.5 - * - * @category PHP - * @package PHPCompatibility - * @author Juliette Reinders Folmer + * @category PHP + * @package PHPCompatibility + * @author Juliette Reinders Folmer */ /** * PHPCompatibility_Sniffs_PHP_NewInterfacesSniff. * - * @category PHP - * @package PHPCompatibility - * @author Juliette Reinders Folmer + * @category PHP + * @package PHPCompatibility + * @author Juliette Reinders Folmer */ class PHPCompatibility_Sniffs_PHP_NewInterfacesSniff extends PHPCompatibility_AbstractNewFeatureSniff { @@ -28,60 +26,60 @@ class PHPCompatibility_Sniffs_PHP_NewInterfacesSniff extends PHPCompatibility_Ab * @var array(string => array(string => int|string|null)) */ protected $newInterfaces = array( - 'Traversable' => array( - '4.4' => false, - '5.0' => true - ), - - 'Countable' => array( - '5.0' => false, - '5.1' => true - ), - 'OuterIterator' => array( - '5.0' => false, - '5.1' => true - ), - 'RecursiveIterator' => array( - '5.0' => false, - '5.1' => true - ), - 'SeekableIterator' => array( - '5.0' => false, - '5.1' => true - ), - 'Serializable' => array( - '5.0' => false, - '5.1' => true, - ), - 'SplObserver' => array( - '5.0' => false, - '5.1' => true - ), - 'SplSubject' => array( - '5.0' => false, - '5.1' => true - ), - - 'JsonSerializable' => array( - '5.3' => false, - '5.4' => true - ), - 'SessionHandlerInterface' => array( - '5.3' => false, - '5.4' => true - ), - - 'DateTimeInterface' => array( - '5.4' => false, - '5.5' => true - ), - - 'Throwable' => array( - '5.6' => false, - '7.0' => true - ), - - ); + 'Traversable' => array( + '4.4' => false, + '5.0' => true, + ), + + 'Countable' => array( + '5.0' => false, + '5.1' => true, + ), + 'OuterIterator' => array( + '5.0' => false, + '5.1' => true, + ), + 'RecursiveIterator' => array( + '5.0' => false, + '5.1' => true, + ), + 'SeekableIterator' => array( + '5.0' => false, + '5.1' => true, + ), + 'Serializable' => array( + '5.0' => false, + '5.1' => true, + ), + 'SplObserver' => array( + '5.0' => false, + '5.1' => true, + ), + 'SplSubject' => array( + '5.0' => false, + '5.1' => true, + ), + + 'JsonSerializable' => array( + '5.3' => false, + '5.4' => true, + ), + 'SessionHandlerInterface' => array( + '5.3' => false, + '5.4' => true, + ), + + 'DateTimeInterface' => array( + '5.4' => false, + '5.5' => true, + ), + + 'Throwable' => array( + '5.6' => false, + '7.0' => true, + ), + + ); /** * A list of methods which cannot be used in combination with particular interfaces. @@ -89,11 +87,11 @@ class PHPCompatibility_Sniffs_PHP_NewInterfacesSniff extends PHPCompatibility_Ab * @var array(string => array(string => string)) */ protected $unsupportedMethods = array( - 'Serializable' => array( - '__sleep' => 'http://php.net/serializable', - '__wakeup' => 'http://php.net/serializable', - ), - ); + 'Serializable' => array( + '__sleep' => 'http://php.net/serializable', + '__wakeup' => 'http://php.net/serializable', + ), + ); /** * Returns an array of tokens this test wants to listen for. @@ -134,7 +132,7 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); - switch($tokens[$stackPtr]['type']) { + switch ($tokens[$stackPtr]['type']) { case 'T_CLASS': case 'T_ANON_CLASS': $this->processClassToken($phpcsFile, $stackPtr); @@ -176,9 +174,9 @@ private function processClassToken(PHP_CodeSniffer_File $phpcsFile, $stackPtr) $tokens = $phpcsFile->getTokens(); $checkMethods = false; - if(isset($tokens[$stackPtr]['scope_closer'])) { + if (isset($tokens[$stackPtr]['scope_closer'])) { $checkMethods = true; - $scopeCloser = $tokens[$stackPtr]['scope_closer']; + $scopeCloser = $tokens[$stackPtr]['scope_closer']; } foreach ($interfaces as $interface) { diff --git a/PHPCompatibility/Sniffs/PHP/NewKeywordsSniff.php b/PHPCompatibility/Sniffs/PHP/NewKeywordsSniff.php index 4fccf37a..76e7cebc 100644 --- a/PHPCompatibility/Sniffs/PHP/NewKeywordsSniff.php +++ b/PHPCompatibility/Sniffs/PHP/NewKeywordsSniff.php @@ -2,8 +2,6 @@ /** * PHPCompatibility_Sniffs_PHP_NewKeywordsSniff. * - * PHP version 5.5 - * * @category PHP * @package PHPCompatibility * @author Wim Godden @@ -16,7 +14,6 @@ * @category PHP * @package PHPCompatibility * @author Wim Godden - * @version 1.0.0 * @copyright 2013 Cu.be Solutions bvba */ class PHPCompatibility_Sniffs_PHP_NewKeywordsSniff extends PHPCompatibility_AbstractNewFeatureSniff @@ -38,83 +35,92 @@ class PHPCompatibility_Sniffs_PHP_NewKeywordsSniff extends PHPCompatibility_Abst * @var array(string => array(string => int|string|null)) */ protected $newKeywords = array( - 'T_HALT_COMPILER' => array( - '5.0' => false, - '5.1' => true, - 'description' => '"__halt_compiler" keyword' - ), - 'T_CONST' => array( - '5.2' => false, - '5.3' => true, - 'description' => '"const" keyword', - 'condition' => 'isClassConstant', // Keyword is only new when not in class context. - ), - 'T_CALLABLE' => array( - '5.3' => false, - '5.4' => true, - 'description' => '"callable" keyword', - 'content' => 'callable', - ), - 'T_DIR' => array( - '5.2' => false, - '5.3' => true, - 'description' => '__DIR__ magic constant', - 'content' => '__DIR__', - ), - 'T_GOTO' => array( - '5.2' => false, - '5.3' => true, - 'description' => '"goto" keyword', - 'content' => 'goto', - ), - 'T_INSTEADOF' => array( - '5.3' => false, - '5.4' => true, - 'description' => '"insteadof" keyword (for traits)', - 'content' => 'insteadof', - ), - 'T_NAMESPACE' => array( - '5.2' => false, - '5.3' => true, - 'description' => '"namespace" keyword', - 'content' => 'namespace', - ), - 'T_NS_C' => array( - '5.2' => false, - '5.3' => true, - 'description' => '__NAMESPACE__ magic constant', - 'content' => '__NAMESPACE__', - ), - 'T_USE' => array( - '5.2' => false, - '5.3' => true, - 'description' => '"use" keyword (for traits/namespaces/anonymous functions)' - ), - 'T_TRAIT' => array( - '5.3' => false, - '5.4' => true, - 'description' => '"trait" keyword', - 'content' => 'trait', - ), - 'T_TRAIT_C' => array( - '5.3' => false, - '5.4' => true, - 'description' => '__TRAIT__ magic constant', - 'content' => '__TRAIT__', - ), - 'T_YIELD' => array( - '5.4' => false, - '5.5' => true, - 'description' => '"yield" keyword (for generators)', - 'content' => 'yield', - ), - 'T_FINALLY' => array( - '5.4' => false, - '5.5' => true, - 'description' => '"finally" keyword (in exception handling)', - 'content' => 'finally', - ), - ); + 'T_HALT_COMPILER' => array( + '5.0' => false, + '5.1' => true, + 'description' => '"__halt_compiler" keyword', + ), + 'T_CONST' => array( + '5.2' => false, + '5.3' => true, + 'description' => '"const" keyword', + 'condition' => 'isClassConstant', // Keyword is only new when not in class context. + ), + 'T_CALLABLE' => array( + '5.3' => false, + '5.4' => true, + 'description' => '"callable" keyword', + 'content' => 'callable', + ), + 'T_DIR' => array( + '5.2' => false, + '5.3' => true, + 'description' => '__DIR__ magic constant', + 'content' => '__DIR__', + ), + 'T_GOTO' => array( + '5.2' => false, + '5.3' => true, + 'description' => '"goto" keyword', + 'content' => 'goto', + ), + 'T_INSTEADOF' => array( + '5.3' => false, + '5.4' => true, + 'description' => '"insteadof" keyword (for traits)', + 'content' => 'insteadof', + ), + 'T_NAMESPACE' => array( + '5.2' => false, + '5.3' => true, + 'description' => '"namespace" keyword', + 'content' => 'namespace', + ), + 'T_NS_C' => array( + '5.2' => false, + '5.3' => true, + 'description' => '__NAMESPACE__ magic constant', + 'content' => '__NAMESPACE__', + ), + 'T_USE' => array( + '5.2' => false, + '5.3' => true, + 'description' => '"use" keyword (for traits/namespaces/anonymous functions)', + ), + 'T_TRAIT' => array( + '5.3' => false, + '5.4' => true, + 'description' => '"trait" keyword', + 'content' => 'trait', + ), + 'T_TRAIT_C' => array( + '5.3' => false, + '5.4' => true, + 'description' => '__TRAIT__ magic constant', + 'content' => '__TRAIT__', + ), + // The specifics for distinguishing between 'yield' and 'yield from' are dealt + // with in the translation logic. + // This token has to be placed above the `T_YIELD` token in this array to allow for this. + 'T_YIELD_FROM' => array( + '5.6' => false, + '7.0' => true, + 'description' => '"yield from" keyword (for generators)', + 'content' => 'yield', + ), + 'T_YIELD' => array( + '5.4' => false, + '5.5' => true, + 'description' => '"yield" keyword (for generators)', + 'content' => 'yield', + ), + 'T_FINALLY' => array( + '5.4' => false, + '5.5' => true, + 'description' => '"finally" keyword (in exception handling)', + 'content' => 'finally', + ), + ); /** * Translation table for T_STRING tokens. @@ -172,6 +178,9 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) $tokens = $phpcsFile->getTokens(); $tokenType = $tokens[$stackPtr]['type']; + // Allow for dealing with multi-token keywords, like "yield from". + $end = $stackPtr; + // Translate T_STRING token if necessary. if ($tokens[$stackPtr]['type'] === 'T_STRING') { $content = $tokens[$stackPtr]['content']; @@ -183,11 +192,40 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) $tokenType = $this->translateContentToToken[$content]; } + /* + * Special case: distinguish between `yield` and `yield from`. + * + * PHPCS currently (at least up to v 3.0.1) does not backfill for the + * `yield` nor the `yield from` keywords. + * See: https://github.com/squizlabs/PHP_CodeSniffer/issues/1524 + * + * In PHP < 5.5, both `yield` as well as `from` are tokenized as T_STRING. + * In PHP 5.5 - 5.6, `yield` is tokenized as T_YIELD and `from` as T_STRING, + * but the `T_YIELD_FROM` token *is* defined in PHP. + * In PHP 7.0+ both are tokenized as their respective token, however, + * a multi-line "yield from" is tokenized as two tokens. + */ + if ($tokenType === 'T_YIELD') { + $nextToken = $phpcsFile->findNext(T_WHITESPACE, ($end + 1), null, true); + if ($tokens[$nextToken]['code'] === T_STRING + && $tokens[$nextToken]['content'] === 'from' + ) { + $tokenType = 'T_YIELD_FROM'; + $end = $nextToken; + } + unset($nextToken); + } + + if ($tokenType === 'T_YIELD_FROM' && $tokens[($stackPtr - 1)]['type'] === 'T_YIELD_FROM') { + // Multi-line "yield from", no need to report it twice. + return; + } + if (isset($this->newKeywords[$tokenType]) === false) { return; } - $nextToken = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr + 1), null, true); + $nextToken = $phpcsFile->findNext(PHP_CodeSniffer_Tokens::$emptyTokens, ($end + 1), null, true); $prevToken = $phpcsFile->findPrevious(PHP_CodeSniffer_Tokens::$emptyTokens, ($stackPtr - 1), null, true); @@ -197,10 +235,11 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) // Either type will result in false-positives when targetting lower versions // of PHP where the name was not reserved, unless we explicitly check for // them. - if ( - ($nextToken === false || $tokens[$nextToken]['type'] !== 'T_OPEN_PARENTHESIS') - && - ($prevToken === false || $tokens[$prevToken]['type'] !== 'T_CLASS' || $tokens[$prevToken]['type'] !== 'T_INTERFACE') + if (($nextToken === false + || $tokens[$nextToken]['type'] !== 'T_OPEN_PARENTHESIS') + && ($prevToken === false + || $tokens[$prevToken]['type'] !== 'T_CLASS' + || $tokens[$prevToken]['type'] !== 'T_INTERFACE') ) { // Skip based on token scope condition. if (isset($this->newKeywords[$tokenType]['condition']) diff --git a/PHPCompatibility/Sniffs/PHP/NewLanguageConstructsSniff.php b/PHPCompatibility/Sniffs/PHP/NewLanguageConstructsSniff.php index 5f62b4d7..c750e2f0 100644 --- a/PHPCompatibility/Sniffs/PHP/NewLanguageConstructsSniff.php +++ b/PHPCompatibility/Sniffs/PHP/NewLanguageConstructsSniff.php @@ -2,8 +2,6 @@ /** * PHPCompatibility_Sniffs_PHP_NewLanguageConstructsSniff. * - * PHP version 5.5 - * * @category PHP * @package PHPCompatibility * @author Wim Godden @@ -16,7 +14,6 @@ * @category PHP * @package PHPCompatibility * @author Wim Godden - * @version 1.0.0 * @copyright 2013 Cu.be Solutions bvba */ class PHPCompatibility_Sniffs_PHP_NewLanguageConstructsSniff extends PHPCompatibility_AbstractNewFeatureSniff @@ -31,42 +28,42 @@ class PHPCompatibility_Sniffs_PHP_NewLanguageConstructsSniff extends PHPCompatib * @var array(string => array(string => int|string|null)) */ protected $newConstructs = array( - 'T_NS_SEPARATOR' => array( - '5.2' => false, - '5.3' => true, - 'description' => 'the \ operator (for namespaces)' - ), - 'T_POW' => array( - '5.5' => false, - '5.6' => true, - 'description' => 'power operator (**)' - ), // identified in PHPCS 1.5 as T_MULTIPLY + T_MULTIPLY - 'T_POW_EQUAL' => array( - '5.5' => false, - '5.6' => true, - 'description' => 'power assignment operator (**=)' - ), // identified in PHPCS 1.5 as T_MULTIPLY + T_MUL_EQUAL - 'T_ELLIPSIS' => array( - '5.5' => false, - '5.6' => true, - 'description' => 'variadic functions using ...' - ), - 'T_SPACESHIP' => array( - '5.6' => false, - '7.0' => true, - 'description' => 'spaceship operator (<=>)' - ), // identified in PHPCS 1.5 as T_IS_SMALLER_OR_EQUAL + T_GREATER_THAN - 'T_COALESCE' => array( - '5.6' => false, - '7.0' => true, - 'description' => 'null coalescing operator (??)' - ), // identified in PHPCS 1.5 as T_INLINE_THEN + T_INLINE_THEN - 'T_COALESCE_EQUAL' => array( - '7.1' => false, - '7.2' => true, - 'description' => 'null coalesce equal operator (??=)' - ), // identified in PHPCS 1.5 as T_INLINE_THEN + T_INLINE_THEN + T_EQUAL and pre-PHPCS 2.8.1 as T_COALESCE + T_EQUAL - ); + 'T_NS_SEPARATOR' => array( + '5.2' => false, + '5.3' => true, + 'description' => 'the \ operator (for namespaces)', + ), + 'T_POW' => array( + '5.5' => false, + '5.6' => true, + 'description' => 'power operator (**)', + ), // Identified in PHPCS 1.5 as T_MULTIPLY + T_MULTIPLY. + 'T_POW_EQUAL' => array( + '5.5' => false, + '5.6' => true, + 'description' => 'power assignment operator (**=)', + ), // Identified in PHPCS 1.5 as T_MULTIPLY + T_MUL_EQUAL. + 'T_ELLIPSIS' => array( + '5.5' => false, + '5.6' => true, + 'description' => 'variadic functions using ...', + ), + 'T_SPACESHIP' => array( + '5.6' => false, + '7.0' => true, + 'description' => 'spaceship operator (<=>)', + ), // Identified in PHPCS 1.5 as T_IS_SMALLER_OR_EQUAL + T_GREATER_THAN. + 'T_COALESCE' => array( + '5.6' => false, + '7.0' => true, + 'description' => 'null coalescing operator (??)', + ), // Identified in PHPCS 1.5 as T_INLINE_THEN + T_INLINE_THEN. + 'T_COALESCE_EQUAL' => array( + '7.1' => false, + '7.2' => true, + 'description' => 'null coalesce equal operator (??=)', + ), // Identified in PHPCS 1.5 as T_INLINE_THEN + T_INLINE_THEN + T_EQUAL and pre-PHPCS 2.8.1 as T_COALESCE + T_EQUAL. + ); /** @@ -77,12 +74,12 @@ class PHPCompatibility_Sniffs_PHP_NewLanguageConstructsSniff extends PHPCompatib * @var array(string => int) */ protected $newConstructsPHPCSCompat = array( - 'T_POW' => T_MULTIPLY, - 'T_POW_EQUAL' => T_MUL_EQUAL, - 'T_SPACESHIP' => T_GREATER_THAN, - 'T_COALESCE' => T_INLINE_THEN, - 'T_COALESCE_EQUAL' => T_EQUAL, - ); + 'T_POW' => T_MULTIPLY, + 'T_POW_EQUAL' => T_MUL_EQUAL, + 'T_SPACESHIP' => T_GREATER_THAN, + 'T_COALESCE' => T_INLINE_THEN, + 'T_COALESCE_EQUAL' => T_EQUAL, + ); /** * Translation table for PHPCS 1.x and older 2.x tokens. @@ -93,8 +90,8 @@ class PHPCompatibility_Sniffs_PHP_NewLanguageConstructsSniff extends PHPCompatib * * If the token combination has multi-layer complexity, such as is the case * with T_COALESCE(_EQUAL), a 'callback' index is added instead pointing to a - * separate function which can determine whether this is the targetted token across - * PHP and PHPCS versions. + * separate function which can determine whether this is the targetted token across + * PHP and PHPCS versions. * * {@internal 'before' was chosen rather than 'after' as that allowed for a 1-on-1 * translation list with the current tokens.}} @@ -102,27 +99,27 @@ class PHPCompatibility_Sniffs_PHP_NewLanguageConstructsSniff extends PHPCompatib * @var array(string => array(string => string)) */ protected $PHPCSCompatTranslate = array( - 'T_MULTIPLY' => array( - 'before' => 'T_MULTIPLY', - 'real_token' => 'T_POW', - ), - 'T_MUL_EQUAL' => array( - 'before' => 'T_MULTIPLY', - 'real_token' => 'T_POW_EQUAL', - ), - 'T_GREATER_THAN' => array( - 'before' => 'T_IS_SMALLER_OR_EQUAL', - 'real_token' => 'T_SPACESHIP', - ), - 'T_INLINE_THEN' => array( - 'callback' => 'isTCoalesce', - 'real_token' => 'T_COALESCE', - ), - 'T_EQUAL' => array( - 'callback' => 'isTCoalesceEqual', - 'real_token' => 'T_COALESCE_EQUAL', - ), - ); + 'T_MULTIPLY' => array( + 'before' => 'T_MULTIPLY', + 'real_token' => 'T_POW', + ), + 'T_MUL_EQUAL' => array( + 'before' => 'T_MULTIPLY', + 'real_token' => 'T_POW_EQUAL', + ), + 'T_GREATER_THAN' => array( + 'before' => 'T_IS_SMALLER_OR_EQUAL', + 'real_token' => 'T_SPACESHIP', + ), + 'T_INLINE_THEN' => array( + 'callback' => 'isTCoalesce', + 'real_token' => 'T_COALESCE', + ), + 'T_EQUAL' => array( + 'callback' => 'isTCoalesceEqual', + 'real_token' => 'T_COALESCE_EQUAL', + ), + ); /** * Returns an array of tokens this test wants to listen for. @@ -135,8 +132,7 @@ public function register() foreach ($this->newConstructs as $token => $versions) { if (defined($token)) { $tokens[] = constant($token); - } - else if(isset($this->newConstructsPHPCSCompat[$token])) { + } elseif (isset($this->newConstructsPHPCSCompat[$token])) { $tokens[] = $this->newConstructsPHPCSCompat[$token]; } } @@ -160,13 +156,10 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) // Translate older PHPCS token combis for new constructs to the actual construct. if (isset($this->newConstructs[$tokenType]) === false) { - if ( - isset($this->PHPCSCompatTranslate[$tokenType]) - && - ((isset($this->PHPCSCompatTranslate[$tokenType]['before']) + if (isset($this->PHPCSCompatTranslate[$tokenType]) + && ((isset($this->PHPCSCompatTranslate[$tokenType]['before'], $tokens[$stackPtr - 1]) === true && $tokens[$stackPtr - 1]['type'] === $this->PHPCSCompatTranslate[$tokenType]['before']) - || - (isset($this->PHPCSCompatTranslate[$tokenType]['callback']) + || (isset($this->PHPCSCompatTranslate[$tokenType]['callback']) === true && call_user_func(array($this, $this->PHPCSCompatTranslate[$tokenType]['callback']), $tokens, $stackPtr) === true)) ) { $tokenType = $this->PHPCSCompatTranslate[$tokenType]['real_token']; @@ -177,7 +170,6 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) // Ignore as will be dealt with via the T_EQUAL token. return; } - } // If the translation did not yield one of the tokens we are looking for, bow out. diff --git a/PHPCompatibility/Sniffs/PHP/NewMagicClassConstantSniff.php b/PHPCompatibility/Sniffs/PHP/NewMagicClassConstantSniff.php index 20cb63a4..a7e69f36 100644 --- a/PHPCompatibility/Sniffs/PHP/NewMagicClassConstantSniff.php +++ b/PHPCompatibility/Sniffs/PHP/NewMagicClassConstantSniff.php @@ -45,6 +45,10 @@ public function register() */ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) { + if ($this->supportsBelow('5.4') === false) { + return; + } + $tokens = $phpcsFile->getTokens(); if (strtolower($tokens[$stackPtr]['content']) !== 'class') { @@ -56,64 +60,10 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) return; } - if ($this->supportsBelow('5.4')) { - $phpcsFile->addError( - 'The magic class constant ClassName::class was not available in PHP 5.4 or earlier', - $stackPtr, - 'Found' - ); - } - - /* - * Check against invalid use of the magic `::class` constant. - */ - if ($this->supportsAbove('5.5') === false) { - return; - } - - $classNameToken = $phpcsFile->findPrevious(T_STRING, ($prevToken - 1), null, false, null, true); - - // Useless if not in a namespace. - $hasNamespace = false; - if ($classNameToken !== false) { - $namespace = $this->determineNamespace($phpcsFile, $classNameToken); - if (empty($namespace) === false) { - $hasNamespace = true; - } - } - - if ($hasNamespace === false) { - $phpcsFile->addWarning( - 'Using the magic class constant ClassName::class is only useful in combination with a namespaced class', - $stackPtr, - 'NotInNamespace' - ); - } - - - // Is the magic constant used in a file which actually contains the referenced class ? - if ($classNameToken === false) { - return; - } - - $targetClassName = $tokens[$classNameToken]['content']; - $classPtr = $stackPtr; - while ($classPtr > 0) { - $classPtr = $phpcsFile->findPrevious(T_CLASS, ($classPtr - 1)); - - if ($classPtr !== false) { - $className = $phpcsFile->getDeclarationName($classPtr); - if (empty($className) === false && $className === $targetClassName) { - return; - } - } - } - - // Still here? In that case, the magic constant is used in a file which doesn't contain the target class. - $phpcsFile->addWarning( - 'The magic class constant ClassName::class can only be used in the same file as where the class is defined', + $phpcsFile->addError( + 'The magic class constant ClassName::class was not available in PHP 5.4 or earlier', $stackPtr, - 'FileDoesNotContainClass' + 'Found' ); } } diff --git a/PHPCompatibility/Sniffs/PHP/NewMagicMethodsSniff.php b/PHPCompatibility/Sniffs/PHP/NewMagicMethodsSniff.php index a087e70d..f2bc480a 100644 --- a/PHPCompatibility/Sniffs/PHP/NewMagicMethodsSniff.php +++ b/PHPCompatibility/Sniffs/PHP/NewMagicMethodsSniff.php @@ -2,9 +2,9 @@ /** * PHPCompatibility_Sniffs_PHP_NewMagicMethodsSniff. * - * @category PHP - * @package PHPCompatibility - * @author Juliette Reinders Folmer + * @category PHP + * @package PHPCompatibility + * @author Juliette Reinders Folmer */ /** @@ -12,9 +12,9 @@ * * Warns for non-magic behaviour of magic methods prior to becoming magic. * - * @category PHP - * @package PHPCompatibility - * @author Juliette Reinders Folmer + * @category PHP + * @package PHPCompatibility + * @author Juliette Reinders Folmer */ class PHPCompatibility_Sniffs_PHP_NewMagicMethodsSniff extends PHPCompatibility_AbstractNewFeatureSniff { @@ -29,46 +29,46 @@ class PHPCompatibility_Sniffs_PHP_NewMagicMethodsSniff extends PHPCompatibility_ * @var array(string => array(string => int|string|null)) */ protected $newMagicMethods = array( - '__get' => array( // verified - '4.4' => false, - '5.0' => true, - ), - - '__isset' => array( // verified - '5.0' => false, - '5.1' => true, - ), - '__unset' => array( // verified - '5.0' => false, - '5.1' => true, - ), - '__set_state' => array( // verified - '5.0' => false, - '5.1' => true, - ), - - '__callstatic' => array( // verified - '5.2' => false, - '5.3' => true, - ), - '__invoke' => array( // verified - '5.2' => false, - '5.3' => true, - ), - - '__debuginfo' => array( // verified - '5.5' => false, - '5.6' => true, - ), - - // Special case - only became properly magical in 5.2.0, - // before that it was only called for echo and print. - '__tostring' => array( - '5.1' => false, - '5.2' => true, - 'message' => 'The method %s() was not truly magical in PHP version %s and earlier. The associated magic functionality will only be called when directly combined with echo or print.', - ), - ); + '__get' => array( + '4.4' => false, + '5.0' => true, + ), + + '__isset' => array( + '5.0' => false, + '5.1' => true, + ), + '__unset' => array( + '5.0' => false, + '5.1' => true, + ), + '__set_state' => array( + '5.0' => false, + '5.1' => true, + ), + + '__callstatic' => array( + '5.2' => false, + '5.3' => true, + ), + '__invoke' => array( + '5.2' => false, + '5.3' => true, + ), + + '__debuginfo' => array( + '5.5' => false, + '5.6' => true, + ), + + // Special case - only became properly magical in 5.2.0, + // before that it was only called for echo and print. + '__tostring' => array( + '5.1' => false, + '5.2' => true, + 'message' => 'The method %s() was not truly magical in PHP version %s and earlier. The associated magic functionality will only be called when directly combined with echo or print.', + ), + ); /** diff --git a/PHPCompatibility/Sniffs/PHP/NewMultiCatchSniff.php b/PHPCompatibility/Sniffs/PHP/NewMultiCatchSniff.php index 95f0e137..0fdf8110 100644 --- a/PHPCompatibility/Sniffs/PHP/NewMultiCatchSniff.php +++ b/PHPCompatibility/Sniffs/PHP/NewMultiCatchSniff.php @@ -4,9 +4,9 @@ * * PHP version 7.1 * - * @category PHP - * @package PHPCompatibility - * @author Juliette Reinders Folmer + * @category PHP + * @package PHPCompatibility + * @author Juliette Reinders Folmer */ /** @@ -16,9 +16,9 @@ * * PHP version 7.1 * - * @category PHP - * @package PHPCompatibility - * @author Juliette Reinders Folmer + * @category PHP + * @package PHPCompatibility + * @author Juliette Reinders Folmer */ class PHPCompatibility_Sniffs_PHP_NewMultiCatchSniff extends PHPCompatibility_Sniff { diff --git a/PHPCompatibility/Sniffs/PHP/NewNowdocQuotedHeredocSniff.php b/PHPCompatibility/Sniffs/PHP/NewNowdocQuotedHeredocSniff.php index c619f9c1..2f291514 100644 --- a/PHPCompatibility/Sniffs/PHP/NewNowdocQuotedHeredocSniff.php +++ b/PHPCompatibility/Sniffs/PHP/NewNowdocQuotedHeredocSniff.php @@ -4,9 +4,9 @@ * * PHP version 5.3 * - * @category PHP - * @package PHPCompatibility - * @author Juliette Reinders Folmer + * @category PHP + * @package PHPCompatibility + * @author Juliette Reinders Folmer */ /** @@ -14,9 +14,9 @@ * * PHP 5.3 introduces Nowdoc syntax and (double) quoted identifiers for heredocs. * - * @category PHP - * @package PHPCompatibility - * @author Juliette Reinders Folmer + * @category PHP + * @package PHPCompatibility + * @author Juliette Reinders Folmer */ class PHPCompatibility_Sniffs_PHP_NewNowdocQuotedHeredocSniff extends PHPCompatibility_Sniff { @@ -126,7 +126,6 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) case '"': $isHeredoc = true; break; - } diff --git a/PHPCompatibility/Sniffs/PHP/NewNullableTypesSniff.php b/PHPCompatibility/Sniffs/PHP/NewNullableTypesSniff.php index 121ac514..dcb4fa12 100644 --- a/PHPCompatibility/Sniffs/PHP/NewNullableTypesSniff.php +++ b/PHPCompatibility/Sniffs/PHP/NewNullableTypesSniff.php @@ -4,9 +4,9 @@ * * PHP version 7.1 * - * @category PHP - * @package PHPCompatibility - * @author Juliette Reinders Folmer + * @category PHP + * @package PHPCompatibility + * @author Juliette Reinders Folmer */ /** @@ -16,9 +16,9 @@ * * PHP version 7.1 * - * @category PHP - * @package PHPCompatibility - * @author Juliette Reinders Folmer + * @category PHP + * @package PHPCompatibility + * @author Juliette Reinders Folmer */ class PHPCompatibility_Sniffs_PHP_NewNullableTypesSniff extends PHPCompatibility_Sniff { @@ -144,7 +144,7 @@ protected function processReturnType(PHP_CodeSniffer_File $phpcsFile, $stackPtr) ); $stackPtr--; - while(in_array($tokens[($stackPtr - 1)]['code'], $validTokens, true) === true) { + while (in_array($tokens[($stackPtr - 1)]['code'], $validTokens, true) === true) { $stackPtr--; } diff --git a/PHPCompatibility/Sniffs/PHP/NewReturnTypeDeclarationsSniff.php b/PHPCompatibility/Sniffs/PHP/NewReturnTypeDeclarationsSniff.php index 6f731f92..19eec520 100644 --- a/PHPCompatibility/Sniffs/PHP/NewReturnTypeDeclarationsSniff.php +++ b/PHPCompatibility/Sniffs/PHP/NewReturnTypeDeclarationsSniff.php @@ -4,9 +4,9 @@ * * PHP version 7.0 * - * @category PHP - * @package PHPCompatibility - * @author Wim Godden + * @category PHP + * @package PHPCompatibility + * @author Wim Godden */ /** @@ -14,9 +14,9 @@ * * PHP version 7.0 * - * @category PHP - * @package PHPCompatibility - * @author Wim Godden + * @category PHP + * @package PHPCompatibility + * @author Wim Godden */ class PHPCompatibility_Sniffs_PHP_NewReturnTypeDeclarationsSniff extends PHPCompatibility_AbstractNewFeatureSniff { @@ -29,45 +29,45 @@ class PHPCompatibility_Sniffs_PHP_NewReturnTypeDeclarationsSniff extends PHPComp * * @var array(string => array(string => int|string|null)) */ - protected $newTypes = array ( - 'int' => array( - '5.6' => false, - '7.0' => true, - ), - 'float' => array( - '5.6' => false, - '7.0' => true, - ), - 'bool' => array( - '5.6' => false, - '7.0' => true, - ), - 'string' => array( - '5.6' => false, - '7.0' => true, - ), - 'array' => array( - '5.6' => false, - '7.0' => true, - ), - 'callable' => array( - '5.6' => false, - '7.0' => true, - ), - 'self' => array( - '5.6' => false, - '7.0' => true, - ), - 'Class name' => array( - '5.6' => false, - '7.0' => true, - ), - - 'void' => array( - '7.0' => false, - '7.1' => true, - ), - ); + protected $newTypes = array( + 'int' => array( + '5.6' => false, + '7.0' => true, + ), + 'float' => array( + '5.6' => false, + '7.0' => true, + ), + 'bool' => array( + '5.6' => false, + '7.0' => true, + ), + 'string' => array( + '5.6' => false, + '7.0' => true, + ), + 'array' => array( + '5.6' => false, + '7.0' => true, + ), + 'callable' => array( + '5.6' => false, + '7.0' => true, + ), + 'self' => array( + '5.6' => false, + '7.0' => true, + ), + 'Class name' => array( + '5.6' => false, + '7.0' => true, + ), + + 'void' => array( + '7.0' => false, + '7.1' => true, + ), + ); /** diff --git a/PHPCompatibility/Sniffs/PHP/NewScalarTypeDeclarationsSniff.php b/PHPCompatibility/Sniffs/PHP/NewScalarTypeDeclarationsSniff.php index 5c053623..9b8346bb 100644 --- a/PHPCompatibility/Sniffs/PHP/NewScalarTypeDeclarationsSniff.php +++ b/PHPCompatibility/Sniffs/PHP/NewScalarTypeDeclarationsSniff.php @@ -2,17 +2,17 @@ /** * PHPCompatibility_Sniffs_PHP_NewScalarTypeDeclarationsSniff. * - * @category PHP - * @package PHPCompatibility - * @author Wim Godden + * @category PHP + * @package PHPCompatibility + * @author Wim Godden */ /** * PHPCompatibility_Sniffs_PHP_NewScalarTypeDeclarationsSniff. * - * @category PHP - * @package PHPCompatibility - * @author Wim Godden + * @category PHP + * @package PHPCompatibility + * @author Wim Godden */ class PHPCompatibility_Sniffs_PHP_NewScalarTypeDeclarationsSniff extends PHPCompatibility_AbstractNewFeatureSniff { @@ -25,36 +25,36 @@ class PHPCompatibility_Sniffs_PHP_NewScalarTypeDeclarationsSniff extends PHPComp * * @var array(string => array(string => int|string|null)) */ - protected $newTypes = array ( - 'array' => array( - '5.0' => false, - '5.1' => true, - ), - 'callable' => array( - '5.3' => false, - '5.4' => true, - ), - 'int' => array( - '5.6' => false, - '7.0' => true, - ), - 'float' => array( - '5.6' => false, - '7.0' => true, - ), - 'bool' => array( - '5.6' => false, - '7.0' => true, - ), - 'string' => array( - '5.6' => false, - '7.0' => true, - ), - 'iterable' => array( - '7.0' => false, - '7.1' => true, - ), - ); + protected $newTypes = array( + 'array' => array( + '5.0' => false, + '5.1' => true, + ), + 'callable' => array( + '5.3' => false, + '5.4' => true, + ), + 'int' => array( + '5.6' => false, + '7.0' => true, + ), + 'float' => array( + '5.6' => false, + '7.0' => true, + ), + 'bool' => array( + '5.6' => false, + '7.0' => true, + ), + 'string' => array( + '5.6' => false, + '7.0' => true, + ), + 'iterable' => array( + '7.0' => false, + '7.1' => true, + ), + ); /** @@ -64,12 +64,12 @@ class PHPCompatibility_Sniffs_PHP_NewScalarTypeDeclarationsSniff extends PHPComp * * @var array(string => string) */ - protected $invalidTypes = array ( - 'parent' => 'self', - 'static' => 'self', - 'boolean' => 'bool', - 'integer' => 'int', - ); + protected $invalidTypes = array( + 'parent' => 'self', + 'static' => 'self', + 'boolean' => 'bool', + 'integer' => 'int', + ); /** @@ -98,7 +98,7 @@ public function register() public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) { // Get all parameters from method signature. - $paramNames = $this->getMethodParameters($phpcsFile, $stackPtr); + $paramNames = $this->getMethodParameters($phpcsFile, $stackPtr); if (empty($paramNames)) { return; } @@ -119,14 +119,14 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) $param['token'], 'TypeHintFound' ); - } - else if (isset($this->newTypes[$type_hint])) { + + } elseif (isset($this->newTypes[$type_hint])) { $itemInfo = array( 'name' => $type_hint, ); $this->handleFeature($phpcsFile, $param['token'], $itemInfo); - } - else if (isset($this->invalidTypes[$type_hint])) { + + } elseif (isset($this->invalidTypes[$type_hint])) { $error = "'%s' is not a valid type declaration. Did you mean %s ?"; $data = array( $type_hint, @@ -134,8 +134,8 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) ); $phpcsFile->addError($error, $param['token'], 'InvalidTypeHintFound', $data); - } - else if ($type_hint === 'self') { + + } elseif ($type_hint === 'self') { if ($this->inClassScope($phpcsFile, $stackPtr, false) === false) { $phpcsFile->addError( "'self' type cannot be used outside of class scope", diff --git a/PHPCompatibility/Sniffs/PHP/NonStaticMagicMethodsSniff.php b/PHPCompatibility/Sniffs/PHP/NonStaticMagicMethodsSniff.php index 8a4c6225..590e8caf 100644 --- a/PHPCompatibility/Sniffs/PHP/NonStaticMagicMethodsSniff.php +++ b/PHPCompatibility/Sniffs/PHP/NonStaticMagicMethodsSniff.php @@ -119,7 +119,7 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) $functionPtr = $stackPtr; // Find all the functions in this class or interface. - while ($functionToken = $phpcsFile->findNext(T_FUNCTION, $functionPtr, $classScopeCloser)) { + while (($functionToken = $phpcsFile->findNext(T_FUNCTION, $functionPtr, $classScopeCloser)) !== false) { /* * Get the scope closer for this function in order to know how * to advance to the next function. @@ -158,7 +158,7 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) $errorCode = $errorCodeBase.'MethodStatic'; $data = array($methodName); - if ( $this->magicMethods[$methodNameLc]['static'] === true ) { + if ($this->magicMethods[$methodNameLc]['static'] === true) { $error = 'Magic method %s must be defined as static.'; $errorCode = $errorCodeBase.'MethodNonStatic'; } diff --git a/PHPCompatibility/Sniffs/PHP/ParameterShadowSuperGlobalsSniff.php b/PHPCompatibility/Sniffs/PHP/ParameterShadowSuperGlobalsSniff.php index 61ec3bda..2d7a1c3f 100644 --- a/PHPCompatibility/Sniffs/PHP/ParameterShadowSuperGlobalsSniff.php +++ b/PHPCompatibility/Sniffs/PHP/ParameterShadowSuperGlobalsSniff.php @@ -1,4 +1,15 @@ + * @copyright 2015 Declan Kelly + */ + /** * PHPCompatibility_Sniffs_PHP_ParameterShadowSuperGlobalsSniff * @@ -8,10 +19,10 @@ * * PHP version 5.4 * - * @category PHP - * @package PHPCompatibility - * @author Declan Kelly - * @copyright 2015 Declan Kelly + * @category PHP + * @package PHPCompatibility + * @author Declan Kelly + * @copyright 2015 Declan Kelly */ class PHPCompatibility_Sniffs_PHP_ParameterShadowSuperGlobalsSniff extends PHPCompatibility_Sniff { @@ -21,7 +32,8 @@ class PHPCompatibility_Sniffs_PHP_ParameterShadowSuperGlobalsSniff extends PHPCo * * @return array */ - public function register() { + public function register() + { return array( T_FUNCTION, T_CLOSURE, @@ -31,12 +43,13 @@ public function register() { /** * Processes the test. * - * @param PHP_CodeSniffer_file $phpcsFile The file being scanned. - * @param int $stackPtr The position of the current token + * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. + * @param int $stackPtr The position of the current token. * * @return void */ - public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) { + public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) + { if ($this->supportsAbove('5.4') === false) { return; } diff --git a/PHPCompatibility/Sniffs/PHP/PregReplaceEModifierSniff.php b/PHPCompatibility/Sniffs/PHP/PregReplaceEModifierSniff.php index fdce9b1f..249c0577 100644 --- a/PHPCompatibility/Sniffs/PHP/PregReplaceEModifierSniff.php +++ b/PHPCompatibility/Sniffs/PHP/PregReplaceEModifierSniff.php @@ -2,7 +2,7 @@ /** * PHPCompatibility_Sniffs_PHP_PregReplaceEModifierSniff. * - * PHP version 5.6 + * PHP version 5.5 * * @category PHP * @package PHPCompatibility @@ -13,10 +13,14 @@ /** * PHPCompatibility_Sniffs_PHP_PregReplaceEModifierSniff. * + * Check for usage of the `e` modifier with PCRE functions which is deprecated since PHP 5.5 + * and removed as of PHP 7.0. + * + * PHP version 5.5 + * * @category PHP * @package PHPCompatibility * @author Wim Godden - * @version 1.1.0 * @copyright 2014 Cu.be Solutions bvba */ class PHPCompatibility_Sniffs_PHP_PregReplaceEModifierSniff extends PHPCompatibility_Sniff @@ -74,7 +78,7 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) $functionNameLc = strtolower($functionName); // Bow out if not one of the functions we're targetting. - if ( isset($this->functions[$functionNameLc]) === false ) { + if (isset($this->functions[$functionNameLc]) === false) { return; } @@ -97,8 +101,8 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) $this->processRegexPattern($value, $phpcsFile, $value['end'], $functionName); } - } - else { + + } else { $this->processRegexPattern($firstParam, $phpcsFile, $stackPtr, $functionName); } @@ -127,7 +131,7 @@ protected function processRegexPattern($pattern, $phpcsFile, $stackPtr, $functio * and function calls. We are only concerned with the strings. */ $regex = ''; - for ($i = $pattern['start']; $i <= $pattern['end']; $i++ ) { + for ($i = $pattern['start']; $i <= $pattern['end']; $i++) { if (in_array($tokens[$i]['code'], PHP_CodeSniffer_Tokens::$stringTokens, true) === true) { $content = $this->stripQuotes($tokens[$i]['content']); if ($tokens[$i]['code'] === T_DOUBLE_QUOTED_STRING) { @@ -158,12 +162,11 @@ protected function processRegexPattern($pattern, $phpcsFile, $stackPtr, $functio if (isset($this->doublesSeparators[$regexFirstChar])) { $regexEndPos = strrpos($regex, $this->doublesSeparators[$regexFirstChar]); - } - else { + } else { $regexEndPos = strrpos($regex, $regexFirstChar); } - if($regexEndPos) { + if ($regexEndPos !== false) { $modifiers = substr($regex, $regexEndPos + 1); if (strpos($modifiers, 'e') !== false) { diff --git a/PHPCompatibility/Sniffs/PHP/RemovedAlternativePHPTagsSniff.php b/PHPCompatibility/Sniffs/PHP/RemovedAlternativePHPTagsSniff.php index b52df53b..749a1f1b 100644 --- a/PHPCompatibility/Sniffs/PHP/RemovedAlternativePHPTagsSniff.php +++ b/PHPCompatibility/Sniffs/PHP/RemovedAlternativePHPTagsSniff.php @@ -2,9 +2,11 @@ /** * PHPCompatibility_Sniffs_PHP_RemovedAlternativePHPTags. * - * @category PHP - * @package PHPCompatibility - * @author Juliette Reinders Folmer + * PHP version 7.0 + * + * @category PHP + * @package PHPCompatibility + * @author Juliette Reinders Folmer */ /** @@ -12,9 +14,11 @@ * * Check for usage of alternative PHP tags - removed in PHP 7.0. * - * @category PHP - * @package PHPCompatibility - * @author Juliette Reinders Folmer + * PHP version 7.0 + * + * @category PHP + * @package PHPCompatibility + * @author Juliette Reinders Folmer * * Based on `Generic_Sniffs_PHP_DisallowAlternativePHPTags` by Juliette Reinders Folmer * which was merged into PHPCS 2.7.0. @@ -27,7 +31,7 @@ class PHPCompatibility_Sniffs_PHP_RemovedAlternativePHPTagsSniff extends PHPComp * * @var bool */ - private $_aspTags = false; + private $aspTags = false; /** * Returns an array of tokens this test wants to listen for. @@ -37,14 +41,14 @@ class PHPCompatibility_Sniffs_PHP_RemovedAlternativePHPTagsSniff extends PHPComp public function register() { if (version_compare(phpversion(), '7.0', '<') === true) { - $this->_aspTags = (boolean) ini_get('asp_tags'); + $this->aspTags = (boolean) ini_get('asp_tags'); } return array( - T_OPEN_TAG, - T_OPEN_TAG_WITH_ECHO, - T_INLINE_HTML, - ); + T_OPEN_TAG, + T_OPEN_TAG_WITH_ECHO, + T_INLINE_HTML, + ); }//end register() @@ -80,21 +84,20 @@ public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) $content, ); $errorCode = 'ASPOpenTagFound'; - } - else if (strpos($content, '