Skip to content

Commit

Permalink
Merge pull request #41272 from fdalcin/9.x
Browse files Browse the repository at this point in the history
[9.x] Improves `Support\Collection` reduce method type definition
  • Loading branch information
nunomaduro committed Feb 28, 2022
2 parents d1c3d4f + 1abcca2 commit 1a1c140
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Illuminate/Collections/Enumerable.php
Expand Up @@ -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
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Collections/Traits/EnumeratesValues.php
Expand Up @@ -745,7 +745,7 @@ function ($carry, $callback) {
* @template TReduceInitial
* @template TReduceReturnType
*
* @param callable(TReduceInitial|TReduceReturnType, TValue): TReduceReturnType $callback
* @param callable(TReduceInitial|TReduceReturnType, TValue, TKey): TReduceReturnType $callback
* @param TReduceInitial $initial
* @return TReduceReturnType
*/
Expand Down
8 changes: 8 additions & 0 deletions types/Support/Collection.php
Expand Up @@ -634,6 +634,14 @@ function ($collection, $count) {
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));

Expand Down

0 comments on commit 1a1c140

Please sign in to comment.