Skip to content

Commit 28ff0e3

Browse files
authored
Document callable types for Enumerable::implode() (#52937)
1 parent ef9113e commit 28ff0e3

File tree

5 files changed

+17
-3
lines changed

5 files changed

+17
-3
lines changed

src/Illuminate/Collections/Collection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,7 @@ public function hasAny($key)
608608
/**
609609
* Concatenate values of a given key as a string.
610610
*
611-
* @param callable|string|null $value
611+
* @param (callable(TValue, TKey): mixed)|string|null $value
612612
* @param string|null $glue
613613
* @return string
614614
*/

src/Illuminate/Collections/Enumerable.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,7 @@ public function hasAny($key);
555555
/**
556556
* Concatenate values of a given key as a string.
557557
*
558-
* @param callable|string $value
558+
* @param (callable(TValue, TKey): mixed)|string $value
559559
* @param string|null $glue
560560
* @return string
561561
*/

src/Illuminate/Collections/LazyCollection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,7 @@ public function hasAny($key)
622622
/**
623623
* Concatenate values of a given key as a string.
624624
*
625-
* @param callable|string $value
625+
* @param (callable(TValue, TKey): mixed)|string $value
626626
* @param string|null $glue
627627
* @return string
628628
*/

types/Support/Collection.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,13 @@ function ($collection, $count) {
538538
assertType('bool', $collection->has(0));
539539
assertType('bool', $collection->has([0, 1]));
540540

541+
assertType('string', $collection->implode(function ($user, $index) {
542+
assertType('User', $user);
543+
assertType('int', $index);
544+
545+
return 'string';
546+
}));
547+
541548
assertType('Illuminate\Support\Collection<int, User>', $collection->intersect([new User]));
542549

543550
assertType('Illuminate\Support\Collection<int, User>', $collection->intersectByKeys([new User]));

types/Support/LazyCollection.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,13 @@
416416
assertType('bool', $collection->has(0));
417417
assertType('bool', $collection->has([0, 1]));
418418

419+
assertType('string', $collection->implode(function ($user, $index) {
420+
assertType('User', $user);
421+
assertType('int', $index);
422+
423+
return 'string';
424+
}));
425+
419426
assertType('Illuminate\Support\LazyCollection<int, User>', $collection->intersect([new User]));
420427

421428
assertType('Illuminate\Support\LazyCollection<int, User>', $collection->intersectByKeys([new User]));

0 commit comments

Comments
 (0)