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 ac78bba

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

File tree

Expand file treeCollapse file tree

2 files changed

+12
-0
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+12
-0
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Compiler/PriorityTaggedServiceTrait.php
+4Lines changed: 4 additions & 0 deletions
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

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Tests/Compiler/PriorityTaggedServiceTraitTest.php
+8Lines changed: 8 additions & 0 deletions
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)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.