Skip to content

Conversation

@jrfnl
Copy link
Member

@jrfnl jrfnl commented Sep 8, 2025

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 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.

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 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.

👉 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

  • 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.

jrfnl added 30 commits September 8, 2025 16:55
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.
@jrfnl jrfnl added this to the 10.0.0 milestone Sep 8, 2025
@jrfnl jrfnl requested a review from wimg September 8, 2025 15:01
@wimg wimg merged commit 645a525 into develop Sep 8, 2025
58 of 59 checks passed
@wimg wimg deleted the feature/phpcs-4.x-compatibility branch September 8, 2025 15:22
@fsmeier
Copy link

fsmeier commented Oct 20, 2025

Heyhey, thank you for your work!
Is there an estimation when we can expect this being released?

All the best,
Florian

@jrfnl
Copy link
Member Author

jrfnl commented Oct 20, 2025

@fsmeier Please see the discussion in #1884

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Type: enhancement Type: meta Repo strategy/structure related

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants