diff --git a/src/Illuminate/Collections/Enumerable.php b/src/Illuminate/Collections/Enumerable.php index eb050dec772a..be621adde94a 100644 --- a/src/Illuminate/Collections/Enumerable.php +++ b/src/Illuminate/Collections/Enumerable.php @@ -805,7 +805,7 @@ public function random($number = null); * @template TReduceInitial * @template TReduceReturnType * - * @param callable(TReduceInitial|TReduceReturnType, TValue): TReduceReturnType $callback + * @param callable(TReduceInitial|TReduceReturnType, TValue, TKey): TReduceReturnType $callback * @param TReduceInitial $initial * @return TReduceReturnType */ diff --git a/src/Illuminate/Collections/Traits/EnumeratesValues.php b/src/Illuminate/Collections/Traits/EnumeratesValues.php index bb18f45593c3..f76c7f06ab53 100644 --- a/src/Illuminate/Collections/Traits/EnumeratesValues.php +++ b/src/Illuminate/Collections/Traits/EnumeratesValues.php @@ -744,7 +744,7 @@ function ($carry, $pipe) { * @template TReduceInitial * @template TReduceReturnType * - * @param callable(TReduceInitial|TReduceReturnType, TValue): TReduceReturnType $callback + * @param callable(TReduceInitial|TReduceReturnType, TValue, TKey): TReduceReturnType $callback * @param TReduceInitial $initial * @return TReduceReturnType */ @@ -808,7 +808,7 @@ class_basename(static::class), gettype($result) * @template TReduceWithKeysInitial * @template TReduceWithKeysReturnType * - * @param callable(TReduceWithKeysInitial|TReduceWithKeysReturnType, TValue): TReduceWithKeysReturnType $callback + * @param callable(TReduceWithKeysInitial|TReduceWithKeysReturnType, TValue, TKey): TReduceWithKeysReturnType $callback * @param TReduceWithKeysInitial $initial * @return TReduceWithKeysReturnType */ diff --git a/types/Support/Collection.php b/types/Support/Collection.php index 0c335a25bce5..d2630a60d2ad 100644 --- a/types/Support/Collection.php +++ b/types/Support/Collection.php @@ -544,6 +544,14 @@ assertType('User', $user); assertType('int', $int); + return 1; + }, 0)); +assertType('int', $collection + ->reduce(function ($int, $user, $key) { + assertType('User', $user); + assertType('int', $int); + assertType('int', $key); + return 1; }, 0)); @@ -559,6 +567,14 @@ assertType('User', $user); assertType('int', $int); + return 1; + }, 0)); +assertType('int', $collection + ->reduceWithKeys(function ($int, $user, $key) { + assertType('User', $user); + assertType('int', $int); + assertType('int', $key); + return 1; }, 0));