Skip to content

Commit 5a6f679

Browse files
[DependencyInjection][FrameworkBundle] Fix precedence of App\Kernel alias and ignore container.excluded tag on synthetic services
1 parent 01e3ad7 commit 5a6f679

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

Compiler/ResolveInstanceofConditionalsPass.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ private function processDefinition(ContainerBuilder $container, string $id, Defi
112112
$definition = substr_replace($definition, '53', 2, 2);
113113
$definition = substr_replace($definition, 'Child', 44, 0);
114114
}
115-
/** @var ChildDefinition $definition */
116115
$definition = unserialize($definition);
116+
/** @var ChildDefinition $definition */
117117
$definition->setParent($parent);
118118

119119
if (null !== $shared && !isset($definition->getChanges()['shared'])) {
@@ -149,6 +149,11 @@ private function processDefinition(ContainerBuilder $container, string $id, Defi
149149
->setAbstract(true);
150150
}
151151

152+
if ($definition->isSynthetic()) {
153+
// Ignore container.excluded tag on synthetic services
154+
$definition->clearTag('container.excluded');
155+
}
156+
152157
return $definition;
153158
}
154159

Tests/Compiler/ResolveInstanceofConditionalsPassTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,21 @@ public function testDecoratorsKeepBehaviorDescribingTags()
376376
], $container->getDefinition('decorator')->getTags());
377377
$this->assertFalse($container->hasParameter('container.behavior_describing_tags'));
378378
}
379+
380+
public function testSyntheticService()
381+
{
382+
$container = new ContainerBuilder();
383+
$container->register('kernel', \stdClass::class)
384+
->setInstanceofConditionals([
385+
\stdClass::class => (new ChildDefinition(''))
386+
->addTag('container.excluded'),
387+
])
388+
->setSynthetic(true);
389+
390+
(new ResolveInstanceofConditionalsPass())->process($container);
391+
392+
$this->assertSame([], $container->getDefinition('kernel')->getTags());
393+
}
379394
}
380395

381396
class DecoratorWithBehavior implements ResetInterface, ResourceCheckerInterface, ServiceSubscriberInterface

0 commit comments

Comments
 (0)