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 5c475e1

Browse filesBrowse files
[DependencyInjection][FrameworkBundle] Fix precedence of App\Kernel alias and ignore container.excluded tag on synthetic services
1 parent 72c0a36 commit 5c475e1
Copy full SHA for 5c475e1

File tree

4 files changed

+33
-12
lines changed
Filter options

4 files changed

+33
-12
lines changed

‎src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
+10-10Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -791,34 +791,34 @@ static function (ChildDefinition $definition, AsPeriodicTask|AsCronTask $attribu
791791
}
792792

793793
$container->registerForAutoconfiguration(CompilerPassInterface::class)
794-
->addTag('container.excluded', ['source' => 'because it\'s a compiler pass'])->setAbstract(true);
794+
->addTag('container.excluded', ['source' => 'because it\'s a compiler pass']);
795795
$container->registerForAutoconfiguration(Constraint::class)
796-
->addTag('container.excluded', ['source' => 'because it\'s a validation constraint'])->setAbstract(true);
796+
->addTag('container.excluded', ['source' => 'because it\'s a validation constraint']);
797797
$container->registerForAutoconfiguration(TestCase::class)
798-
->addTag('container.excluded', ['source' => 'because it\'s a test case'])->setAbstract(true);
798+
->addTag('container.excluded', ['source' => 'because it\'s a test case']);
799799
$container->registerForAutoconfiguration(\UnitEnum::class)
800-
->addTag('container.excluded', ['source' => 'because it\'s an enum'])->setAbstract(true);
800+
->addTag('container.excluded', ['source' => 'because it\'s an enum']);
801801
$container->registerAttributeForAutoconfiguration(AsMessage::class, static function (ChildDefinition $definition) {
802-
$definition->addTag('container.excluded', ['source' => 'because it\'s a messenger message'])->setAbstract(true);
802+
$definition->addTag('container.excluded', ['source' => 'because it\'s a messenger message']);
803803
});
804804
$container->registerAttributeForAutoconfiguration(\Attribute::class, static function (ChildDefinition $definition) {
805-
$definition->addTag('container.excluded', ['source' => 'because it\'s an attribute'])->setAbstract(true);
805+
$definition->addTag('container.excluded', ['source' => 'because it\'s an attribute']);
806806
});
807807
$container->registerAttributeForAutoconfiguration(Entity::class, static function (ChildDefinition $definition) {
808-
$definition->addTag('container.excluded', ['source' => 'because it\'s a doctrine entity'])->setAbstract(true);
808+
$definition->addTag('container.excluded', ['source' => 'because it\'s a doctrine entity']);
809809
});
810810
$container->registerAttributeForAutoconfiguration(Embeddable::class, static function (ChildDefinition $definition) {
811-
$definition->addTag('container.excluded', ['source' => 'because it\'s a doctrine embeddable'])->setAbstract(true);
811+
$definition->addTag('container.excluded', ['source' => 'because it\'s a doctrine embeddable']);
812812
});
813813
$container->registerAttributeForAutoconfiguration(MappedSuperclass::class, static function (ChildDefinition $definition) {
814-
$definition->addTag('container.excluded', ['source' => 'because it\'s a doctrine mapped superclass'])->setAbstract(true);
814+
$definition->addTag('container.excluded', ['source' => 'because it\'s a doctrine mapped superclass']);
815815
});
816816

817817
$container->registerAttributeForAutoconfiguration(JsonStreamable::class, static function (ChildDefinition $definition, JsonStreamable $attribute) {
818818
$definition->addTag('json_streamer.streamable', [
819819
'object' => $attribute->asObject,
820820
'list' => $attribute->asList,
821-
])->addTag('container.excluded', ['source' => 'because it\'s a streamable JSON'])->setAbstract(true);
821+
])->addTag('container.excluded', ['source' => 'because it\'s a streamable JSON']);
822822
});
823823

824824
if (!$container->getParameter('kernel.debug')) {

‎src/Symfony/Bundle/FrameworkBundle/Kernel/MicroKernelTrait.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/Kernel/MicroKernelTrait.php
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,6 @@ public function registerContainerConfiguration(LoaderInterface $loader): void
165165
->setPublic(true)
166166
;
167167
}
168-
$container->setAlias($kernelClass, 'kernel')->setPublic(true);
169168

170169
$kernelDefinition = $container->getDefinition('kernel');
171170
$kernelDefinition->addTag('routing.route_loader');
@@ -198,6 +197,8 @@ public function registerContainerConfiguration(LoaderInterface $loader): void
198197
$kernelLoader->registerAliasesForSinglyImplementedInterfaces();
199198
AbstractConfigurator::$valuePreProcessor = $valuePreProcessor;
200199
}
200+
201+
$container->setAlias($kernelClass, 'kernel')->setPublic(true);
201202
});
202203
}
203204

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/DependencyInjection/Compiler/ResolveInstanceofConditionalsPass.php
+6-1Lines 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

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

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