Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[DependencyInjection] accept null index in #[TaggedItem] #40484

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
class TaggedItem
{
public function __construct(
public string $index,
public ?string $index = null,
public ?int $priority = null,
) {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,13 +205,17 @@ public function testTaggedItemAttributes()
HelloNamedService::class => (new ChildDefinition(''))->addTag('my_custom_tag'),
\stdClass::class => (new ChildDefinition(''))->addTag('my_custom_tag2'),
]);
$container->register('service3', HelloNamedService2::class)
->setAutoconfigured(true)
->addTag('my_custom_tag');

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

$priorityTaggedServiceTraitImplementation = new PriorityTaggedServiceTraitImplementation();

$tag = new TaggedIteratorArgument('my_custom_tag', 'foo', 'getFooBar');
$expected = [
'service3' => new TypedReference('service3', HelloNamedService2::class),
'hello' => new TypedReference('service2', HelloNamedService::class),
'service1' => new TypedReference('service1', FooTagClass::class),
];
Expand All @@ -235,3 +239,8 @@ public function test($tagName, ContainerBuilder $container)
class HelloNamedService extends \stdClass
{
}

#[TaggedItem(priority: 2)]
class HelloNamedService2
{
}