Skip to content

Commit 210b371

Browse files
committed
don't check parameter values if they are not set
1 parent 80b5ce4 commit 210b371

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/Symfony/Component/DependencyInjection/Compiler/CheckTypeDeclarationsPass.php

+8-2
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,17 @@ private function checkTypeDeclarations(Definition $checkedDefinition, \Reflectio
139139
$envPlaceholderUniquePrefix = $this->container->getParameterBag() instanceof EnvPlaceholderParameterBag ? $this->container->getParameterBag()->getEnvPlaceholderUniquePrefix() : null;
140140

141141
for ($i = 0; $i < $checksCount; ++$i) {
142-
if (!$reflectionParameters[$i]->hasType() || $reflectionParameters[$i]->isVariadic()) {
142+
$p = $reflectionParameters[$i];
143+
if (!$p->hasType() || $p->isVariadic()) {
144+
continue;
145+
}
146+
if (\array_key_exists($p->name, $values)) {
147+
$i = $p->name;
148+
} elseif (!\array_key_exists($i, $values)) {
143149
continue;
144150
}
145151

146-
$this->checkType($checkedDefinition, $values[$i], $reflectionParameters[$i], $envPlaceholderUniquePrefix);
152+
$this->checkType($checkedDefinition, $values[$i], $p, $envPlaceholderUniquePrefix);
147153
}
148154

149155
if ($reflectionFunction->isVariadic() && ($lastParameter = end($reflectionParameters))->hasType()) {

0 commit comments

Comments
 (0)