Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NETBEANS-5599] PHP 8.1 Support: Enumerations #3940

Merged
merged 6 commits into from Apr 9, 2022

Conversation

junichi11
Copy link
Member

@junichi11 junichi11 commented Apr 7, 2022

Part 1:

  • Fix the parser, the lexer, and PHP81UnhandledError

nb-php81-enumerations-syntax-1

nb-php81-enumerations-syntax-2

PHP 8.1:

nb-php81-enumerations-syntax-4

PHP 8.0:

nb-php81-enumerations-syntax-php80

Part 2:

  • Fix the indexer
  • Add elements for an enum and an enum case

Part 3:

  • Fix the Navigator
enum UserStatus: string {

    case Pending = 'P';
    case Active = 'A';
    case Suspended = 'S';
    case CanceledByUser = 'C';

    public function label(): string {
        return match ($this) {
            static::Pending => 'Pending',
            static::Active => 'Active',
            static::Suspended => 'Suspended',
            static::CanceledByUser => 'Canceled by user',
        };
    }
}

nb-php81-enumerations-navigator-window

Part 4:

  • Fix the SemanticAnalysis and the PHPBracesMatcher
  • Add unit tests for the SemanticAnalysis, the FoldingScanner, and the PHPBrace Matcher

Part 5:

  • Fix the parser (e.g. Name::CASE1->method(), $i::CASE1->method(), Name:::CASE1::staicMethod(), Name::CASE1::CONSTANT)

nb-php81-enumerations-syntax-3

Part 6:

  • Fix the formatter

NOTE:

CC, GotoDeclaration, MarkOccurrences, Hints etc. are not fixed yet.

- https://issues.apache.org/jira/browse/NETBEANS-5599
- https://wiki.php.net/rfc/enumerations
- Fix the `SemanticAnalysis` and the `PHPBracesMatcher`
- Add unit tests for the SemanticAnalysis, the FoldingScanner, and the PHPBrace Matcher
- https://issues.apache.org/jira/browse/NETBEANS-5599
- https://wiki.php.net/rfc/enumerations
- Fix the parser (e.g. Name::CASE1->method(), $i::CASE1->method(), Name:::CASE1::staicMethod(), Name::CASE1::CONSTANT)
- Add unit tests
@junichi11 junichi11 added the PHP [ci] enable extra PHP tests (php/php.editor) label Apr 7, 2022
@junichi11 junichi11 added this to the NB14 milestone Apr 7, 2022
@junichi11 junichi11 requested a review from tmysik April 7, 2022 22:07
@junichi11
Copy link
Member Author

@tmysik Could you please have a look at this when you have time? Sorry for the huge changes...
I've added unit tests as much as possible. If there is no problem, let's merge it. Thanks!

Copy link
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.

Really nice (and huge, of course :) patch! Thanks for it!

@tmysik
Copy link
Member

tmysik commented Apr 9, 2022

@junichi11 My only comment - it would be nice to have a different icon for enum, but I can imagine that there is nobody who could draw it...

@tmysik tmysik merged commit 3863c3d into apache:master Apr 9, 2022
@junichi11
Copy link
Member Author

junichi11 commented Apr 9, 2022

@tmysik Thank you for your review!

My only comment - it would be nice to have a different icon for enum, but I can imagine that there is nobody who could draw it...

Yes, I think so.
I've copied the enum icon from CSL in this change, but the icon of enum cases is the same as const...

class ExampleClass {
    const CONSTANT = 1;
}

enum ExampleEnum: string {
    case ENUM_CASE = "";
    const CONSTANT = 1;
}

nb-php81-enumerations-icon

@junichi11 junichi11 deleted the php81-enumerations branch April 9, 2022 23:10
@tmysik
Copy link
Member

tmysik commented Apr 10, 2022

@junichi11 Exactly...

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.

None yet

2 participants