Skip to content

Commit

Permalink
automatic pos/name argument resolver
Browse files Browse the repository at this point in the history
  • Loading branch information
rodber committed Jan 17, 2025
1 parent 656f4d7 commit 08343a8
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/Arguments.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 08343a8

Please sign in to comment.