Skip to content

Commit

Permalink
[9.x] Improve Support\LazyCollection type definitions (#39506)
Browse files Browse the repository at this point in the history
* Make LazyCollection generic

* Remove `toBase` type test from LazyCollection
  • Loading branch information
Sébastien Nikolaou authored Nov 7, 2021
1 parent 5869c9d commit 0565d94
Show file tree
Hide file tree
Showing 6 changed files with 1,039 additions and 148 deletions.
10 changes: 5 additions & 5 deletions src/Illuminate/Collections/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function all()
/**
* Get a lazy collection for the items in this collection.
*
* @return \Illuminate\Support\LazyCollection
* @return \Illuminate\Support\LazyCollection<TKey, TValue>
*/
public function lazy()
{
Expand Down Expand Up @@ -366,7 +366,7 @@ public function filter(callable $callback = null)
*
* @template TFirstDefault
*
* @param (callable(TValue): bool)|null $callback
* @param (callable(TValue, TKey): bool)|null $callback
* @param TFirstDefault $default
* @return TValue|TFirstDefault
*/
Expand Down Expand Up @@ -1188,10 +1188,10 @@ public function sole($key = null, $operator = null, $value = null)
/**
* Get the first item in the collection but throw an exception if no matching items exist.
*
* @param mixed $key
* @param (callable(TValue, TKey): bool)|string $key
* @param mixed $operator
* @param mixed $value
* @return mixed
* @return TValue
*
* @throws \Illuminate\Support\ItemNotFoundException
*/
Expand All @@ -1216,7 +1216,7 @@ public function firstOrFail($key = null, $operator = null, $value = null)
* Chunk the collection into chunks of the given size.
*
* @param int $size
* @return static<int, static<int, TValue>>
* @return static<int, static<TKey, TValue>>
*/
public function chunk($size)
{
Expand Down
10 changes: 6 additions & 4 deletions src/Illuminate/Collections/Enumerable.php
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ public function whereInstanceOf($type);
*
* @template TFirstDefault
*
* @param (callable(TValue): bool)|null $callback
* @param (callable(TValue,TKey): bool)|null $callback
* @param TFirstDefault $default
* @return TValue|TFirstDefault
*/
Expand Down Expand Up @@ -878,7 +878,7 @@ public function sole($key = null, $operator = null, $value = null);
* Chunk the collection into chunks of the given size.
*
* @param int $size
* @return static<int, static<int, TValue>>
* @return static<int, static<TKey, TValue>>
*/
public function chunk($size);

Expand Down Expand Up @@ -1047,8 +1047,10 @@ public function pad($size, $value);
/**
* Count the number of items in the collection using a given truth test.
*
* @param (callable(TValue, TKey): mixed)|string|null $callback
* @return static<TValue, int>
* @template TGroup of array-key
*
* @param (callable(TValue, TKey): TGroup)|string|null $callback
* @return static<TGroup, int>
*/
public function countBy($callback = null);

Expand Down
Loading

0 comments on commit 0565d94

Please sign in to comment.