8000 [DependencyInjection] Do not try to load default method name on inter… · symfony/symfony@ac78bba · GitHub
[go: up one dir, main page]

Skip to content

Commit ac78bba

Browse files
committed
[DependencyInjection] Do not try to load default method name on interface
1 parent 4a176ce commit ac78bba

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

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

+4
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,10 @@ public static function getDefault(ContainerBuilder $container, string $serviceId
133133
return null;
134134
}
135135

136+
if ($r->isInterface()) {
137+
return null;
138+
}
139+
136140
if (null !== $indexAttribute) {
137141
$service = $class !== $serviceId ? sprintf('service "%s"', $serviceId) : 'on the corresponding service';
138142
$message = [sprintf('Either method "%s::%s()" should ', $class, $defaultMethod), sprintf(' or tag "%s" on %s is missing attribute "%s".', $tagName, $service, $indexAttribute)];

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

+8
Original file line numberDiff line numberDiff line change
@@ -151,13 +151,16 @@ public function testTheIndexedTagsByDefaultIndexMethod()
151151

152152
$container->register('service3', IntTagClass::class)->addTag('my_custom_tag');
153153

154+
$container->register('service4', HelloInterface::class)->addTag('my_custom_tag');
155+
154156
$priorityTaggedServiceTraitImplementation = new PriorityTaggedServiceTraitImplementation();
155157

156158
$tag = new TaggedIteratorArgument('my_custom_tag', 'foo', 'getFooBar');
157159
$expected = [
158160
'bar_tab_class_with_defaultmethod' => new TypedReference('service2', BarTagClass::class),
159161
'service1' => new TypedReference('service1', FooTagClass::class),
160162
'10' => new TypedReference('service3', IntTagClass::class),
163+
'service4' => new TypedReference('service4', HelloInterface::class),
161164
];
162165
$services = $priorityTaggedServiceTraitImplementation->test($tag, $container);
163166
$this->assertSame(array_keys($expected), array_keys($services));
@@ -244,3 +247,8 @@ class HelloNamedService extends \stdClass
244247
class HelloNamedService2
245248
{
246249
}
250+
251+
interface HelloInterface
252+
{
253+
public static function getFooBar(): string;
254+
}

0 commit comments

Comments
 (0)
0