From 210b371de5069fdf01ec72462ec7e85571ebaa2c Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Wed, 29 Nov 2023 07:58:28 +0100 Subject: [PATCH] don't check parameter values if they are not set --- .../Compiler/CheckTypeDeclarationsPass.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Component/DependencyInjection/Compiler/CheckTypeDeclarationsPass.php b/src/Symfony/Component/DependencyInjection/Compiler/CheckTypeDeclarationsPass.php index e69d56fb16265..867a4a22412f2 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/CheckTypeDeclarationsPass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/CheckTypeDeclarationsPass.php @@ -139,11 +139,17 @@ private function checkTypeDeclarations(Definition $checkedDefinition, \Reflectio $envPlaceholderUniquePrefix = $this->container->getParameterBag() instanceof EnvPlaceholderParameterBag ? $this->container->getParameterBag()->getEnvPlaceholderUniquePrefix() : null; for ($i = 0; $i < $checksCount; ++$i) { - if (!$reflectionParameters[$i]->hasType() || $reflectionParameters[$i]->isVariadic()) { + $p = $reflectionParameters[$i]; + if (!$p->hasType() || $p->isVariadic()) { + continue; + } + if (\array_key_exists($p->name, $values)) { + $i = $p->name; + } elseif (!\array_key_exists($i, $values)) { continue; } - $this->checkType($checkedDefinition, $values[$i], $reflectionParameters[$i], $envPlaceholderUniquePrefix); + $this->checkType($checkedDefinition, $values[$i], $p, $envPlaceholderUniquePrefix); } if ($reflectionFunction->isVariadic() && ($lastParameter = end($reflectionParameters))->hasType()) {