PHP 8.3 Support: Typed class constants #6701#6793
Merged
junichi11 merged 6 commits intoapache:php-nb21-featuresfrom Dec 8, 2023
Merged
PHP 8.3 Support: Typed class constants #6701#6793junichi11 merged 6 commits intoapache:php-nb21-featuresfrom
junichi11 merged 6 commits intoapache:php-nb21-featuresfrom
Conversation
- apache#6701 - https://wiki.php.net/rfc/typed_class_constants - Fix the grammar file (parser) - Fix the `PHP83UnhandledError` - Add/Fix unit tests for the parser - Increment the spec version Example: ```php class Example { public const string CONSTANT1 = 'constant'; public const ?int CONSTANT2 = 1; public const int|string CONSTANT3 = 1; } ```
junichi11
commented
Dec 5, 2023
| CLASS MyClass [PUBLIC] Bar | ||
| CLASS TypedPropertiesClass [PUBLIC] Foo | ||
| ------------------------------------ | ||
| KEYWORD abstract null |
Member
Author
There was a problem hiding this comment.
These are unnecessary in this caret position.
junichi11
commented
Dec 5, 2023
| Code completion result for source line: | ||
| public const |CONSTANT = "constant"; | ||
| (QueryType=COMPLETION, prefixSearch=true, caseSensitive=true) | ||
| PACKAGE Bar [PUBLIC] null |
Member
Author
There was a problem hiding this comment.
A constant declaration may have types.
junichi11
commented
Dec 5, 2023
Member
Author
|
@tmysik Could you please have a look at each commit when you have time? |
tmysik
reviewed
Dec 7, 2023
tmysik
approved these changes
Dec 7, 2023
Member
tmysik
left a comment
There was a problem hiding this comment.
Looks good to me, thanks again for all the tests, as always 👍
Member
Author
|
Thank you for your time and your review! |
- apache#6701 - https://wiki.php.net/rfc/typed_class_constants - Index class constant types - Fix the navigator - Add/Fix unit tests for the indexer and the navigator - Increment the spec version
- apache#6701 - https://wiki.php.net/rfc/typed_class_constants - Fix the context sensitive lexer (Reserved keywords can be used as constant names) - Get the constant names as the `PHP_STRING` token - Add unit tests Example: ```php class Example { public const string|array array = [1, 2, 3], string = "example"; } ```
- apache#6701 - https://wiki.php.net/rfc/typed_class_constants - Fix the mark occurences and the go to declaration features - Add unit tests
- apache#6701 - https://wiki.php.net/rfc/typed_class_constants - Fix the Code Completion feature - Add templates for constant statements - Add unit tests
- apache#6701 - https://wiki.php.net/rfc/typed_class_constants - Fix the formatter (don't add spaces within parens of DNF types) - Fix the `UnusableTypeHintError` - Add unit tests
40c71cf to
450cb20
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.
PHP 8.3 Support: Typed class constants (Part 1)
PHP83UnhandledErrorExample:
PHP 8.3
PHP 8.2
PHP 8.3 Support: Typed class constants (Part 2)
PHP 8.3 Support: Typed class constants (Part 3)
PHP_STRINGtokenExample:
PHP 8.3 Support: Typed class constants (Part 4)
PHP 8.3 Support: Typed class constants (Part 5)
PHP 8.3 Support: Typed class constants (Part 6)
UnusableTypeHintError