-
-
Notifications
You must be signed in to change notification settings - Fork 8
Update for compatibility with PHPCS 4.0 #367
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
e570313
to
cc72a1a
Compare
As of PHPCS 4.0, the base sniff test class has been renamed from `AbstractSniffUnitTest` to `AbstractSniffTestCase`. Additionally the PHPCS test setup no longer uses the outdated custom test suite creation. This means that to allow for the tests to run on both PHPCS 3.x as well as 4.x, some changes are needed. This commit handles this by: * Changing all test files to `extend` the new test case class and adding a class alias to the test bootstrap for compatibility with PHPCS 3.x. * Adding separate scripts to the `composer.json` file for invoking the tests on PHPCS 3.x vs 4.x. * Add jobs to test against PHPCS 4.x to all `test` matrices. * Updating the `quicktest`, `test` and `coverage` jobs to use the correct Composer script based on the installed PHPCS version. This commit also adds a step to all three jobs to remove the `PHPCSDevCS` dependency. This dependency is not needed in the tests and is currently not (yet) compatible with PHPCS 4.x, so it would block the `composer install`. _Note: even though PHPCS 4.x supports PHPUnit 10 and 11, we cannot widen the version restrictions for PHPUnit (yet) while PHPCS 3.x is also supported as it would lead to PHPUnit 10/11 being installed for PHPCS 3.x on PHP >= 8.1, which would break the test runs._
As of PHPCS 4.0, PHPCS will no longer support scanning of JS/CSS files. This is the only sniff in PHPCSExtra which supports JS/CSS and that support is hereby deprecated and will be removed in PHPCSExtra 2.0.
The tokenization of (namespaced) "names" has changed in PHP 8.0 and this new tokenization will come into effect for PHP_CodeSniffer as of version 4.0.0. This commit adds handling for the new tokenization of fully qualified function calls to `dirname()` to this sniff.
The tokenization of (namespaced) "names" has changed in PHP 8.0 and this new tokenization will come into effect for PHP_CodeSniffer as of version 4.0.0. This commit adds handling for the new tokenization of fully qualified function calls to `*sprintf()` to this sniff.
The tokenization of (namespaced) "names" has changed in PHP 8.0 and this new tokenization will come into effect for PHP_CodeSniffer as of version 4.0.0. This commit adds handling for the new tokenization of fully qualified `true`/`false`/`null` to this sniff.
Two tests from the `KeywordSpacingUnitTest.1.inc` file involve code which is interpreted differently in PHP < 8.0 vs 8.0 due to the PHP change to tokenize namespaced names as a single token. Along the same lines, the code samples in the `KeywordSpacingUnitTest.2.inc` file will also no longer trigger the sniff. As this change has been polyfilled in PHPCS 4.0, this invalidates those tests when running the sniff on PHPCS 4.0. This commit moves the original tests from the `KeywordSpacingUnitTest.1.inc` file to a new `KeywordSpacingUnitTest.5.inc` file, which will be skipped on PHPCS 4.0. The `KeywordSpacingUnitTest.2.inc` file will also be skipped. It also updates the tests in the `KeywordSpacingUnitTest.1.inc` file to be tests which are PHPCS cross-version compatible.
Two tests from the `LowercaseFunctionConst.inc` file involve code which is interpreted differently in PHP < 8.0 vs 8.0 due to the PHP change to tokenize namespaced names as a single token. As this change has been polyfilled in PHPCS 4.0, this invalidates those tests when running the sniff on PHPCS 4.0. This commit: * Renames the `LowercaseFunctionConst.inc` test case file to `LowercaseFunctionConst.1.inc`. * Moves the original tests to a new `LowercaseFunctionConst.2.inc` file, which will be skipped on PHPCS 4.0. * And updates the tests in the `LowercaseFunctionConst.1.inc` file to be tests which are PHPCS cross-version compatible.
One test from the `NoLeadingBackslashUnitTest.1.inc` file involves code which is interpreted differently in PHP < 8.0 vs 8.0 due to the PHP change to tokenize namespaced names as a single token. As this change has been polyfilled in PHPCS 4.0, this invalidates those tests when running the sniff on PHPCS 4.0. This commit: * Updates the sniff to be PHPCS cross-version compatible. * Moves the original tests to a new `NoLeadingBackslashUnitTest.6.inc` file, which will be skipped on PHPCS 4.0. * And updates the tests in the `NoLeadingBackslashUnitTest.1.inc` file to be tests which are PHPCS cross-version compatible.
The token walking this sniff did to find the exact token to report the error on needed to be updated to allow for the PHP 8.0 namespaced name as single token change as applied in PHPCS 4.0. Fixed now.
The token walking this sniff did to find the exact token to report the error on needed to be updated to allow for the PHP 8.0 namespaced name as single token change as applied in PHPCS 4.0. Fixed now. Includes some additional tests. Includes updating one test to make it cross-version compatible as the original code was not valid since PHP 8.0.
The token walking this sniff did to find the exact token to report the error on needed to be updated to allow for the PHP 8.0 namespaced name as single token change as applied in PHPCS 4.0. Fixed now. Includes updating one test to make it cross-version compatible as the original code was not valid since PHP 8.0.
The tokenization of (namespaced) "names" has changed in PHP 8.0 and this new tokenization will come into effect for PHP_CodeSniffer as of version 4.0.0. This commit adds handling for this new tokenization to this sniff. Includes some additional tests.
cc72a1a
to
881942a
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Tests: update to allow for running the tests on PHPCS 4.x
As of PHPCS 4.0, the base sniff test class has been renamed from
AbstractSniffUnitTest
toAbstractSniffTestCase
.Additionally the PHPCS test setup no longer uses the outdated custom test suite creation.
This means that to allow for the tests to run on both PHPCS 3.x as well as 4.x, some changes are needed.
This commit handles this by:
extend
the new test case class and adding a class alias to the test bootstrap for compatibility with PHPCS 3.x.composer.json
file for invoking the tests on PHPCS 3.x vs 4.x.test
matrices.quicktest
,test
andcoverage
jobs to use the correct Composer script based on the installed PHPCS version.This commit also adds a step to all three jobs to remove the
PHPCSDevCS
dependency. This dependency is not needed in the tests and is currently not (yet) compatible with PHPCS 4.x, so it would block thecomposer install
.Note: even though PHPCS 4.x supports PHPUnit 10 and 11, we cannot widen the version restrictions for PHPUnit (yet) while PHPCS 3.x is also supported as it would lead to PHPUnit 10/11 being installed for PHPCS 3.x on PHP >= 8.1, which would break the test runs.
Universal/PrecisionAlignment: deprecate JS/CSS support
As of PHPCS 4.0, PHPCS will no longer support scanning of JS/CSS files.
This is the only sniff in PHPCSExtra which supports JS/CSS and that support is hereby deprecated and will be removed in PHPCSExtra 2.0.
Modernize/Dirname: update for PHPCS 4.0
The tokenization of (namespaced) "names" has changed in PHP 8.0 and this new tokenization will come into effect for PHP_CodeSniffer as of version 4.0.0.
This commit adds handling for the new tokenization of fully qualified function calls to
dirname()
to this sniff.Universal/NoEchoSprintf: update for PHPCS 4.0
The tokenization of (namespaced) "names" has changed in PHP 8.0 and this new tokenization will come into effect for PHP_CodeSniffer as of version 4.0.0.
This commit adds handling for the new tokenization of fully qualified function calls to
*sprintf()
to this sniff.Universal/NoFQNTrueFalseNull: update for PHPCS 4.0
The tokenization of (namespaced) "names" has changed in PHP 8.0 and this new tokenization will come into effect for PHP_CodeSniffer as of version 4.0.0.
This commit adds handling for the new tokenization of fully qualified
true
/false
/null
to this sniff.Universal/KeywordSpacing: update tests for PHPCS 4.0
Two tests from the
KeywordSpacingUnitTest.1.inc
file involve code which is interpreted differently in PHP < 8.0 vs 8.0 due to the PHP change to tokenize namespaced names as a single token.Along the same lines, the code samples in the
KeywordSpacingUnitTest.2.inc
file will also no longer trigger the sniff.As this change has been polyfilled in PHPCS 4.0, this invalidates those tests when running the sniff on PHPCS 4.0.
This commit moves the original tests from the
KeywordSpacingUnitTest.1.inc
file to a newKeywordSpacingUnitTest.5.inc
file, which will be skipped on PHPCS 4.0. TheKeywordSpacingUnitTest.2.inc
file will also be skipped.It also updates the tests in the
KeywordSpacingUnitTest.1.inc
file to be tests which are PHPCS cross-version compatible.Universal/LowercaseFunctionConst: update tests for PHPCS 4.0
Two tests from the
LowercaseFunctionConst.inc
file involve code which is interpreted differently in PHP < 8.0 vs 8.0 due to the PHP change to tokenize namespaced names as a single token.As this change has been polyfilled in PHPCS 4.0, this invalidates those tests when running the sniff on PHPCS 4.0.
This commit:
LowercaseFunctionConst.inc
test case file toLowercaseFunctionConst.1.inc
.LowercaseFunctionConst.2.inc
file, which will be skipped on PHPCS 4.0.LowercaseFunctionConst.1.inc
file to be tests which are PHPCS cross-version compatible.Universal/NoLeadingBackslash: update for PHPCS 4.0
One test from the
NoLeadingBackslashUnitTest.1.inc
file involves code which is interpreted differently in PHP < 8.0 vs 8.0 due to the PHP change to tokenize namespaced names as a single token.As this change has been polyfilled in PHPCS 4.0, this invalidates those tests when running the sniff on PHPCS 4.0.
This commit:
NoLeadingBackslashUnitTest.6.inc
file, which will be skipped on PHPCS 4.0.NoLeadingBackslashUnitTest.1.inc
file to be tests which are PHPCS cross-version compatible.Universal/DisallowUseClass: update for PHPCS 4.0
The token walking this sniff did to find the exact token to report the error on needed to be updated to allow for the PHP 8.0 namespaced name as single token change as applied in PHPCS 4.0.
Fixed now.
Universal/DisallowUseConst: update for PHPCS 4.0
The token walking this sniff did to find the exact token to report the error on needed to be updated to allow for the PHP 8.0 namespaced name as single token change as applied in PHPCS 4.0.
Fixed now.
Includes some additional tests.
Includes updating one test to make it cross-version compatible as the original code was not valid since PHP 8.0.
Universal/DisallowUseFunction: update for PHPCS 4.0
The token walking this sniff did to find the exact token to report the error on needed to be updated to allow for the PHP 8.0 namespaced name as single token change as applied in PHPCS 4.0.
Fixed now.
Includes updating one test to make it cross-version compatible as the original code was not valid since PHP 8.0.
Universal/NoUselessAliases: update for PHPCS 4.0
The tokenization of (namespaced) "names" has changed in PHP 8.0 and this new tokenization will come into effect for PHP_CodeSniffer as of version 4.0.0.
This commit adds handling for this new tokenization to this sniff.
Includes some additional tests.
Make PHPCS 4 support official