-
-
Notifications
You must be signed in to change notification settings - Fork 150
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
Added initial version of our BC promise #138
Conversation
Let's talk constructor parameters again. Personally I think the exact dependencies I'm injecting into a class (that do not leak out via class methods) should be considered implementation detail: If I want to change an algorithm for instance, I'd like to be able to exchange So, when does this hurt anyone? Basically whenever there are calls to my class's constructor with a now changed (and incompatible = no respective optional parameters) signature due to...
In a DI architecture where classes (services) are instantiated by the container 1) can be neglected. 2) is only the case when inheriting and there are only a few reasons someone should ever do this:
Points 1) - 3) are legitimate use cases. 4), however, clearly is a misuse to me (the class is maybe simply not So how to work around this? Let's make an example: If I want decorate Doctrine's default Long story short, because all of you know where this is going anyway: 😄 I would vote for excluding constructors from BC promise and make some well-thought exceptions to this rule, namely to cover the above building blocks. Note that this is only true for the 'new' code, not the legacy classes inside (And imho those exceptions should be visible in code - e.g. with appropriate annotations. ) |
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 like the initial version and especially the following sentence:
What we could discuss:
|
Co-Authored-By: Hannes <xchs@gmx-topmail.de>
Co-Authored-By: Hannes <xchs@gmx-topmail.de>
Co-Authored-By: Hannes <xchs@gmx-topmail.de>
I don't think I will ever agree here.
I don't think we need to mention this here. We won't be able to change that in any minor version so that must be covered by BC.
Added. |
Do you mind sharing why? |
Symfony protects all public methods that obviously includes constructors. Which makes sense because anybody can register their own services and use the classes the way they want. |
I’m not sure about the constructor arguments. For services it might make sense to exclude them from the BC promise. Should we set this to “up for discussion”? |
There is no "up for discussion" label in this repo, but we should definitely discuss this. I have set up a reminder for the next call. |
I generally like the statement(s). Some thoughts:
|
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 discussed in Mumble on November 28th, we want to add a paragraph about constructors marked as @internal
before we merge.
|
||
* Our BC promise does not cover classes and methods marked as `@internal`. In most cases this concerns constructors | ||
of services Contao provides. If you want to change the behaviour of a service, do not replace it with your own | ||
instance of the class but instead decorate the original service (see the tip about "Composition over Inheritance"). |
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.
Can we somehow link to https://symfony.com/doc/current/service_container/service_decoration.html here?
* Because Contao is a Symfony bundle like every other bundle, our BC promise does not cover anything that is about | ||
integrating Contao into the Symfony application. This includes: | ||
|
||
* Commands | ||
* Data collectors | ||
* Dependency injection compiler passes | ||
* Event listeners | ||
|
||
* Our BC promise also does not cover the `ContaoManager/Plugin` class, which is required to integrate a bundle into | ||
the [Contao Managed Edition][Contao_ME]. |
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'm not sure this whole chapter is necessary if we simply mark them as @internal
? All of the mentioned class types (except the Plugin) are also services, so they are already covered by you should decorate a service?
This is quite an important one so I've requested a few people for review.
Please feel free to notify other Contao devs if you think they would like to extend/modify this document.