Skip to content

Navigation Menu

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

[DependencyInjection][FrameworkBundle] Fix precedence of App\Kernel alias and ignore container.excluded tag on synthetic services #60392

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -791,34 +791,34 @@ static function (ChildDefinition $definition, AsPeriodicTask|AsCronTask $attribu
}

$container->registerForAutoconfiguration(CompilerPassInterface::class)
->addTag('container.excluded', ['source' => 'because it\'s a compiler pass'])->setAbstract(true);
->addTag('container.excluded', ['source' => 'because it\'s a compiler pass']);
$container->registerForAutoconfiguration(Constraint::class)
->addTag('container.excluded', ['source' => 'because it\'s a validation constraint'])->setAbstract(true);
->addTag('container.excluded', ['source' => 'because it\'s a validation constraint']);
$container->registerForAutoconfiguration(TestCase::class)
->addTag('container.excluded', ['source' => 'because it\'s a test case'])->setAbstract(true);
->addTag('container.excluded', ['source' => 'because it\'s a test case']);
$container->registerForAutoconfiguration(\UnitEnum::class)
->addTag('container.excluded', ['source' => 'because it\'s an enum'])->setAbstract(true);
->addTag('container.excluded', ['source' => 'because it\'s an enum']);
$container->registerAttributeForAutoconfiguration(AsMessage::class, static function (ChildDefinition $definition) {
$definition->addTag('container.excluded', ['source' => 'because it\'s a messenger message'])->setAbstract(true);
$definition->addTag('container.excluded', ['source' => 'because it\'s a messenger message']);
});
$container->registerAttributeForAutoconfiguration(\Attribute::class, static function (ChildDefinition $definition) {
$definition->addTag('container.excluded', ['source' => 'because it\'s an attribute'])->setAbstract(true);
$definition->addTag('container.excluded', ['source' => 'because it\'s a PHP attribute']);
});
$container->registerAttributeForAutoconfiguration(Entity::class, static function (ChildDefinition $definition) {
$definition->addTag('container.excluded', ['source' => 'because it\'s a doctrine entity'])->setAbstract(true);
$definition->addTag('container.excluded', ['source' => 'because it\'s a Doctrine entity']);
});
$container->registerAttributeForAutoconfiguration(Embeddable::class, static function (ChildDefinition $definition) {
$definition->addTag('container.excluded', ['source' => 'because it\'s a doctrine embeddable'])->setAbstract(true);
$definition->addTag('container.excluded', ['source' => 'because it\'s a Doctrine embeddable']);
});
$container->registerAttributeForAutoconfiguration(MappedSuperclass::class, static function (ChildDefinition $definition) {
$definition->addTag('container.excluded', ['source' => 'because it\'s a doctrine mapped superclass'])->setAbstract(true);
$definition->addTag('container.excluded', ['source' => 'because it\'s a Doctrine mapped superclass']);
});

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

if (!$container->getParameter('kernel.debug')) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ public function registerContainerConfiguration(LoaderInterface $loader): void
->setPublic(true)
;
}
$container->setAlias($kernelClass, 'kernel')->setPublic(true);

$kernelDefinition = $container->getDefinition('kernel');
$kernelDefinition->addTag('routing.route_loader');
Expand Down Expand Up @@ -198,6 +197,8 @@ public function registerContainerConfiguration(LoaderInterface $loader): void
$kernelLoader->registerAliasesForSinglyImplementedInterfaces();
AbstractConfigurator::$valuePreProcessor = $valuePreProcessor;
}

$container->setAlias($kernelClass, 'kernel')->setPublic(true);
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ private function processDefinition(ContainerBuilder $container, string $id, Defi
$definition = substr_replace($definition, '53', 2, 2);
$definition = substr_replace($definition, 'Child', 44, 0);
}
/** @var ChildDefinition $definition */
$definition = unserialize($definition);
/** @var ChildDefinition $definition */
$definition->setParent($parent);

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

if ($definition->isSynthetic()) {
// Ignore container.excluded tag on synthetic services
nicolas-grekas marked this conversation as resolved.
Show resolved Hide resolved
$definition->clearTag('container.excluded');
}

return $definition;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,21 @@ public function testDecoratorsKeepBehaviorDescribingTags()
], $container->getDefinition('decorator')->getTags());
$this->assertFalse($container->hasParameter('container.behavior_describing_tags'));
}

public function testSyntheticService()
{
$container = new ContainerBuilder();
$container->register('kernel', \stdClass::class)
->setInstanceofConditionals([
\stdClass::class => (new ChildDefinition(''))
->addTag('container.excluded'),
])
->setSynthetic(true);

(new ResolveInstanceofConditionalsPass())->process($container);

$this->assertSame([], $container->getDefinition('kernel')->getTags());
}
}

class DecoratorWithBehavior implements ResetInterface, ResourceCheckerInterface, ServiceSubscriberInterface
Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.