✨ New PHPCSUtils\Utils\Constants class + associated token collection#562
Merged
Conversation
6943e72 to
3a9516d
Compare
114217e to
eaaa537
Compare
Member
Author
eaaa537 to
8829511
Compare
d06975f to
8b08c1e
Compare
Member
Author
|
Rebased and updated for DNF support + added some extra parse error protections (with tests). Marking as ready for review. I will squash the commits back into the original two commits before merging, but will leave this open for a couple of days before I do so, to allow review. |
8829511 to
2657594
Compare
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
... 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.
2657594 to
7e953e4
Compare
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
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.
✨ 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_NULLABLEtoken.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
constkeyword.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): arrayto 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.