From a9f28754938320408356b7ebe86bd05e2a449945 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Mon, 27 Feb 2023 17:59:26 +0100 Subject: [PATCH] Resolver: refactoring --- src/DI/Resolver.php | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/DI/Resolver.php b/src/DI/Resolver.php index 7ccfa36ed..d8d6ed6ec 100644 --- a/src/DI/Resolver.php +++ b/src/DI/Resolver.php @@ -555,13 +555,9 @@ public static function autowireArguments( $optCount = 0; break; - } elseif (array_key_exists($paramName, $arguments)) { - $res[$useName ? $paramName : $num] = $arguments[$paramName]; - unset($arguments[$paramName], $arguments[$num]); - - } elseif (array_key_exists($num, $arguments)) { - $res[$useName ? $paramName : $num] = $arguments[$num]; - unset($arguments[$num]); + } elseif (array_key_exists($key = $paramName, $arguments) || array_key_exists($key = $num, $arguments)) { + $res[$useName ? $paramName : $num] = $arguments[$key]; + unset($arguments[$key], $arguments[$num]); // unset $num to enable overwriting in configuration } elseif (($aw = self::autowireArgument($param, $getter)) !== null) { $res[$useName ? $paramName : $num] = $aw;