Skip to content

Commit

Permalink
Document callable types for Enumerable::implode() (#52937)
Browse files Browse the repository at this point in the history
  • Loading branch information
devfrey authored Sep 27, 2024
1 parent ef9113e commit 28ff0e3
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Illuminate/Collections/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Collections/Enumerable.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Collections/LazyCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
7 changes: 7 additions & 0 deletions types/Support/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<int, User>', $collection->intersect([new User]));

assertType('Illuminate\Support\Collection<int, User>', $collection->intersectByKeys([new User]));
Expand Down
7 changes: 7 additions & 0 deletions types/Support/LazyCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<int, User>', $collection->intersect([new User]));

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

0 comments on commit 28ff0e3

Please sign in to comment.