Skip to content

Commit

Permalink
don't check parameter values if they are not set
Browse files Browse the repository at this point in the history
  • Loading branch information
xabbuh committed Nov 29, 2023
1 parent eb1bcaf commit d5d48f2
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions Compiler/CheckTypeDeclarationsPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down

0 comments on commit d5d48f2

Please sign in to comment.