-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Remove abstract class and use Interface+Trait #12595
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
Remove abstract class and use Interface+Trait #12595
Conversation
@@ -26,8 +27,10 @@ | |||
* | |||
* @api | |||
*/ | |||
abstract class Bundle extends ContainerAware implements BundleInterface | |||
abstract class Bundle implements BundleInterface |
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.
missing ContainerAwareInterface
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.
it's not needed because interface BundleInterface extends ContainerAwareInterface
What is the benefit to use What is the benefit for us or for the symfony's users to deprecate the class ContainerAware and force them to use the trait? |
@jeremy-derusse As I said in the description, with interface+trait, you keep your inheritance free, you will able now to inherit from a class with a real benefit. There is no multiple inheritance in PHP, so we should use it only if really needed. |
From the doc :
Inheritance provides no more and I think It's actually done in this way because traits doesn't exists in 5.3 otherwise they would have been used. 👍 for me :) |
Actually, as a developer, I'm free to use the |
Hm, I'm actually wondering what is the benefit of using the |
@xabbuh in case of refactoring, if we will need to add an inheritance, we won't be blocked. @jeremy-derusse It will allow you, later, the possibility to add inheritance, you won't be blocked. I don't understand the benefit to use abstract class instead of trait/interface for you? |
this is a good idea. containeraware has nothing todo with inheritance. i am 👍 |
@blanchonvincent Can you finish this one? 👍 |
@fabpot yep, I'll do that this week end |
I would suggest to also make |
@Tobion I like your idea about to also make |
If we removed the |
See #12595 (comment) where we agreed to deprecate the class. Edit: We want to deprecate it in 3.0 not in 2.8 (which makes more sense). So it means, we should not remove the class here, but only add the deprecation message. |
Status: Needs Work |
@Tobion what kind of message would you like? "Deprecated since version 3.0, to be removed in ??" |
@Tobion why not deprecate it in 2.8? @blanchonvincent depends on the decision of deprecation in 2.8 or 3.0, but:
|
@wouterj as I wrote above, there would not be a clean upgrade path in 2.8 as the trait cannot be used for PHP < 5.5. And the amount of people affected is maybe not justified in 2.8 |
@Tobion as Symfony 3 requires PHP 5.5.9, people already need to run Symfony 2.8 on PHP 5.5 for a clean upgrade path (or is this not considered as part of the upgrade path?). |
@wouterj People using 2.8 don't need php 5.5. And if they want to get rid of all deprecation messages to be compatible with 3.0 in the future they can also do so on PHP 5.3. But with the ContainerAware class they would have a problem as the replacement wouldn't be available to them. So they would basically need to reimplement this class in their own code to get rid of the deprecation. |
BTW, shouldn't we trigger a deprecated error when the version of php is under 5.5 ? |
@blanchonvincent do you have time to finish this PR? It needs a rebase and please deprecate |
Replaced by #16411 |
@Tobion sorry mate, I am on vacation |
This PR was merged into the 3.0-dev branch. Discussion ---------- [3.0] use ContainerAwareTrait | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | yes | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - Finished version of #12595 This adds the first deprecation in symfony 3. We cannot deprecate ContainerAware in 2.8 as the alternative, the trait, cannot be used with php 5.3. So there would not be an upgrade path for people using an older php version Commits ------- f75a940 [VarDumper] fix filename 2309901 [VarDumper] replace VarDumperTestCase by trait 24ff770 [TwigBundle] use ContainerAwareTrait in commands e337ce6 Remove deprecated ContainerAware class and make use of the trait in another class 52c50e3 Remove abstract class and use Interface+Trait
Why do we need to close the inheritance if we can use our existing interface/trait? This PR will provide trait+interface instead of abstract class, that will allow to improve inheritance and allow to the class to extends another with real advantage if it needed.