Skip to content

Modernize: use the new PHPCS 4.x Tokens class constants #2010

Merged
wimg merged 3 commits intodevelopfrom
feature/modernize-use-phpcs-tokens-class-constants
Nov 30, 2025
Merged

Modernize: use the new PHPCS 4.x Tokens class constants #2010
wimg merged 3 commits intodevelopfrom
feature/modernize-use-phpcs-tokens-class-constants

Conversation

@jrfnl
Copy link
Member

@jrfnl jrfnl commented Nov 30, 2025

Modernize: prefer Tokens::NAME_TOKENS over Collections::nameTokens()

These token arrays contain the same tokens, but the Tokens::NAME_TOKENS array is only available in PHPCS 4.x, which is why we previously couldn't use it.

Modernize: use the new PHPCS 4.x Tokens class constants

... instead of the properties to reference token arrays.

This also allows for some simplifications when these token arrays are used to fill the value of a class property.

GH Actions: add automated check for usage of Tokens::$... properties

Now support for PHPCS 3.x has been dropped, only the Tokens::... constants should be used. The use of the properties from the Tokens class is deprecated.

This workflow job is intended to catch any accidental/force-of-habit usages of the Tokens properties.

These token arrays contain the same tokens, but the `Tokens::NAME_TOKENS` array is only available in PHPCS 4.x, which is why we previously couldn't use it.
... instead of the properties to reference token arrays.

This also allows for some simplifications when these token arrays are used to fill the value of a class property.
Now support for PHPCS 3.x has been dropped, only the `Tokens::...` constants should be used. The use of the properties from the `Tokens` class is deprecated.

This workflow job is intended to catch any accidental/force-of-habit usages of the `Tokens` properties.
@jrfnl jrfnl added this to the 10.0.0-alpha3 milestone Nov 30, 2025
@jrfnl jrfnl requested a review from wimg November 30, 2025 15:19
@jrfnl jrfnl added Type: chores/QA PR: quick merge PR only contains relatively simple changes PR: ready for review labels Nov 30, 2025
@wimg wimg merged commit 33970e2 into develop Nov 30, 2025
48 checks passed
@wimg wimg deleted the feature/modernize-use-phpcs-tokens-class-constants branch November 30, 2025 17:48
@github-actions github-actions bot removed PR: quick merge PR only contains relatively simple changes PR: ready for review labels Nov 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants