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 4f0daa7

Browse filesBrowse files
committed
feature #22420 [DI] Make tagged abstract services throw earlier (nicolas-grekas)
This PR was squashed before being merged into the 3.3-dev branch (closes #22420). Discussion ---------- [DI] Make tagged abstract services throw earlier | Q | A | ------------- | --- | Branch? | 3.3 | Bug fix? | yes | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - As spotted by @stof in #22388 (comment), skipping abstract tagged services removes an opportunity to report config mistakes to users. Instead of skipping them, let's throw as done before (thus reverting #22039, ping @chalasr). I made `$container->findTaggedServiceIds()` accept a 2nd arg to make this more systematic. To keep the possibility to have abstract tagged services *for the purpose of tag inheritance*, `ResolveTagsInheritancePass` now resets their tags. Commits ------- 388e4b3 [DI] Make tagged abstract services throw earlier cd06c12 Revert "minor #22039 Skip abstract definitions in compiler passes (chalasr)"
2 parents 64b715b + 388e4b3 commit 4f0daa7
Copy full SHA for 4f0daa7

File tree

30 files changed

+117
-90
lines changed
Filter options

30 files changed

+117
-90
lines changed

‎src/Symfony/Bridge/Doctrine/DependencyInjection/CompilerPass/RegisterEventListenersAndSubscribersPass.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Doctrine/DependencyInjection/CompilerPass/RegisterEventListenersAndSubscribersPass.php
+2-10Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ public function process(ContainerBuilder $container)
5555
return;
5656
}
5757

58-
$taggedSubscribers = $container->findTaggedServiceIds($this->tagPrefix.'.event_subscriber');
59-
$taggedListeners = $container->findTaggedServiceIds($this->tagPrefix.'.event_listener');
58+
$taggedSubscribers = $container->findTaggedServiceIds($this->tagPrefix.'.event_subscriber', true);
59+
$taggedListeners = $container->findTaggedServiceIds($this->tagPrefix.'.event_listener', true);
6060

6161
if (empty($taggedSubscribers) && empty($taggedListeners)) {
6262
return;
@@ -78,10 +78,6 @@ public function process(ContainerBuilder $container)
7878

7979
uasort($subscribers, $sortFunc);
8080
foreach ($subscribers as $id => $instance) {
81-
if ($container->getDefinition($id)->isAbstract()) {
82-
continue;
83-
}
84-
8581
$em->addMethodCall('addEventSubscriber', array(new Reference($id)));
8682
}
8783
}
@@ -94,10 +90,6 @@ public function process(ContainerBuilder $container)
9490

9591
uasort($listeners, $sortFunc);
9692
foreach ($listeners as $id => $instance) {
97-
if ($container->getDefinition($id)->isAbstract()) {
98-
continue;
99-
}
100-
10193
$em->addMethodCall('addEventListener', array(
10294
array_unique($instance['event']),
10395
isset($instance['lazy']) && $instance['lazy'] ? $id : new Reference($id),

‎src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/CompilerPass/RegisterEventListenersAndSubscribersPassTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Doctrine/Tests/DependencyInjection/CompilerPass/RegisterEventListenersAndSubscribersPassTest.php
+7-3Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818

1919
class RegisterEventListenersAndSubscribersPassTest extends TestCase
2020
{
21+
/**
22+
* @expectedException \InvalidArgumentException
23+
*/
2124
public function testExceptionOnAbstractTaggedSubscriber()
2225
{
2326
$container = $this->createBuilder();
@@ -29,10 +32,12 @@ public function testExceptionOnAbstractTaggedSubscriber()
2932
$container->setDefinition('a', $abstractDefinition);
3033

3134
$this->process($container);
32-
$this->assertSame(array(), $container->getDefinition('doctrine.dbal.default_connection.event_manager')->getMethodCalls());
3335
}
3436

35-
public function testAbstractTaggedListenerIsSkipped()
37+
/**
38+
* @expectedException \InvalidArgumentException
39+
*/
40+
public function testExceptionOnAbstractTaggedListener()
3641
{
3742
$container = $this->createBuilder();
3843

@@ -43,7 +48,6 @@ public function testAbstractTaggedListenerIsSkipped()
4348
$container->setDefinition('a', $abstractDefinition);
4449

4550
$this->process($container);
46-
$this->assertSame(array(), $container->getDefinition('doctrine.dbal.default_connection.event_manager')->getMethodCalls());
4751
}
4852

4953
public function testProcessEventListenersWithPriorities()

‎src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/AddCacheClearerPass.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/AddCacheClearerPass.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function process(ContainerBuilder $container)
3232
}
3333

3434
$clearers = array();
35-
foreach ($container->findTaggedServiceIds('kernel.cache_clearer') as $id => $attributes) {
35+
foreach ($container->findTaggedServiceIds('kernel.cache_clearer', true) as $id => $attributes) {
3636
$clearers[] = new Reference($id);
3737
}
3838

‎src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/AddExpressionLanguageProvidersPass.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/AddExpressionLanguageProvidersPass.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@ public function process(ContainerBuilder $container)
3030
// routing
3131
if ($container->has('router')) {
3232
$definition = $container->findDefinition('router');
33-
foreach ($container->findTaggedServiceIds('routing.expression_language_provider') as $id => $attributes) {
33+
foreach ($container->findTaggedServiceIds('routing.expression_language_provider', true) as $id => $attributes) {
3434
$definition->addMethodCall('addExpressionLanguageProvider', array(new Reference($id)));
3535
}
3636
}
3737

3838
// security
3939
if ($container->has('security.access.expression_voter')) {
4040
$definition = $container->findDefinition('security.access.expression_voter');
41-
foreach ($container->findTaggedServiceIds('security.expression_language_provider') as $id => $attributes) {
41+
foreach ($container->findTaggedServiceIds('security.expression_language_provider', true) as $id => $attributes) {
4242
$definition->addMethodCall('addExpressionLanguageProvider', array(new Reference($id)));
4343
}
4444
}

‎src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/ProfilerPass.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/ProfilerPass.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function process(ContainerBuilder $container)
3333

3434
$collectors = new \SplPriorityQueue();
3535
$order = PHP_INT_MAX;
36-
foreach ($container->findTaggedServiceIds('data_collector') as $id => $attributes) {
36+
foreach ($container->findTaggedServiceIds('data_collector', true) as $id => $attributes) {
3737
$priority = isset($attributes[0]['priority']) ? $attributes[0]['priority'] : 0;
3838
$template = null;
3939

‎src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/TemplatingPass.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/TemplatingPass.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function process(ContainerBuilder $container)
3232

3333
if ($container->hasDefinition('templating.engine.php')) {
3434
$helpers = array();
35-
foreach ($container->findTaggedServiceIds('templating.helper') as $id => $attributes) {
35+
foreach ($container->findTaggedServiceIds('templating.helper', true) as $id => $attributes) {
3636
if (isset($attributes[0]['alias'])) {
3737
$helpers[$attributes[0]['alias']] = $id;
3838
}

‎src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/TranslationDumperPass.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/TranslationDumperPass.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function process(ContainerBuilder $container)
2828

2929
$definition = $container->getDefinition('translation.writer');
3030

31-
foreach ($container->findTaggedServiceIds('translation.dumper') as $id => $attributes) {
31+
foreach ($container->findTaggedServiceIds('translation.dumper', true) as $id => $attributes) {
3232
$definition->addMethodCall('addDumper', array($attributes[0]['alias'], new Reference($id)));
3333
}
3434
}

‎src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/TranslationExtractorPass.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/TranslationExtractorPass.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function process(ContainerBuilder $container)
2929

3030
$definition = $container->getDefinition('translation.extractor');
3131

32-
foreach ($container->findTaggedServiceIds('translation.extractor') as $id => $attributes) {
32+
foreach ($container->findTaggedServiceIds('translation.extractor', true) as $id => $attributes) {
3333
if (!isset($attributes[0]['alias'])) {
3434
throw new RuntimeException(sprintf('The alias for the tag "translation.extractor" of service "%s" must be set.', $id));
3535
}

‎src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/TranslatorPass.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/TranslatorPass.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function process(ContainerBuilder $container)
2626

2727
$loaders = array();
2828
$loaderRefs = array();
29-
foreach ($container->findTaggedServiceIds('translation.loader') as $id => $attributes) {
29+
foreach ($container->findTaggedServiceIds('translation.loader', true) as $id => $attributes) {
3030
$loaderRefs[$id] = new Reference($id);
3131
$loaders[$id][] = $attributes[0]['alias'];
3232
if (isset($attributes[0]['legacy-alias'])) {

‎src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/ValidateWorkflowsPass.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/ValidateWorkflowsPass.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class ValidateWorkflowsPass implements CompilerPassInterface
2525
{
2626
public function process(ContainerBuilder $container)
2727
{
28-
$taggedServices = $container->findTaggedServiceIds('workflow.definition');
28+
$taggedServices = $container->findTaggedServiceIds('workflow.definition', true);
2929
foreach ($taggedServices as $id => $tags) {
3030
$definition = $container->get($id);
3131
foreach ($tags as $tag) {

‎src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/AddConsoleCommandPassTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/AddConsoleCommandPassTest.php
+4-2Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ public function visibilityProvider()
6262
);
6363
}
6464

65+
/**
66+
* @expectedException \InvalidArgumentException
67+
* @expectedExceptionMessage The service "my-command" tagged "console.command" must not be abstract.
68+
*/
6569
public function testProcessThrowAnExceptionIfTheServiceIsAbstract()
6670
{
6771
$container = new ContainerBuilder();
@@ -73,8 +77,6 @@ public function testProcessThrowAnExceptionIfTheServiceIsAbstract()
7377
$container->setDefinition('my-command', $definition);
7478

7579
$container->compile();
76-
77-
$this->assertSame(array(), $container->getParameter('console.command.ids'));
7880
}
7981

8082
/**

‎src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/AddConstraintValidatorsPassTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Compiler/AddConstraintValidatorsPassTest.php
+18-3Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,6 @@ public function testThatConstraintValidatorServicesAreProcessed()
3434
->addTag('validator.constraint_validator', array('alias' => 'my_constraint_validator_alias1'));
3535
$container->register('my_constraint_validator_service2', Validator2::class)
3636
->addTag('validator.constraint_validator');
37-
$container->register('my_abstract_constraint_validator')
38-
->setAbstract(true)
39-
->addTag('validator.constraint_validator');
4037

4138
$addConstraintValidatorsPass = new AddConstraintValidatorsPass();
4239
$addConstraintValidatorsPass->process($container);
@@ -49,6 +46,24 @@ public function testThatConstraintValidatorServicesAreProcessed()
4946
$this->assertEquals($expected, $container->getDefinition((string) $validatorFactory->getArgument(0)));
5047
}
5148

49+
/**
50+
* @expectedException \InvalidArgumentException
51+
* @expectedExceptionMessage The service "my_abstract_constraint_validator" tagged "validator.constraint_validator" must not be abstract.
52+
*/
53+
public function testAbstractConstraintValidator()
54+
{
55+
$container = new ContainerBuilder();
56+
$validatorFactory = $container->register('validator.validator_factory')
57+
->addArgument(array());
58+
59+
$container->register('my_abstract_constraint_validator')
60+
->setAbstract(true)
61+
->addTag('validator.constraint_validator');
62+
63+
$addConstraintValidatorsPass = new AddConstraintValidatorsPass();
64+
$addConstraintValidatorsPass->process($container);
65+
}
66+
5267
public function testThatCompilerPassIsIgnoredIfThereIsNoConstraintValidatorFactoryDefinition()
5368
{
5469
$definition = $this->getMockBuilder('Symfony\Component\DependencyInjection\Definition')->getMock();

‎src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/RuntimeLoaderPass.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/RuntimeLoaderPass.php
+1-6Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,8 @@ public function process(ContainerBuilder $container)
2929

3030
$definition = $container->getDefinition('twig.runtime_loader');
3131
$mapping = array();
32-
foreach ($container->findTaggedServiceIds('twig.runtime') as $id => $attributes) {
32+
foreach ($container->findTaggedServiceIds('twig.runtime', true) as $id => $attributes) {
3333
$def = $container->getDefinition($id);
34-
35-
if ($def->isAbstract()) {
36-
continue;
37-
}
38-
3934
$mapping[$def->getClass()] = new Reference($id);
4035
}
4136

‎src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/TwigEnvironmentPass.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/TwigEnvironmentPass.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function process(ContainerBuilder $container)
3636
// be registered.
3737
$calls = $definition->getMethodCalls();
3838
$definition->setMethodCalls(array());
39-
foreach ($container->findTaggedServiceIds('twig.extension') as $id => $attributes) {
39+
foreach ($container->findTaggedServiceIds('twig.extension', true) as $id => $attributes) {
4040
$definition->addMethodCall('addExtension', array(new Reference($id)));
4141
}
4242
$definition->setMethodCalls(array_merge($definition->getMethodCalls(), $calls));

‎src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/TwigLoaderPass.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/TwigBundle/DependencyInjection/Compiler/TwigLoaderPass.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function process(ContainerBuilder $container)
3232
$prioritizedLoaders = array();
3333
$found = 0;
3434

35-
foreach ($container->findTaggedServiceIds('twig.loader') as $id => $attributes) {
35+
foreach ($container->findTaggedServiceIds('twig.loader', true) as $id => $attributes) {
3636
$priority = isset($attributes[0]['priority']) ? $attributes[0]['priority'] : 0;
3737
$prioritizedLoaders[$priority][] = $id;
3838
++$found;

‎src/Symfony/Component/Console/DependencyInjection/AddConsoleCommandPass.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/DependencyInjection/AddConsoleCommandPass.php
+1-6Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,11 @@ class AddConsoleCommandPass implements CompilerPassInterface
2525
{
2626
public function process(ContainerBuilder $container)
2727
{
28-
$commandServices = $container->findTaggedServiceIds('console.command');
28+
$commandServices = $container->findTaggedServiceIds('console.command', true);
2929
$serviceIds = array();
3030

3131
foreach ($commandServices as $id => $tags) {
3232
$definition = $container->getDefinition($id);
33-
34-
if ($definition->isAbstract()) {
35-
continue;
36-
}
37-
3833
$class = $container->getParameterBag()->resolveValue($definition->getClass());
3934

4035
if (!$r = $container->getReflectionClass($class)) {

‎src/Symfony/Component/Console/Tests/DependencyInjection/AddConsoleCommandPassTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Console/Tests/DependencyInjection/AddConsoleCommandPassTest.php
+5-3Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,11 @@ public function visibilityProvider()
5050
);
5151
}
5252

53-
public function testProcessSkipAbstractDefinitions()
53+
/**
54+
* @expectedException \InvalidArgumentException
55+
* @expectedExceptionMessage The service "my-command" tagged "console.command" must not be abstract.
56+
*/
57+
public function testProcessThrowAnExceptionIfTheServiceIsAbstract()
5458
{
5559
$container = new ContainerBuilder();
5660
$container->setResourceTracking(false);
@@ -62,8 +66,6 @@ public function testProcessSkipAbstractDefinitions()
6266
$container->setDefinition('my-command', $definition);
6367

6468
$container->compile();
65-
66-
$this->assertSame(array(), $container->getParameter('console.command.ids'));
6769
}
6870

6971
/**

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Compiler/PriorityTaggedServiceTrait.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ private function findAndSortTaggedServices($tagName, ContainerBuilder $container
4040
{
4141
$services = array();
4242

43-
foreach ($container->findTaggedServiceIds($tagName) as $serviceId => $attributes) {
43+
foreach ($container->findTaggedServiceIds($tagName, true) as $serviceId => $attributes) {
4444
$priority = isset($attributes[0]['priority']) ? $attributes[0]['priority'] : 0;
4545
$services[$priority][] = new Reference($serviceId);
4646
}

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Compiler/ResolveTagsInheritancePass.php
+22Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespace Symfony\Component\DependencyInjection\Compiler;
1313

1414
use Symfony\Component\DependencyInjection\ChildDefinition;
15+
use Symfony\Component\DependencyInjection\ContainerBuilder;
1516
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
1617

1718
/**
@@ -21,6 +22,24 @@
2122
*/
2223
class ResolveTagsInheritancePass extends AbstractRecursivePass
2324
{
25+
private $abstractInheritedParents = array();
26+
27+
/**
28+
* {@inheritdoc}
29+
*/
30+
public function process(ContainerBuilder $container)
31+
{
32+
try {
33+
parent::process($container);
34+
35+
foreach ($this->abstractInheritedParents as $id) {
36+
$container->findDefinition($id)->setTags(array());
37+
}
38+
} finally {
39+
$this->abstractInheritedParents = array();
40+
}
41+
}
42+
2443
/**
2544
* {@inheritdoc}
2645
*/
@@ -36,6 +55,9 @@ protected function processValue($value, $isRoot = false)
3655
}
3756

3857
$parentDef = $this->container->findDefinition($parent);
58+
if ($parentDef->isAbstract()) {
59+
$this->abstractInheritedParents[$parent] = $parent;
60+
}
3961

4062
if ($parentDef instanceof ChildDefinition) {
4163
$this->processValue($parentDef);

‎src/Symfony/Component/DependencyInjection/ContainerBuilder.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/ContainerBuilder.php
+6-2Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1200,16 +1200,20 @@ public function resolveServices($value)
12001200
* }
12011201
* }
12021202
*
1203-
* @param string $name The tag name
1203+
* @param string $name
1204+
* @param bool $throwOnAbstract
12041205
*
12051206
* @return array An array of tags with the tagged service as key, holding a list of attribute arrays
12061207
*/
1207-
public function findTaggedServiceIds($name)
1208+
public function findTaggedServiceIds($name, $throwOnAbstract = false)
12081209
{
12091210
$this->usedTags[] = $name;
12101211
$tags = array();
12111212
foreach ($this->getDefinitions() as $id => $definition) {
12121213
if ($definition->hasTag($name)) {
1214+
if ($throwOnAbstract && $definition->isAbstract()) {
1215+
throw new InvalidArgumentException(sprintf('The service "%s" tagged "%s" must not be abstract.', $id, $name));
1216+
}
12131217
$tags[$id] = $definition->getTag($name);
12141218
}
12151219
}

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveTagsInheritancePassTest.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ public function testProcess()
2222
{
2323
$container = new ContainerBuilder();
2424
$container->register('grandpa', self::class)->addTag('g');
25-
$container->setDefinition('parent', new ChildDefinition('grandpa'))->addTag('p')->setInheritTags(true);
25+
$container->setDefinition('parent', new ChildDefinition('grandpa'))->addTag('p')->setInheritTags(true)->setAbstract(true);
2626
$container->setDefinition('child', new ChildDefinition('parent'))->setInheritTags(true);
2727

2828
(new ResolveTagsInheritancePass())->process($container);
2929

3030
$expected = array('p' => array(array()), 'g' => array(array()));
31-
$this->assertSame($expected, $container->getDefinition('parent')->getTags());
3231
$this->assertSame($expected, $container->getDefinition('child')->getTags());
32+
$this->assertSame(array(), $container->getDefinition('parent')->getTags());
3333
}
3434
}

‎src/Symfony/Component/EventDispatcher/DependencyInjection/RegisterListenersPass.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/EventDispatcher/DependencyInjection/RegisterListenersPass.php
+2-8Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,8 @@ public function process(ContainerBuilder $container)
6060

6161
$definition = $container->findDefinition($this->dispatcherService);
6262

63-
foreach ($container->findTaggedServiceIds($this->listenerTag) as $id => $events) {
63+
foreach ($container->findTaggedServiceIds($this->listenerTag, true) as $id => $events) {
6464
$def = $container->getDefinition($id);
65-
if ($def->isAbstract()) {
66-
continue;
67-
}
6865

6966
foreach ($events as $event) {
7067
$priority = isset($event['priority']) ? $event['priority'] : 0;
@@ -87,11 +84,8 @@ public function process(ContainerBuilder $container)
8784

8885
$extractingDispatcher = new ExtractingEventDispatcher();
8986

90-
foreach ($container->findTaggedServiceIds($this->subscriberTag) as $id => $attributes) {
87+
foreach ($container->findTaggedServiceIds($this->subscriberTag, true) as $id => $attributes) {
9188
$def = $container->getDefinition($id);
92-
if ($def->isAbstract()) {
93-
continue;
94-
}
9589

9690
// We must assume that the class value has been correctly filled, even if the service is created by a factory
9791
$class = $container->getParameterBag()->resolveValue($def->getClass());

0 commit comments

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