Skip to content

Commit 9f26b84

Browse files
authored
Fix Collection::concat() return type (#50669)
1 parent 8fc7bd4 commit 9f26b84

File tree

5 files changed

+17
-6
lines changed

5 files changed

+17
-6
lines changed

src/Illuminate/Collections/Collection.php

+5-2
Original file line numberDiff line numberDiff line change
@@ -998,8 +998,11 @@ public function push(...$values)
998998
/**
999999
* Push all of the given items onto the collection.
10001000
*
1001-
* @param iterable<array-key, TValue> $source
1002-
* @return static
1001+
* @template TConcatKey of array-key
1002+
* @template TConcatValue
1003+
*
1004+
* @param iterable<TConcatKey, TConcatValue> $source
1005+
* @return static<TKey|TConcatKey, TValue|TConcatValue>
10031006
*/
10041007
public function concat($source)
10051008
{

src/Illuminate/Collections/Enumerable.php

+5-2
Original file line numberDiff line numberDiff line change
@@ -789,8 +789,11 @@ public function partition($key, $operator = null, $value = null);
789789
/**
790790
* Push all of the given items onto the collection.
791791
*
792-
* @param iterable<array-key, TValue> $source
793-
* @return static
792+
* @template TConcatKey of array-key
793+
* @template TConcatValue
794+
*
795+
* @param iterable<TConcatKey, TConcatValue> $source
796+
* @return static<TKey|TConcatKey, TValue|TConcatValue>
794797
*/
795798
public function concat($source);
796799

src/Illuminate/Collections/LazyCollection.php

+5-2
Original file line numberDiff line numberDiff line change
@@ -991,8 +991,11 @@ public function select($keys)
991991
/**
992992
* Push all of the given items onto the collection.
993993
*
994-
* @param iterable<array-key, TValue> $source
995-
* @return static
994+
* @template TConcatKey of array-key
995+
* @template TConcatValue
996+
*
997+
* @param iterable<TConcatKey, TConcatValue> $source
998+
* @return static<TKey|TConcatKey, TValue|TConcatValue>
996999
*/
9971000
public function concat($source)
9981001
{

types/Support/Collection.php

+1
Original file line numberDiff line numberDiff line change
@@ -657,6 +657,7 @@ function ($collection, $count) {
657657

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

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

types/Support/LazyCollection.php

+1
Original file line numberDiff line numberDiff line change
@@ -547,6 +547,7 @@
547547

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

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

0 commit comments

Comments
 (0)