Skip to content

Commit

Permalink
Fix Collection::concat() return type (#50669)
Browse files Browse the repository at this point in the history
  • Loading branch information
axlon committed Mar 20, 2024
1 parent 8fc7bd4 commit 9f26b84
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 6 deletions.
7 changes: 5 additions & 2 deletions src/Illuminate/Collections/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -998,8 +998,11 @@ public function push(...$values)
/**
* Push all of the given items onto the collection.
*
* @param iterable<array-key, TValue> $source
* @return static
* @template TConcatKey of array-key
* @template TConcatValue
*
* @param iterable<TConcatKey, TConcatValue> $source
* @return static<TKey|TConcatKey, TValue|TConcatValue>
*/
public function concat($source)
{
Expand Down
7 changes: 5 additions & 2 deletions src/Illuminate/Collections/Enumerable.php
Original file line number Diff line number Diff line change
Expand Up @@ -789,8 +789,11 @@ public function partition($key, $operator = null, $value = null);
/**
* Push all of the given items onto the collection.
*
* @param iterable<array-key, TValue> $source
* @return static
* @template TConcatKey of array-key
* @template TConcatValue
*
* @param iterable<TConcatKey, TConcatValue> $source
* @return static<TKey|TConcatKey, TValue|TConcatValue>
*/
public function concat($source);

Expand Down
7 changes: 5 additions & 2 deletions src/Illuminate/Collections/LazyCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -991,8 +991,11 @@ public function select($keys)
/**
* Push all of the given items onto the collection.
*
* @param iterable<array-key, TValue> $source
* @return static
* @template TConcatKey of array-key
* @template TConcatValue
*
* @param iterable<TConcatKey, TConcatValue> $source
* @return static<TKey|TConcatKey, TValue|TConcatValue>
*/
public function concat($source)
{
Expand Down
1 change: 1 addition & 0 deletions types/Support/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,7 @@ function ($collection, $count) {

assertType('Illuminate\Support\Collection<int, int>', $collection->make([1])->concat([2]));
assertType('Illuminate\Support\Collection<int, string>', $collection->make(['string'])->concat(['string']));
assertType('Illuminate\Support\Collection<int, int|string>', $collection->make([1])->concat(['string']));

assertType('Illuminate\Support\Collection<int, int>|int', $collection->make([1])->random(2));
assertType('Illuminate\Support\Collection<int, string>|string', $collection->make(['string'])->random());
Expand Down
1 change: 1 addition & 0 deletions types/Support/LazyCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,7 @@

assertType('Illuminate\Support\LazyCollection<int, int>', $collection->make([1])->concat([2]));
assertType('Illuminate\Support\LazyCollection<int, string>', $collection->make(['string'])->concat(['string']));
assertType('Illuminate\Support\LazyCollection<int, int|string>', $collection->make([1])->concat(['string']));

assertType('Illuminate\Support\LazyCollection<int, int>|int', $collection->make([1])->random(2));
assertType('Illuminate\Support\LazyCollection<int, string>|string', $collection->make(['string'])->random());
Expand Down

0 comments on commit 9f26b84

Please sign in to comment.