From 82e2151a56ec45821d6cdf097de0a531cfb60d80 Mon Sep 17 00:00:00 2001 From: Jeffrey Angenent <1571879+devfrey@users.noreply.github.com> Date: Thu, 26 Sep 2024 09:37:41 +0200 Subject: [PATCH] Document callable types for `Enumerable::implode()` --- src/Illuminate/Collections/Collection.php | 2 +- src/Illuminate/Collections/Enumerable.php | 2 +- src/Illuminate/Collections/LazyCollection.php | 2 +- types/Support/Collection.php | 7 +++++++ types/Support/LazyCollection.php | 7 +++++++ 5 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/Illuminate/Collections/Collection.php b/src/Illuminate/Collections/Collection.php index d6f79b5400f9..1ab7474f89a6 100644 --- a/src/Illuminate/Collections/Collection.php +++ b/src/Illuminate/Collections/Collection.php @@ -608,7 +608,7 @@ public function hasAny($key) /** * Concatenate values of a given key as a string. * - * @param callable|string|null $value + * @param (callable(TValue, TKey): mixed)|string|null $value * @param string|null $glue * @return string */ diff --git a/src/Illuminate/Collections/Enumerable.php b/src/Illuminate/Collections/Enumerable.php index 36c47995a1d4..836d4225608b 100644 --- a/src/Illuminate/Collections/Enumerable.php +++ b/src/Illuminate/Collections/Enumerable.php @@ -555,7 +555,7 @@ public function hasAny($key); /** * Concatenate values of a given key as a string. * - * @param callable|string $value + * @param (callable(TValue, TKey): mixed)|string $value * @param string|null $glue * @return string */ diff --git a/src/Illuminate/Collections/LazyCollection.php b/src/Illuminate/Collections/LazyCollection.php index a79cb31315b7..c8fc497bbd05 100644 --- a/src/Illuminate/Collections/LazyCollection.php +++ b/src/Illuminate/Collections/LazyCollection.php @@ -622,7 +622,7 @@ public function hasAny($key) /** * Concatenate values of a given key as a string. * - * @param callable|string $value + * @param (callable(TValue, TKey): mixed)|string $value * @param string|null $glue * @return string */ diff --git a/types/Support/Collection.php b/types/Support/Collection.php index 8a0805ee3be4..30d13f3943d7 100644 --- a/types/Support/Collection.php +++ b/types/Support/Collection.php @@ -538,6 +538,13 @@ function ($collection, $count) { assertType('bool', $collection->has(0)); assertType('bool', $collection->has([0, 1])); +assertType('string', $collection->implode(function ($user, $index) { + assertType('User', $user); + assertType('int', $index); + + return 'string'; +})); + assertType('Illuminate\Support\Collection', $collection->intersect([new User])); assertType('Illuminate\Support\Collection', $collection->intersectByKeys([new User])); diff --git a/types/Support/LazyCollection.php b/types/Support/LazyCollection.php index 51694fdf4488..eabbc28984b5 100644 --- a/types/Support/LazyCollection.php +++ b/types/Support/LazyCollection.php @@ -416,6 +416,13 @@ assertType('bool', $collection->has(0)); assertType('bool', $collection->has([0, 1])); +assertType('string', $collection->implode(function ($user, $index) { + assertType('User', $user); + assertType('int', $index); + + return 'string'; +})); + assertType('Illuminate\Support\LazyCollection', $collection->intersect([new User])); assertType('Illuminate\Support\LazyCollection', $collection->intersectByKeys([new User]));