From 325d2f377f17d99529ea76833479e6ab6d6ff64c Mon Sep 17 00:00:00 2001 From: Can Vural Date: Wed, 9 Nov 2022 14:14:14 +0100 Subject: [PATCH] fix: update stubs --- stubs/Collection.stub | 20 +++++++++++++++++++ stubs/Enumerable.stub | 10 ++++++++++ .../collection-generic-static-methods.php | 6 +++--- 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/stubs/Collection.stub b/stubs/Collection.stub index d3ac9b1ed..5f3d94f09 100644 --- a/stubs/Collection.stub +++ b/stubs/Collection.stub @@ -29,6 +29,16 @@ class Collection implements ArrayAccess, CanBeEscapedWhenCastToString, Enumerabl * @throws \InvalidArgumentException */ public function random($number = null) {} + + /** + * Create a collection by using this collection for keys and another for its values. + * + * @template TCombineValue + * + * @param \Illuminate\Contracts\Support\Arrayable|iterable $values + * @return static + */ + public function combine($values) {} } /** @@ -43,4 +53,14 @@ class LazyCollection implements CanBeEscapedWhenCastToString, Enumerable * @use \Illuminate\Support\Traits\EnumeratesValues */ use EnumeratesValues; + + /** + * Create a collection by using this collection for keys and another for its values. + * + * @template TCombineValue + * + * @param \Illuminate\Contracts\Support\Arrayable|iterable $values + * @return static + */ + public function combine($values) {} } diff --git a/stubs/Enumerable.stub b/stubs/Enumerable.stub index 7f2f2b000..0d63c8b1b 100644 --- a/stubs/Enumerable.stub +++ b/stubs/Enumerable.stub @@ -19,4 +19,14 @@ interface Enumerable extends \Countable, \IteratorAggregate, \JsonSerializable * @throws \InvalidArgumentException */ public function random($number = null) {} + + /** + * Create a collection by using this collection for keys and another for its values. + * + * @template TCombineValue + * + * @param \Illuminate\Contracts\Support\Arrayable|iterable $values + * @return static + */ + public function combine($values); } diff --git a/tests/Type/data/collection-generic-static-methods.php b/tests/Type/data/collection-generic-static-methods.php index 99bd1a8bf..498b20a1c 100644 --- a/tests/Type/data/collection-generic-static-methods.php +++ b/tests/Type/data/collection-generic-static-methods.php @@ -74,10 +74,10 @@ assertType('App\UserCollection', $secondCustomEloquentCollection->mergeRecursive([1 => new User()])); assertType('Illuminate\Support\Collection', $items->mergeRecursive(['foo' => 2])); -assertType('Illuminate\Database\Eloquent\Collection', $collection->combine([1])); -assertType('App\TransactionCollection', $customEloquentCollection->combine([1])); +assertType('Illuminate\Database\Eloquent\Collection<(int|string), int>', $collection->combine([1])); +assertType('App\TransactionCollection<(int|string), int>', $customEloquentCollection->combine([1])); assertType('App\UserCollection', $secondCustomEloquentCollection->combine([1])); -assertType('Illuminate\Support\Collection', $items->combine(['foo'])); +assertType('Illuminate\Support\Collection<(int|string), string>', $items->combine(['foo'])); assertType('App\User|Illuminate\Database\Eloquent\Collection|null', $collection->pop(1)); assertType('App\Transaction|App\TransactionCollection|null', $customEloquentCollection->pop(2));