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
Support php 8.1 enums #197
Conversation
tests/php81_enums.phpt
Outdated
| 0: AST_ENUM_CASE | ||
| name: "FOO" | ||
| expr: 42 | ||
| 0: null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's that zero index doing here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missed that - changed to attributes
I started writing this a month ago and didn't notice the 0. Enum cases can have attributes - I updated the test and documentation.
Because this is a brand new node kind, it shouldn't be a breaking change to always set attributes in $node->children instead of an instance property
ast.c
Outdated
| @@ -560,7 +572,9 @@ static inline zend_ast_attr ast_assign_op_to_binary_op(zend_ast_attr attr) { | |||
| static inline zend_ast **ast_get_children(zend_ast *ast, uint32_t *count) { | |||
| if (ast_kind_is_decl(ast->kind)) { | |||
| zend_ast_decl *decl = (zend_ast_decl *) ast; | |||
| #if PHP_VERSION_ID >= 80000 | |||
| #if PHP_VERSION_ID >= 80100 | |||
| *count = decl->kind == ZEND_AST_CLASS ? (decl->child[4] != NULL ? 5 : 4) : 5; | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we don't have anything like this right now (where an AST node has an optional child). Maybe it's better to unconditionally include child 4 in the new version?
(iff === if and only if)
|
Looks like there's test failures. |
|
Will look at it tonight - I may also need to set a null placeholder for type in php 8.0 and older |
Add support for https://wiki.php.net/rfc/enumerations
The text was updated successfully, but these errors were encountered: