-
Notifications
You must be signed in to change notification settings - Fork 7.8k
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
Override static in return types with self in final classes #17724
base: master
Are you sure you want to change the base?
Override static in return types with self in final classes #17724
Conversation
…verriding static with self in non-final classes
…self in final classes
…n final classes
…n final classes
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.
@rekmixa please define what exactly you propose. (e.g. some code didn't work as expected and started to work after the patch).
I'm not sure if this patch is a fix or a new feature that requries RFC and discussion, how it's going to coexists with type variance, etc
@iluuu1994 @nielsdos @arnaud-lb please take care about this PR.
Zend/tests/type_declarations/override_another_type_in_final_class_with_union_type.phpt
Outdated
Show resolved
Hide resolved
…tests to folder Zend/tests/type_declarations/variance/override_static_with_self
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.
Conceptually, this seems correct to me. Please see my preliminary review comments.
.../override_static_with_self/override_static_type_with_self_in_non_final_class_with_trait.phpt
Outdated
Show resolved
Hide resolved
...verride_static_with_self/override_static_type_with_self_in_final_class_with_union_types.phpt
Outdated
Show resolved
Hide resolved
…ability to replace static with self
@nielsdos do i need to squash all commits in this PR? |
…_union_types.phpt
No, we will squash on merge. Squashing makes it harder for us to review what has changed since our reviews. |
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 this is right now, thanks. But I haven't worked with this code a lot, so this needs more eyes, especially since this is deep engine code.
cc @iluuu1994 @arnaud-lb
This may also need discussion on the ML so we know for sure there are no objections.
By the way, i already created discussion in the ML: https://externals.io/message/126367 |
Ah good to know, I missed this. |
…ng for static before checking for final
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.
LGTM now. Thank you @rekmixa! Given there were no objections on the list, it should be ok to merge this in a week or so.
Thanks for your comments. Can you tell me if this PR will be merged in 8.4 or 8.5? |
8.5. Stable branches only receive bug fixes. |
This PR adds the ability to replace static with self in the return types in the final classes, provided that the prototype of the final class has a static return method.
Example of how it should work:
More information in the issue: #17725