Skip to content

PHP 8.3 Support: Typed class constants #6701#6793

Merged
junichi11 merged 6 commits intoapache:php-nb21-featuresfrom
junichi11:php83-typed-class-constants
Dec 8, 2023
Merged

PHP 8.3 Support: Typed class constants #6701#6793
junichi11 merged 6 commits intoapache:php-nb21-featuresfrom
junichi11:php83-typed-class-constants

Conversation

@junichi11
Copy link
Copy Markdown
Member

PHP 8.3 Support: Typed class constants (Part 1)

  • Fix the grammar file (parser)
  • Fix the PHP83UnhandledError
  • Add/Fix unit tests for the parser
  • Increment the spec version

Example:

class Example {
    public const string CONSTANT1 = 'constant';
    public const ?int CONSTANT2 = 1;
    public const int|string CONSTANT3 = 1;
}

PHP 8.3

nb-php83-typed-class-constants-parser

PHP 8.2

nb-php83-typed-class-constants-parser-php82

PHP 8.3 Support: Typed class constants (Part 2)

  • Index class constant types
  • Fix the navigator
  • Add/Fix unit tests for the indexer and the navigator
  • Increment the spec version

nb-php83-typed-class-constants-navigator

PHP 8.3 Support: Typed class constants (Part 3)

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

class Example {
    public const string|array array = [1, 2, 3], string = "example";
}

nb-php83-typed-class-constants-context-sensitive-lexer

PHP 8.3 Support: Typed class constants (Part 4)

  • Fix the mark occurences and the go to declaration features
  • Add unit tests

PHP 8.3 Support: Typed class constants (Part 5)

  • Fix the Code Completion feature
  • Add templates for constant statements
  • Add unit tests

PHP 8.3 Support: Typed class constants (Part 6)

  • Fix the formatter (don't add spaces within parens of DNF types)
  • Fix the UnusableTypeHintError
  • Add unit tests

nb-php83-typed-class-constants-unusable-type-hint-error

- 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 junichi11 added the PHP [ci] enable extra PHP tests (php/php.editor) label Dec 5, 2023
@junichi11 junichi11 added this to the NB21 milestone Dec 5, 2023
CLASS MyClass [PUBLIC] Bar
CLASS TypedPropertiesClass [PUBLIC] Foo
------------------------------------
KEYWORD abstract null
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are unnecessary in this caret position.

Code completion result for source line:
public const |CONSTANT = "constant";
(QueryType=COMPLETION, prefixSearch=true, caseSensitive=true)
PACKAGE Bar [PUBLIC] null
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A constant declaration may have types.

@junichi11 junichi11 mentioned this pull request Dec 5, 2023
3 tasks
@junichi11 junichi11 requested a review from tmysik December 5, 2023 03:23
@junichi11
Copy link
Copy Markdown
Member Author

@tmysik Could you please have a look at each commit when you have time?

Copy link
Copy Markdown
Member

@tmysik tmysik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, thanks again for all the tests, as always 👍

@junichi11
Copy link
Copy Markdown
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
@junichi11 junichi11 force-pushed the php83-typed-class-constants branch from 40c71cf to 450cb20 Compare December 8, 2023 03:28
@junichi11 junichi11 merged commit 480ad74 into apache:php-nb21-features Dec 8, 2023
@junichi11 junichi11 deleted the php83-typed-class-constants branch December 8, 2023 09:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PHP [ci] enable extra PHP tests (php/php.editor)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants