Skip to content

Commit

Permalink
Add generics type definition
Browse files Browse the repository at this point in the history
  • Loading branch information
fdalcin committed Feb 28, 2022
1 parent d1c3d4f commit 1abcca2
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 1abcca2

Please sign in to comment.