Skip to content
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

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

mmalferov
Copy link
Member

Static properties defined in the trait are shared only between classes of the same hierarchy. Maybe we should mention this?

Static properties defined in the trait are shared only between classes of the same hierarchy. Maybe we should mention this?
@Girgias
Copy link
Member

Girgias commented Nov 29, 2024

@alexandre-daubois do you have any opinion about this?

Copy link
Contributor

@alexandre-daubois alexandre-daubois left a 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?

language/oop5/traits.xml Outdated Show resolved Hide resolved
@mmalferov mmalferov changed the title Update traits.xml Mention the hierarchy of classes Update traits.xml Mention the hierarchy of classes, amend final modifier example Nov 29, 2024
mmalferov added a commit to php/doc-ru that referenced this pull request Nov 30, 2024
Copy link
Member

@Girgias Girgias left a 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

language/oop5/traits.xml Outdated Show resolved Hide resolved
Co-authored-by: Gina Peter Banyard <[email protected]>
Copy link
Contributor

@alexandre-daubois alexandre-daubois left a 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 🙂

Comment on lines +430 to +432
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.
Copy link
Contributor

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?

Copy link
Member Author

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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to me, yes!

@Girgias Girgias linked an issue Dec 2, 2024 that may be closed by this pull request
language/oop5/traits.xml Outdated Show resolved Hide resolved
Co-authored-by: Gina Peter Banyard <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

The final modifier to methods coming from traits
3 participants