File tree Expand file tree Collapse file tree 1 file changed +15
-5
lines changed
Expand file tree Collapse file tree 1 file changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -164,15 +164,25 @@ private function setArguments(mixed ...$argument): void
164164 if (! $ this ->parameters ->isVariadic ()) {
165165 $ this ->assertArgumentsCount ($ argument );
166166 }
167+ if (count ($ this ->parameters ) === 0 ) {
168+ $ this ->arguments = $ argument ; // @phpstan-ignore-line
169+
170+ return ;
171+ }
172+ $ isPositional = array_is_list ($ argument );
167173 $ lastKey = array_key_last ($ this ->parameters ->keys ());
168174 $ lastName = $ this ->parameters ->keys ()[$ lastKey ] ?? null ;
169- $ values = [];
170175 foreach ($ this ->parameters as $ name => $ parameter ) {
171176 if ($ name === $ lastName && $ this ->parameters ->isVariadic ()) {
172- $ variadicKeys = array_diff_key (
173- $ argument ,
174- array_flip ($ this ->parameters ->keys ())
175- );
177+ if ($ isPositional ) {
178+ /** @var int $lastKey */
179+ $ variadicKeys = array_slice ($ argument , $ lastKey );
180+ } else {
181+ $ variadicKeys = array_diff_key (
182+ $ argument ,
183+ array_flip ($ this ->parameters ->keys ())
184+ );
185+ }
176186 foreach ($ variadicKeys as $ key => $ value ) {
177187 $ key = strval ($ key );
178188 $ values [$ key ] = $ value ;
You can’t perform that action at this time.
0 commit comments