Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[10.x] Fix Collection::concat() return type #50669

Merged
merged 1 commit into from Mar 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/Illuminate/Collections/Collection.php
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
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
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
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
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