From 08343a84e738d42d9eba8d0f96bda3e8b02fb0a0 Mon Sep 17 00:00:00 2001 From: Rodolfo Berrios <20590102+rodber@users.noreply.github.com> Date: Fri, 17 Jan 2025 14:19:18 -0300 Subject: [PATCH] automatic pos/name argument resolver --- src/Arguments.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Arguments.php b/src/Arguments.php index d5ee165..fbf3a2b 100644 --- a/src/Arguments.php +++ b/src/Arguments.php @@ -60,11 +60,14 @@ public function __construct( if ($arguments instanceof ArrayAccess) { $arguments = $this->getArrayAccessArray($arguments); } - if (array_is_list($arguments) && count($arguments) === count($parameters)) { - $arguments = array_combine($parameters->keys(), $arguments); + $isIterable = $parameters->keys() === ['K', 'V']; + $countArguments = count($arguments); + if (array_is_list($arguments) && ! $isIterable) { + $parametersMap = array_slice($this->parameters->keys(), 0, $countArguments); + $arguments = array_combine($parametersMap, $arguments); } $this->setArguments($arguments); - if ($parameters->keys() === ['K', 'V']) { + if ($isIterable) { $pairs = []; foreach (array_keys($arguments) as $key) { $key = strval($key);