Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 49d23d4

Browse filesBrowse files
minor #40484 [DependencyInjection] accept null index in #[TaggedItem] (nicolas-grekas)
This PR was merged into the 5.3-dev branch. Discussion ---------- [DependencyInjection] accept null index in #[TaggedItem] | Q | A | ------------- | --- | Branch? | 5.x | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - As hinted by @stof in #40248 (comment) Commits ------- 6d16fac [DI] accept null index in #[TaggedItem]
2 parents db87d72 + 6d16fac commit 49d23d4
Copy full SHA for 49d23d4

File tree

2 files changed

+10
-1
lines changed
Filter options

2 files changed

+10
-1
lines changed

‎src/Symfony/Component/DependencyInjection/Attribute/TaggedItem.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Attribute/TaggedItem.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
class TaggedItem
2121
{
2222
public function __construct(
23-
public string $index,
23+
public ?string $index = null,
2424
public ?int $priority = null,
2525
) {
2626
}

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Tests/Compiler/PriorityTaggedServiceTraitTest.php
+9Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,13 +205,17 @@ public function testTaggedItemAttributes()
205205
HelloNamedService::class => (new ChildDefinition(''))->addTag('my_custom_tag'),
206206
\stdClass::class => (new ChildDefinition(''))->addTag('my_custom_tag2'),
207207
]);
208+
$container->register('service3', HelloNamedService2::class)
209+
->setAutoconfigured(true)
210+
->addTag('my_custom_tag');
208211

209212
(new ResolveInstanceofConditionalsPass())->process($container);
210213

211214
$priorityTaggedServiceTraitImplementation = new PriorityTaggedServiceTraitImplementation();
212215

213216
$tag = new TaggedIteratorArgument('my_custom_tag', 'foo', 'getFooBar');
214217
$expected = [
218+
'service3' => new TypedReference('service3', HelloNamedService2::class),
215219
'hello' => new TypedReference('service2', HelloNamedService::class),
216220
'service1' => new TypedReference('service1', FooTagClass::class),
217221
];
@@ -235,3 +239,8 @@ public function test($tagName, ContainerBuilder $container)
235239
class HelloNamedService extends \stdClass
236240
{
237241
}
242+
243+
#[TaggedItem(priority: 2)]
244+
class HelloNamedService2
245+
{
246+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.