From 9f26b84c0cd0b3fb1dd7924eaa490e20fe9675c2 Mon Sep 17 00:00:00 2001 From: Choraimy Kroonstuiver <3661474+axlon@users.noreply.github.com> Date: Wed, 20 Mar 2024 21:09:13 +0100 Subject: [PATCH] Fix `Collection::concat()` return type (#50669) --- src/Illuminate/Collections/Collection.php | 7 +++++-- src/Illuminate/Collections/Enumerable.php | 7 +++++-- src/Illuminate/Collections/LazyCollection.php | 7 +++++-- types/Support/Collection.php | 1 + types/Support/LazyCollection.php | 1 + 5 files changed, 17 insertions(+), 6 deletions(-) diff --git a/src/Illuminate/Collections/Collection.php b/src/Illuminate/Collections/Collection.php index 0bbbe189816f..c46fc052f972 100644 --- a/src/Illuminate/Collections/Collection.php +++ b/src/Illuminate/Collections/Collection.php @@ -998,8 +998,11 @@ public function push(...$values) /** * Push all of the given items onto the collection. * - * @param iterable $source - * @return static + * @template TConcatKey of array-key + * @template TConcatValue + * + * @param iterable $source + * @return static */ public function concat($source) { diff --git a/src/Illuminate/Collections/Enumerable.php b/src/Illuminate/Collections/Enumerable.php index a561488e8a59..918f64758e66 100644 --- a/src/Illuminate/Collections/Enumerable.php +++ b/src/Illuminate/Collections/Enumerable.php @@ -789,8 +789,11 @@ public function partition($key, $operator = null, $value = null); /** * Push all of the given items onto the collection. * - * @param iterable $source - * @return static + * @template TConcatKey of array-key + * @template TConcatValue + * + * @param iterable $source + * @return static */ public function concat($source); diff --git a/src/Illuminate/Collections/LazyCollection.php b/src/Illuminate/Collections/LazyCollection.php index a8b7716d35d6..84b22ebf9257 100644 --- a/src/Illuminate/Collections/LazyCollection.php +++ b/src/Illuminate/Collections/LazyCollection.php @@ -991,8 +991,11 @@ public function select($keys) /** * Push all of the given items onto the collection. * - * @param iterable $source - * @return static + * @template TConcatKey of array-key + * @template TConcatValue + * + * @param iterable $source + * @return static */ public function concat($source) { diff --git a/types/Support/Collection.php b/types/Support/Collection.php index 77861041deaf..2e8b4a926386 100644 --- a/types/Support/Collection.php +++ b/types/Support/Collection.php @@ -657,6 +657,7 @@ function ($collection, $count) { assertType('Illuminate\Support\Collection', $collection->make([1])->concat([2])); assertType('Illuminate\Support\Collection', $collection->make(['string'])->concat(['string'])); +assertType('Illuminate\Support\Collection', $collection->make([1])->concat(['string'])); assertType('Illuminate\Support\Collection|int', $collection->make([1])->random(2)); assertType('Illuminate\Support\Collection|string', $collection->make(['string'])->random()); diff --git a/types/Support/LazyCollection.php b/types/Support/LazyCollection.php index c9ad444ec154..ef3c5f21578a 100644 --- a/types/Support/LazyCollection.php +++ b/types/Support/LazyCollection.php @@ -547,6 +547,7 @@ assertType('Illuminate\Support\LazyCollection', $collection->make([1])->concat([2])); assertType('Illuminate\Support\LazyCollection', $collection->make(['string'])->concat(['string'])); +assertType('Illuminate\Support\LazyCollection', $collection->make([1])->concat(['string'])); assertType('Illuminate\Support\LazyCollection|int', $collection->make([1])->random(2)); assertType('Illuminate\Support\LazyCollection|string', $collection->make(['string'])->random());