From fd0bc8a71cf517fd6896a40d31e6dc1cd962097c Mon Sep 17 00:00:00 2001 From: Felipe Dalcin Date: Fri, 4 Feb 2022 14:19:27 -0300 Subject: [PATCH 1/3] Update tests --- types/Support/Collection.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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)); From 8838553cc7c9477efb00b6d0e27e807c6f14f421 Mon Sep 17 00:00:00 2001 From: Felipe Dalcin Date: Fri, 4 Feb 2022 14:23:08 -0300 Subject: [PATCH 2/3] Trigger pipeline From b24ce992dd1bc78cc2fcafc18c981b5f2ceec705 Mon Sep 17 00:00:00 2001 From: Felipe Dalcin Date: Fri, 4 Feb 2022 14:27:10 -0300 Subject: [PATCH 3/3] Fix generics type definition --- src/Illuminate/Collections/Enumerable.php | 2 +- src/Illuminate/Collections/Traits/EnumeratesValues.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) 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 */