Skip to content

Commit 5a4a036

Browse files
committed
[DependencyInjection] Fix PriorityTaggedServiceTrait when tag attributes are not a list
1 parent de6acd7 commit 5a4a036

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/Symfony/Component/DependencyInjection/Compiler/PriorityTaggedServiceTrait.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ private function findAndSortTaggedServices(string|TaggedIteratorArgument $tagNam
8181
$phpAttributes = [];
8282
}
8383

84+
$attributes = array_values($attributes);
8485
for ($i = 0; $i < \count($attributes); ++$i) {
8586
if (!($attribute = $attributes[$i]) && $phpAttributes) {
8687
array_splice($attributes, $i--, 1, $phpAttributes);

src/Symfony/Component/DependencyInjection/Tests/Compiler/PriorityTaggedServiceTraitTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,21 @@ public function testMultiTagsWithMixedAttributesAndNonStaticDefault()
449449
$this->assertArrayHasKey('foo', $services);
450450
$this->assertArrayHasKey('default', $services);
451451
}
452+
453+
public function testTagAttributesAreNotAList()
454+
{
455+
$container = new ContainerBuilder();
456+
$container->register('service1')->setTags([
457+
'my_custom_tag' => [1 => ['attributes' => 'not_a_list']],
458+
]);
459+
460+
$priorityTaggedServiceTraitImplementation = new PriorityTaggedServiceTraitImplementation();
461+
462+
$expected = [
463+
new Reference('service1'),
464+
];
465+
$this->assertEquals($expected, $priorityTaggedServiceTraitImplementation->test('my_custom_tag', $container));
466+
}
452467
}
453468

454469
class PriorityTaggedServiceTraitImplementation

0 commit comments

Comments
 (0)