Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[DependencyInjection] Allow disabling instanceof config inheritance#61511
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
nicolas-grekas commentedAug 25, 2025
Thanks for the detailed description. Before, let me challenge the proposal:
|
HypeMC commentedAug 25, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@nicolas-grekas Hi. Yeah, I see your point about exceptions. I'm not sure how many cases like this there actually are.
I'm assuming you meantignore the one without a name. I agree, that would solve the serializer case. However, there might be other cases besides this and the Monolog one.
Here's a simple example: #[AsMonologProcessor('my_channel')]finalclass MyProcessorimplements ProcessorInterface{publicfunction__invoke(LogRecord$record) {}} You'd expect this processor to be registered only for The workaround is the same, disable autoconfiguration and add an explicit tag. services:App\MyProcessor:autoconfigure:falsetags: -monolog.processor:{ channel: 'my_channel' } |
nicolas-grekas commentedAug 25, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
I'd like to see how my proposal fits before looking for a more generic solution, to lower the overall complexity of things... |
HypeMC commentedAug 26, 2025
@nicolas-grekas Please see#61526. I've opened it as a bug fix cause it seems like one, if need I'll switch to 7.4. |
…specify a named one (HypeMC)This PR was merged into the 7.3 branch.Discussion----------[Serializer] Don't fallback to default serializer if tags specify a named one| Q | A| ------------- | ---| Branch? | 7.3| Bug fix? | yes| New feature? | no| Deprecations? | no| Issues | -| License | MITAn alternative to#61511.Commits-------e442a38 [Serializer] Don't fallback to default serializer if tags specify a named one
fabpot commentedAug 26, 2025
Closing in favor of#61526 |
Uh oh!
There was an error while loading.Please reload this page.
When configuring services like normalizers for a named serializer or Monolog processors for specific channels/handlers, autoconfiguration can get in the way.
For example, the
NormalizerInterfaceisregistered for autoconfiguration.If I try to register a custom normalizer for a specific named serializer, it also gets registered with the default serializer because of autoconfiguration:
Currently, the only way around this is to disable autoconfiguration entirely:
This PR introduces a new
inherit_configurationoption for service definitions and a#[WithoutInheritedConfiguration]attribute.Both allow skipping the inheritance of
instanceofconditionals from parent classes or interfaces:It can also be used to exclude specific services from inheriting
_instanceofconfigurations:Why a new attribute?
I initially tried adding a new argument to the existing
#[Autoconfigure]attribute.However, this attribute itself isresolved via instanceof conditionals.
I could try something like
$conditionals[$class], but since the attribute is repeatable, it’s unclear how to handle cases like: