-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Description
Symfony version(s) affected
7.0
Description
Previously we had following configuration:
services:
_instanceOf:
App\Validation\Entity\ActiveRecordValidatorInterface:
shared: false
lazy: true
tags: ['app.tag.validation']
This allowed us to get all validators and mark them non-shared.
I am migrating this configuration into PHP Attributes using this documentation. It states:
If you need more capabilities to autoconfigure instances of your base class like their laziness, their bindings or their calls for example, you may rely on the Autoconfigure attribute.
But it seems that order of PHP Attributes matter and AutoconfigureTag
overrides any previous Autoconfigure
attribute, even through AutoconfigureTag
does not accept anything more than tag configuration
How to reproduce
use Symfony\Component\DependencyInjection\Attribute\Autoconfigure;
use Symfony\Component\DependencyInjection\Attribute\AutoconfigureTag;
#[
Autoconfigure(lazy: true, shared: false),
AutoconfigureTag(self::class),
]
interface ActiveRecordValidatorInterface
All services implementing this interface are shared and eager services (ReadOnlyValidator as example):

But if I merge these attributes or switch them in place, than it becomes correct:
#[
AutoconfigureTag(self::class),
Autoconfigure(lazy: true, shared: false),
]
or
#[Autoconfigure(tags: [self::class], lazy: true, shared: false)]

Possible Solution
No response
Additional Context
No response