Skip to content

Add traits to BC policy #9718

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

Closed
wants to merge 1 commit into from
Closed

Conversation

nicolas-grekas
Copy link
Member

Changing traits is more constrained that changing classes.
Also embeds some things I found missing in other parts.

@xabbuh xabbuh added this to the 2.7 milestone May 18, 2018
@@ -196,21 +234,28 @@ Move to parent class Yes
Add protected property Yes
Remove protected property No [7]_
Reduce visibility No [7]_
Make public Yes
Copy link
Member

Choose a reason for hiding this comment

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

Such a change will break child classes that override the formerly protected property: https://3v4l.org/8vbr3

Move to parent class Yes
**Private Properties**
Add private property Yes
Make public or protected Yes
Copy link
Member

Choose a reason for hiding this comment

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

same as above

@@ -226,6 +271,8 @@ Add protected method Yes
Remove protected method No [7]_
Change name No [7]_
Reduce visibility No [7]_
Make final No [6]_
Make public Yes
Copy link
Member

Choose a reason for hiding this comment

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

see above

@@ -240,6 +287,7 @@ Change return type No [7]_ [8]_
Add private method Yes
Remove private method Yes
Change name Yes
Make public or protected Yes
Copy link
Member

Choose a reason for hiding this comment

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

same here

Copy link
Member Author

Choose a reason for hiding this comment

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

since adding a new method is allowed, making a private one public or protected should be allowed

@javiereguiluz
Copy link
Member

What can we do here to overcome the issues pointed by @xabbuh? Thanks!

@nicolas-grekas
Copy link
Member Author

Thanks @xabbuh, comments addressed.

**Private Properties**
Add private property Yes
Remove private property No
Make public or protected Yes
Copy link
Contributor

@HeahDude HeahDude Jul 1, 2018

Choose a reason for hiding this comment

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

This conflict with user added functions, right? sorry see below

Add private method Yes
Remove private method No
Change name No
Make public or protected Yes
Copy link
Contributor

Choose a reason for hiding this comment

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

This conflicts with user added functions, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

same answer as above: since adding a new method is allowed, making a private one public or protected should be allowed

Copy link
Contributor

Choose a reason for hiding this comment

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

But if we can can add methods in core whatever their visibility we should not be able to guarantee BC on adding some in user land, I surely miss something.

Copy link
Member Author

@nicolas-grekas nicolas-grekas Jul 1, 2018

Choose a reason for hiding this comment

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

We do not actually - or we would be just blocked for any future improvements.
Didn't ever you add any public or protected method to any class already?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok I agree, this is obvious, but I thought that at some point we documented that it was covered.

Maybe we could precise that when using a trait, composition might break when the trait add methods, because as obvious it is, it already caused issues when adding json or file shortcuts in the core. WDYT?

Copy link
Member Author

Choose a reason for hiding this comment

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

Is there anything specific to traits?

Copy link
Contributor

Choose a reason for hiding this comment

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

No of course, the same goes for extending any class from the core. Maybe we lack a sentence to explicit that it's not possible. Not all new comers have a strong PHP logic helping make that obvious.

Copy link
Member

Choose a reason for hiding this comment

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

@HeahDude do you think we need that extended explanation in this PR ... or can be done later in a separate PR? Thanks!

Copy link
Contributor

Choose a reason for hiding this comment

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

Im' not even sure we should at all actually. So definitely not blocking here.

@javiereguiluz
Copy link
Member

Another one merged! Thanks for all your contributions Nicolas!

javiereguiluz added a commit that referenced this pull request Jul 6, 2018
This PR was submitted for the 2.7 branch but it was merged into the 2.8 branch instead (closes #9718).

Discussion
----------

Add traits to BC policy

Changing traits is more constrained that changing classes.
Also embeds some things I found missing in other parts.

Commits
-------

3c814db Add traits to BC policy
@nicolas-grekas nicolas-grekas deleted the trait branch November 11, 2018 09:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants