-
-
Notifications
You must be signed in to change notification settings - Fork 205
Make codebase compatible with PHPCS 4.0 #1911
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
This was previously disabled, but now the release of PHPCS 4.0 is imminent, it is relevant again.
…anceof static` The `static` keyword is generally tokenized as `T_STATIC`. However, in PHPCS 3.x, there was one exception - when `static` was used in an `instanceof static` expression, the `static` keyword was tokenized as `T_STRING`. As of PHPCS 4.0, this exception has been removed and `static` in `instanceof static` will now also be tokenized as `T_STATIC`. This commit updates the sniff for compatibility with that change.
…paced name tokenization The tokenization of (namespaced) "names" has changed in PHP 8.0 and while this new tokenization was "undone" for PHPCS 3.x, as of PHP_CodeSniffer 4.0.0, the new tokenization is used. This is relevant for this abstract sniff as it looks for method calls (unchanged, still `T_STRING`) and calls to global functions which may be called either in unqualified or fully qualified form, i.e. `callMe()` or `\callMe()`, with the first needing special handling on PHPCS 3.x to prevent recognizing `Something\callMe()` as the global function, while the second is tokenized differently on PHPCS 4.x, which removes the need for the special handling, but does mean we need to sniff for an extra token. This commit sorts this all out. :point_right: Reviewing this commit will be more straight-forward while ignoring whitespace changes.
…spaced name tokenization The tokenization of (namespaced) "names" has changed in PHP 8.0 and while this new tokenization was "undone" for PHPCS 3.x, as of PHP_CodeSniffer 4.0.0, the new tokenization is used. This commit adds handling for the new tokenization of namespaced names to this sniff. Includes a slew of extra tests just to be sure.
…okenization The tokenization of (namespaced) "names" has changed in PHP 8.0 and while this new tokenization was "undone" for PHPCS 3.x, as of PHP_CodeSniffer 4.0.0, the new tokenization is used. This commit adds handling for the new tokenization of namespaced names to this sniff.
…ed name tokenization The tokenization of (namespaced) "names" has changed in PHP 8.0 and while this new tokenization was "undone" for PHPCS 3.x, as of PHP_CodeSniffer 4.0.0, the new tokenization is used. This commit adds handling for the new tokenization of namespaced names to this sniff.
…me tokenization The tokenization of (namespaced) "names" has changed in PHP 8.0 and while this new tokenization was "undone" for PHPCS 3.x, as of PHP_CodeSniffer 4.0.0, the new tokenization is used. This commit adds handling for the new tokenization of namespaced names to this sniff.
…PHPCS 4.0/PHP 8.0 namespaced name tokenization The tokenization of (namespaced) "names" has changed in PHP 8.0 and while this new tokenization was "undone" for PHPCS 3.x, as of PHP_CodeSniffer 4.0.0, the new tokenization is used. This commit adds handling for the new tokenization of namespaced names to this sniff.
… error message consistent ... in light of the different way fully qualified exit/die is tokenized in PHPCS 4.0.
…PHP 8.0 namespaced name tokenization The tokenization of (namespaced) "names" has changed in PHP 8.0 and while this new tokenization was "undone" for PHPCS 3.x, as of PHP_CodeSniffer 4.0.0, the new tokenization is used. This commit adds handling for the new tokenization of namespaced names to this sniff.
…paced name tokenization The tokenization of (namespaced) "names" has changed in PHP 8.0 and while this new tokenization was "undone" for PHPCS 3.x, as of PHP_CodeSniffer 4.0.0, the new tokenization is used. This commit adds handling for the new tokenization of namespaced names to this sniff.
… tokenization The tokenization of (namespaced) "names" has changed in PHP 8.0 and while this new tokenization was "undone" for PHPCS 3.x, as of PHP_CodeSniffer 4.0.0, the new tokenization is used. This commit adds handling for the new tokenization of namespaced names to this sniff.
…name tokenization The tokenization of (namespaced) "names" has changed in PHP 8.0 and while this new tokenization was "undone" for PHPCS 3.x, as of PHP_CodeSniffer 4.0.0, the new tokenization is used. This commit adds handling for the new tokenization of namespaced names to this sniff.
…0 namespaced name tokenization The tokenization of (namespaced) "names" has changed in PHP 8.0 and while this new tokenization was "undone" for PHPCS 3.x, as of PHP_CodeSniffer 4.0.0, the new tokenization is used. This commit adds handling for the new tokenization of namespaced names to this sniff.
... as it will be incompatible with PHPCS 4.0.
…tokenization The tokenization of (namespaced) "names" has changed in PHP 8.0 and while this new tokenization was "undone" for PHPCS 3.x, as of PHP_CodeSniffer 4.0.0, the new tokenization is used. This commit adds handling for the new tokenization of namespaced names to this sniff.
…enization The tokenization of (namespaced) "names" has changed in PHP 8.0 and while this new tokenization was "undone" for PHPCS 3.x, as of PHP_CodeSniffer 4.0.0, the new tokenization is used. This commit adds handling for the new tokenization of namespaced names to this sniff.
… namespaced name tokenization The tokenization of (namespaced) "names" has changed in PHP 8.0 and while this new tokenization was "undone" for PHPCS 3.x, as of PHP_CodeSniffer 4.0.0, the new tokenization is used. This commit adds handling for the new tokenization of namespaced names to this sniff.
… namespaced name tokenization The tokenization of (namespaced) "names" has changed in PHP 8.0 and while this new tokenization was "undone" for PHPCS 3.x, as of PHP_CodeSniffer 4.0.0, the new tokenization is used. This commit adds handling for the new tokenization of fully qualified function calls to this sniff. Note: this commit will be more straight forward to review while ignoring whitespace changes.
….0/PHP 8.0 namespaced name tokenization The tokenization of (namespaced) "names" has changed in PHP 8.0 and while this new tokenization was "undone" for PHPCS 3.x, as of PHP_CodeSniffer 4.0.0, the new tokenization is used. This commit adds handling for the new tokenization of namespaced names to this sniff.
…0 namespaced name tokenization The tokenization of (namespaced) "names" has changed in PHP 8.0 and while this new tokenization was "undone" for PHPCS 3.x, as of PHP_CodeSniffer 4.0.0, the new tokenization is used. This commit adds handling for the new tokenization of namespaced names to this sniff.
…mespaced name tokenization The tokenization of (namespaced) "names" has changed in PHP 8.0 and while this new tokenization was "undone" for PHPCS 3.x, as of PHP_CodeSniffer 4.0.0, the new tokenization is used. This commit adds handling for the new tokenization of namespaced names to this sniff.
… name tokenization The tokenization of (namespaced) "names" has changed in PHP 8.0 and while this new tokenization was "undone" for PHPCS 3.x, as of PHP_CodeSniffer 4.0.0, the new tokenization is used. This commit adds handling for the new tokenization of namespaced names to this sniff.
… name tokenization The tokenization of (namespaced) "names" has changed in PHP 8.0 and while this new tokenization was "undone" for PHPCS 3.x, as of PHP_CodeSniffer 4.0.0, the new tokenization is used. This commit adds handling for the new tokenization of namespaced names to this sniff.
…spaced name tokenization The tokenization of (namespaced) "names" has changed in PHP 8.0 and while this new tokenization was "undone" for PHPCS 3.x, as of PHP_CodeSniffer 4.0.0, the new tokenization is used. This commit adds handling for the new tokenization of namespaced names to this sniff.
…HP 8.0 namespaced name tokenization The tokenization of (namespaced) "names" has changed in PHP 8.0 and while this new tokenization was "undone" for PHPCS 3.x, as of PHP_CodeSniffer 4.0.0, the new tokenization is used. This commit adds handling for the new tokenization of namespaced names to this sniff.
…/PHP 8.0 namespaced name tokenization The tokenization of (namespaced) "names" has changed in PHP 8.0 and while this new tokenization was "undone" for PHPCS 3.x, as of PHP_CodeSniffer 4.0.0, the new tokenization is used. This commit adds handling for the new tokenization of namespaced names to this sniff.
… 8.0 namespaced name tokenization The tokenization of (namespaced) "names" has changed in PHP 8.0 and while this new tokenization was "undone" for PHPCS 3.x, as of PHP_CodeSniffer 4.0.0, the new tokenization is used. This commit adds handling for the new tokenization of namespaced names to this sniff.
… namespaced name tokenization The tokenization of (namespaced) "names" has changed in PHP 8.0 and while this new tokenization was "undone" for PHPCS 3.x, as of PHP_CodeSniffer 4.0.0, the new tokenization is used. This commit adds handling for the new tokenization of namespaced names to this sniff.
…amespaced name tokenization The tokenization of (namespaced) "names" has changed in PHP 8.0 and while this new tokenization was "undone" for PHPCS 3.x, as of PHP_CodeSniffer 4.0.0, the new tokenization is used. This commit adds handling for the new tokenization of namespaced names to this sniff.
…namespaced name tokenization The tokenization of (namespaced) "names" has changed in PHP 8.0 and while this new tokenization was "undone" for PHPCS 3.x, as of PHP_CodeSniffer 4.0.0, the new tokenization is used. This commit adds handling for the new tokenization of namespaced names to this sniff.
…ame tokenization The tokenization of (namespaced) "names" has changed in PHP 8.0 and while this new tokenization was "undone" for PHPCS 3.x, as of PHP_CodeSniffer 4.0.0, the new tokenization is used. This commit adds handling for the new tokenization of namespaced names to this sniff.
…ed name tokenization The tokenization of (namespaced) "names" has changed in PHP 8.0 and while this new tokenization was "undone" for PHPCS 3.x, as of PHP_CodeSniffer 4.0.0, the new tokenization is used. This commit adds handling for the new tokenization of namespaced names to this sniff.
…espaced name tokenization The tokenization of (namespaced) "names" has changed in PHP 8.0 and while this new tokenization was "undone" for PHPCS 3.x, as of PHP_CodeSniffer 4.0.0, the new tokenization is used. This commit adds handling for the new tokenization of namespaced names to this sniff.
…spaced name tokenization The tokenization of (namespaced) "names" has changed in PHP 8.0 and while this new tokenization was "undone" for PHPCS 3.x, as of PHP_CodeSniffer 4.0.0, the new tokenization is used. This commit adds handling for the new tokenization of namespaced names to this sniff.
…HP 8.0 namespaced name tokenization The tokenization of (namespaced) "names" has changed in PHP 8.0 and while this new tokenization was "undone" for PHPCS 3.x, as of PHP_CodeSniffer 4.0.0, the new tokenization is used. This commit adds handling for the new tokenization of namespaced names to this sniff.
* Allow for Composer installation with PHPCS `^4.0`. * Update GH Actions workflows to test all PHP versions against PHPCS 4.x and those builds are no longer allowed to fail. Note: once PHPCS 4.0 has been released, the workflows will get another update to also test against "low" 4.x, but that should wait until the release.
wimg
approved these changes
Sep 8, 2025
|
Heyhey, thank you for your work! All the best, |
Member
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
GH Actions: start running the tests against PHPCS 4.x (again)
This was previously disabled, but now the release of PHPCS 4.0 is imminent, it is relevant again.
Classes/NewLateStaticBinding: handle change in tokenization for
instanceof staticThe
statickeyword is generally tokenized asT_STATIC. However, in PHPCS 3.x, there was one exception - whenstaticwas used in aninstanceof staticexpression, thestatickeyword was tokenized asT_STRING.As of PHPCS 4.0, this exception has been removed and
staticininstanceof staticwill now also be tokenized asT_STATIC.This commit updates the sniff for compatibility with that change.
AbstractFunctionCallParameterSniff: allow for PHPCS 4.0/PHP 8.0 namespaced name tokenization
The tokenization of (namespaced) "names" has changed in PHP 8.0 and while this new tokenization was "undone" for PHPCS 3.x, as of PHP_CodeSniffer 4.0.0, the new tokenization is used.
This is relevant for this abstract sniff as it looks for method calls (unchanged, still
T_STRING) and calls to global functions which may be called either in unqualified or fully qualified form, i.e.callMe()or\callMe(), with the first needing special handling on PHPCS 3.x to prevent recognizingSomething\callMe()as the global function, while the second is tokenized differently on PHPCS 4.x, which removes the need for the special handling, but does mean we need to sniff for an extra token.This commit sorts this all out.
👉 Reviewing this commit will be more straight-forward while ignoring whitespace changes.
MiscHelper::isUseOfGlobalConstant(): allow for PHPCS 4.0/PHP 8.0 namespaced name tokenization
The tokenization of (namespaced) "names" has changed in PHP 8.0 and while this new tokenization was "undone" for PHPCS 3.x, as of PHP_CodeSniffer 4.0.0, the new tokenization is used.
This commit adds handling for the new tokenization of namespaced names to this sniff.
Includes a slew of extra tests just to be sure.
Constants/NewConstants: allow for PHPCS 4.0/PHP 8.0 namespaced name tokenization
The tokenization of (namespaced) "names" has changed in PHP 8.0 and while this new tokenization was "undone" for PHPCS 3.x, as of PHP_CodeSniffer 4.0.0, the new tokenization is used.
This commit adds handling for the new tokenization of namespaced names to this sniff.
Constants/NewMagicClassConstant: allow for PHPCS 4.0/PHP 8.0 namespaced name tokenization
Constants/RemovedConstants: allow for PHPCS 4.0/PHP 8.0 namespaced name tokenization
ControlStructures/ForbiddenBreakContinueVariableArguments: allow for PHPCS 4.0/PHP 8.0 namespaced name tokenization
FunctionDeclarations/RemovedCallingDestructAfterConstructorExit: make error message consistent
... in light of the different way fully qualified exit/die is tokenized in PHPCS 4.0.
FunctionUse/ArgumentFunctionsReportCurrentValue: allow for PHPCS 4.0/PHP 8.0 namespaced name tokenization
FunctionUse/ArgumentFunctionsUsage: allow for PHPCS 4.0/PHP 8.0 namespaced name tokenization
FunctionUse/NewFunctions: allow for PHPCS 4.0/PHP 8.0 namespaced name tokenization
FunctionUse/RemovedFunctions: allow for PHPCS 4.0/PHP 8.0 namespaced name tokenization
InitialValue/NewConstantScalarExpressions: allow for PHPCS 4.0/PHP 8.0 namespaced name tokenization
Interfaces/NewInterfaces: remove a specific parse error test
... as it will be incompatible with PHPCS 4.0.
Keywords/ForbiddenNames: allow for PHPCS 4.0/PHP 8.0 namespaced name tokenization
Keywords/NewKeywords: allow for PHPCS 4.0/PHP 8.0 namespaced name tokenization
LanguageConstructs/NewLanguageConstructs: allow for PHPCS 4.0/PHP 8.0 namespaced name tokenization
Numbers/RemovedHexadecimalNumericStrings: allow for PHPCS 4.0/PHP 8.0 namespaced name tokenization
Note: this commit will be more straight forward to review while ignoring whitespace changes.
ParameterValues/ForbiddenStripTagsSelfClosingXHTML: allow for PHPCS 4.0/PHP 8.0 namespaced name tokenization
ParameterValues/NewArrayReduceInitialType: allow for PHPCS 4.0/PHP 8.0 namespaced name tokenization
ParameterValues/NewExitAsFunctionCall: allow for PHPCS 4.0/PHP 8.0 namespaced name tokenization
ParameterValues/NewFopenModes: allow for PHPCS 4.0/PHP 8.0 namespaced name tokenization
ParameterValues/NewPackFormat: allow for PHPCS 4.0/PHP 8.0 namespaced name tokenization
ParameterValues/NewProcOpenCmdArray: allow for PHPCS 4.0/PHP 8.0 namespaced name tokenization
ParameterValues/NewStripTagsAllowableTagsArray: allow for PHPCS 4.0/PHP 8.0 namespaced name tokenization
ParameterValues/RemovedImplodeFlexibleParamOrder: allow for PHPCS 4.0/PHP 8.0 namespaced name tokenization
ParameterValues/RemovedLdapConnectSignatures: allow for PHPCS 4.0/PHP 8.0 namespaced name tokenization
ParameterValues/RemovedMbstringModifiers: allow for PHPCS 4.0/PHP 8.0 namespaced name tokenization
ParameterValues/RemovedSetlocaleString: allow for PHPCS 4.0/PHP 8.0 namespaced name tokenization
Syntax/ForbiddenCallTimePassByReference: allow for PHPCS 4.0/PHP 8.0 namespaced name tokenization
Syntax/NewClassMemberAccess: allow for PHPCS 4.0/PHP 8.0 namespaced name tokenization
Syntax/NewDynamicAccessToStatic: allow for PHPCS 4.0/PHP 8.0 namespaced name tokenization
Syntax/NewFunctionArrayDereferencing: allow for PHPCS 4.0/PHP 8.0 namespaced name tokenization
Syntax/RemovedCurlyBraceArrayAccess: allow for PHPCS 4.0/PHP 8.0 namespaced name tokenization
Variables/RemovedIndirectModificationOfGlobals: allow for PHPCS 4.0/PHP 8.0 namespaced name tokenization
Make PHPCS 4.x support official
^4.0.Note: once PHPCS 4.0 has been released, the workflows will get another update to also test against "low" 4.x, but that should wait until the release.