-
Notifications
You must be signed in to change notification settings - Fork 7.9k
[RFC] Typed class constants #5815
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
Conversation
@@ -796,8 +796,8 @@ attributed_class_statement: | |||
variable_modifiers optional_type_without_static property_list ';' | |||
{ $$ = zend_ast_create(ZEND_AST_PROP_GROUP, $2, $3, NULL); | |||
$$->attr = $1; } | |||
| method_modifiers T_CONST class_const_list ';' | |||
{ $$ = zend_ast_create(ZEND_AST_CLASS_CONST_GROUP, $3, NULL); | |||
| method_modifiers T_CONST type_expr_without_static class_const_list ';' |
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.
This needs to be optional_type_without_static
instead of type_expr_without_static
but since there are 4 shift/reduce conflicts using the former one, I am temporarily using type_expr_without_static
.
...this is also the reason behind a bunch of failing tests.
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 only have a few cosmetic questions/suggestions which shouldn't affect the RFC too much in so early a phase. :)
@moliata Are you planning on pursuing this RFC? |
Hey, @iluuu1994 I do plan to continue pursuing this RFC, however, this implementation isn't really good and I will rewrite it completely from scratch when I get the time to do so. For now, I think it's fine that we close this PR but leave the RFC page still available on the wiki. Best regards, |
Thanks @moliata. |
Hi @moliata, Recently, I wanted to fix your problem with the parser. Even though I didn't reach far, @bwoebi helped me. Afterwards, I fixed a few smaller issues with your implementation... so your RFC now has an almost complete implementation: https://github.com/php/php-src/compare/master...kocsismate:php-src:const-type?expand=1 I strongly recommend though to split the abstract constant part of your proposal because of its possible controversiality and additional - unnecessary - complexity. I didn't even try to implement this. |
@kocsismate For reference, I was confused about you mentioning the abstract part of my proposal. Apparently, Mark Niebergall modified my original proposal on the wiki, included |
@moliata Did you have the chance to make some progress with the RFC? |
@kocsismate Despite having done some progress during the holidays, I have come to understanding that due to time constraints and many exam sessions that I am currently having, I won't be able to work on this properly any time soon. I would be glad if someone took upon this RFC and refined it. |
@moliata OK, I'd be happy to take the RFC over - of course by properly crediting your previous work. :) The only additional thing I want is to make it possible to add types to global constants ( |
@kocsismate Looks great to me! Thank you so much for your work and I wish you the best of luck during the voting phase. |
RFC: https://wiki.php.net/rfc/typed_class_constants