Skip to content

Commit 0fe7090

Browse files
committed
bug #52780 [DependencyInjection] don't check parameter values if they are not set (xabbuh)
This PR was merged into the 5.4 branch. Discussion ---------- [DependencyInjection] don't check parameter values if they are not set | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | Fix #52768 | License | MIT Commits ------- 210b371 don't check parameter values if they are not set
2 parents e95605c + 210b371 commit 0fe7090

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

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

Lines changed: 8 additions & 2 deletions
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy