-
Notifications
You must be signed in to change notification settings - Fork 741
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
Update traits.xml Mention the hierarchy of classes, amend final
modifier example
#4188
base: master
Are you sure you want to change the base?
Conversation
Static properties defined in the trait are shared only between classes of the same hierarchy. Maybe we should mention this?
@alexandre-daubois do you have any opinion about this? |
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.
Indeed! I did a little check: https://3v4l.org/ekFKM
It works only if the child class also uses the trait. If it doesn't (e.g. remove use T;
from B), the instance is shared. It should be worth mentioning this specificity?
Co-authored-by: Alexandre Daubois <[email protected]>
Co-authored-by: Alexandre Daubois <[email protected]>
final
modifier example
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.
Minor question, but looks fine to me otherwise
Co-authored-by: Gina Peter Banyard <[email protected]>
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.
Just one nitpick comment, otherwise it's great! Thank you for taking care of this followup 🙂
own copy of the static property if it explicitly uses the trait, | ||
i.e. the static property defined in a trait inserted into a child class override | ||
a static property that the child class inherited from the parent class. |
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.
As a non-native speaker, I struggle a bit to understand the sentence. Maybe it could be cut in two?
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.
Probably, a native English speaker (not me) will formulate it better, or changed it to single sentence at all, something like that:
As of PHP 8.3.0, the static property of the trait inserted in the child class overrides the static property that the child class inherited from the parent class defined in conjunction with the same trait
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.
Better to me, yes!
Co-authored-by: Gina Peter Banyard <[email protected]>
Static properties defined in the trait are shared only between classes of the same hierarchy. Maybe we should mention this?