You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying out the new PHP 8.1 enums and stumbled upon an inconsistency regarding enum member names. As it seems, neither PhpUnit or 3v4l allow PHP keywords as enum member names, whereas they are allowed as class constants. Since enums and cases are mostly handled like classes and constants, I think there is an inconsistency.
I already reported it at PhpStorm, because I thought they where to blame (their editor didn't warn me about using a keyword as a member name). There I learned, that this seems to be the correct way to handle this. YouTrack issue: https://youtrack.jetbrains.com/issue/WI-63788
Current behavior
The current behaviour spits out this error when using Continue as an enum member name during testing:
Cannot parse ResponseCode.php: Syntax error, unexpected T_CONTINUE, expecting T_STRING on line 7
Summary
I am trying out the new PHP 8.1 enums and stumbled upon an inconsistency regarding enum member names. As it seems, neither PhpUnit or 3v4l allow PHP keywords as enum member names, whereas they are allowed as class constants. Since enums and cases are mostly handled like classes and constants, I think there is an inconsistency.
I already reported it at PhpStorm, because I thought they where to blame (their editor didn't warn me about using a keyword as a member name). There I learned, that this seems to be the correct way to handle this. YouTrack issue: https://youtrack.jetbrains.com/issue/WI-63788
Current behavior
The current behaviour spits out this error when using
Continue
as an enum member name during testing:How to reproduce
Write a test covering this piece of code and test it: https://3v4l.org/K8ksR#v8.1rc3
Expected behavior
No parsing errors, since the PHP interpreter itself also doesn't warn about this.
The text was updated successfully, but these errors were encountered: