✨ New PHPCSUtils\Utils\Constants class + associated token collection #562
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.
✨ New Collections::constantTypeTokens() method
PHP 8.3 adds support for typed OO constants.
This collection contains all the tokens which can be encountered in a constant type.
Note: along the same lines as for property/parameter/return type declarations, the collection does not include the
T_NULLABLE
token.Ref: https://wiki.php.net/rfc/typed_class_constants#supported_types
✨ New PHPCSUtils\Utils\Constants class
... to contain utilities methods for analysing constants declared using the
const
keyword.In the future, the scope of the methods might be expanded to also covered constants declared using
define()
, but that's for later.Initially, the class comes with the following method:
getProperties(File $phpcsFile, $stackPtr): array
to retrieve an array of information about a constant declaration, like the visibility, whether visibility was explicitly declared, whether the constant was declared as final, what the type is for the constant etc.Includes extensive unit tests.