Skip to content

Commit e6dd1b9

Browse files
committed
Fix baseRest implementation
1 parent 0dcee2f commit e6dd1b9

File tree

7 files changed

+9
-8
lines changed

7 files changed

+9
-8
lines changed

src/Array/without.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,5 @@
3434
*/
3535
function without(array $array, ...$values): array
3636
{
37-
return baseRest('\_\difference')($array, $values);
37+
return baseRest('\_\difference')($array, ...$values);
3838
}

src/Array/zip.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@
3131
*/
3232
function zip(array ...$arrays): array
3333
{
34-
return baseRest('\_\unzip')($arrays);
34+
return baseRest('\_\unzip')(...$arrays);
3535
}

src/Collection/invokeMap.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,5 @@ function invokeMap(iterable $collection, $path, array $args = []): array
4747
});
4848

4949
return $result;
50-
})($collection, $path, $args);
50+
})($collection, $path, ...$args);
5151
}

src/Function/overArgs.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ function overArgs(callable $func, array $transforms): callable
5858

5959
$funcsLength = \count($transforms);
6060

61-
return baseRest(function (...$args) use ($funcsLength, $transforms, $func) {
61+
return baseRest(function ($args) use ($funcsLength, $transforms, $func) {
6262
$index = -1;
6363
$length = \min(\count($args), $funcsLength);
6464

src/Function/spread.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ function spread(callable $func, ?int $start = null)
4545
{
4646
$start = null === $start ? 0 : \max($start, 0);
4747

48-
return baseRest(function (...$args) use ($start, $func) {
48+
return baseRest(function ($args) use ($start, $func) {
4949
$array = $args[$start];
5050
$otherArgs = castSlice($args, 0, $start);
5151

src/Object/pick.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
*/
3333
function pick($object, $paths): \stdClass
3434
{
35-
return flatRest(function ($object, ...$paths) {
35+
return flatRest(function ($object, $paths) {
3636
return basePick($object, $paths);
3737
})($object, $paths);
3838
}

src/internal/overRest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313

1414
function overRest(callable $func, $start, callable $transform): callable
1515
{
16-
$start = max($start ?? -1, 0);
16+
$parameters = (new \ReflectionFunction($func))->getNumberOfParameters();
17+
$start = max($start ?? $parameters - 1, 0);
1718

1819
return function () use ($func, $start, $transform) {
1920
$args = \func_get_args();
@@ -31,6 +32,6 @@ function overRest(callable $func, $start, callable $transform): callable
3132
}
3233
$otherArgs[$start] = $transform($array);
3334

34-
return $func(...$otherArgs[$start]);
35+
return $func(...$otherArgs);
3536
};
3637
}

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