From 397504389b6bb9abab846f568fc973aceeb5f5de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Tamarelle?= Date: Fri, 28 Mar 2025 18:29:28 +0100 Subject: [PATCH] Remove always-true condition Introduced in symfony/symfony#45657 symfony/dependency-injection 6.4+ is required, so the class always exists --- .../RegisterControllerArgumentLocatorsPass.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/HttpKernel/DependencyInjection/RegisterControllerArgumentLocatorsPass.php b/src/Symfony/Component/HttpKernel/DependencyInjection/RegisterControllerArgumentLocatorsPass.php index d473a2e6b04a7..a5fa06f17b495 100644 --- a/src/Symfony/Component/HttpKernel/DependencyInjection/RegisterControllerArgumentLocatorsPass.php +++ b/src/Symfony/Component/HttpKernel/DependencyInjection/RegisterControllerArgumentLocatorsPass.php @@ -51,8 +51,6 @@ public function process(ContainerBuilder $container): void } } - $emptyAutowireAttributes = class_exists(Autowire::class) ? null : []; - foreach ($container->findTaggedServiceIds('controller.service_arguments', true) as $id => $tags) { $def = $container->getDefinition($id); $def->setPublic(true); @@ -129,7 +127,7 @@ public function process(ContainerBuilder $container): void /** @var \ReflectionParameter $p */ $type = preg_replace('/(^|[(|&])\\\\/', '\1', $target = ltrim(ProxyHelper::exportType($p) ?? '', '?')); $invalidBehavior = ContainerInterface::IGNORE_ON_INVALID_REFERENCE; - $autowireAttributes = $autowire ? $emptyAutowireAttributes : []; + $autowireAttributes = null; $parsedName = $p->name; $k = null; @@ -155,7 +153,7 @@ public function process(ContainerBuilder $container): void $args[$p->name] = $bindingValue; continue; - } elseif (!$autowire || (!($autowireAttributes ??= $p->getAttributes(Autowire::class, \ReflectionAttribute::IS_INSTANCEOF)) && (!$type || '\\' !== $target[0]))) { + } elseif (!$autowire || (!($autowireAttributes = $p->getAttributes(Autowire::class, \ReflectionAttribute::IS_INSTANCEOF)) && (!$type || '\\' !== $target[0]))) { continue; } elseif (is_subclass_of($type, \UnitEnum::class)) { // do not attempt to register enum typed arguments if not already present in bindings