Skip to content

Commit b3c474e

Browse files
committed
[DependencyInjection] Ensure Definition::getTags() contains a list of attributes for each tag
1 parent 6f18f60 commit b3c474e

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/Symfony/Component/DependencyInjection/Definition.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ public function isAutoconfigured(): bool
426426
*/
427427
public function setTags(array $tags): static
428428
{
429-
$this->tags = $tags;
429+
$this->tags = array_map('array_values', $tags);
430430

431431
return $this;
432432
}

src/Symfony/Component/DependencyInjection/Tests/DefinitionTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,19 @@ public function testSetGetConfigurator()
216216
$this->assertEquals('foo', $def->getConfigurator(), '->getConfigurator() returns the configurator');
217217
}
218218

219+
public function testSetTagsAreInList()
220+
{
221+
$def = new Definition('stdClass');
222+
$def->setTags([
223+
'tag1' => [5 => ['attr1' => 'value1'], 3 => []],
224+
'tag2' => [1 => ['attr2' => 'value2']],
225+
]);
226+
$this->assertSame([
227+
'tag1' => [['attr1' => 'value1'], []],
228+
'tag2' => [['attr2' => 'value2']],
229+
], $def->getTags(), '->setTags() reindex the tags arrays');
230+
}
231+
219232
public function testClearTags()
220233
{
221234
$def = new Definition('stdClass');

0 commit comments

Comments
 (0)