Skip to content

Commit af0ed3d

Browse files
[DependencyInjection] Don't autoconfigure tag when it's already set with attributes
1 parent 24cf522 commit af0ed3d

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

Compiler/ResolveInstanceofConditionalsPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ private function processDefinition(ContainerBuilder $container, string $id, Defi
129129
foreach ($instanceofTags[$i] as $k => $v) {
130130
if (null === $definition->getDecoratedService() || \in_array($k, $tagsToKeep, true)) {
131131
foreach ($v as $v) {
132-
if ($definition->hasTag($k) && \in_array($v, $definition->getTag($k))) {
132+
if ($definition->hasTag($k) && (!$v || \in_array($v, $definition->getTag($k)))) {
133133
continue;
134134
}
135135
$definition->addTag($k, $v);

Tests/Compiler/IntegrationTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -860,6 +860,7 @@ static function (ChildDefinition $definition, CustomAutoconfiguration $attribute
860860
$definition->addTag('app.custom_tag', get_object_vars($attribute) + ['class' => $reflector->getName()]);
861861
}
862862
);
863+
$container->registerForAutoconfiguration(TaggedService1::class)->addTag('app.custom_tag');
863864

864865
$container->register('one', TaggedService1::class)
865866
->setPublic(true)

0 commit comments

Comments
 (0)