diff --git a/src/Illuminate/Database/Eloquent/Collection.php b/src/Illuminate/Database/Eloquent/Collection.php index 62e84780a7d6..022e27dcc6c2 100755 --- a/src/Illuminate/Database/Eloquent/Collection.php +++ b/src/Illuminate/Database/Eloquent/Collection.php @@ -27,7 +27,7 @@ class Collection extends BaseCollection implements QueueableCollection * * @param mixed $key * @param TFindDefault $default - * @return static|TModel|TFindDefault + * @return ($key is (\Illuminate\Contracts\Support\Arrayable|array) ? static : TModel|TFindDefault) */ public function find($key, $default = null) { @@ -470,7 +470,7 @@ public function intersect($items) * * @param (callable(TModel, TKey): mixed)|string|null $key * @param bool $strict - * @return static + * @return static */ public function unique($key = null, $strict = false) { @@ -485,7 +485,7 @@ public function unique($key = null, $strict = false) * Returns only the models from the collection with the specified keys. * * @param array|null $keys - * @return static + * @return static */ public function only($keys) { @@ -502,7 +502,7 @@ public function only($keys) * Returns all models in the collection except the models with specified keys. * * @param array|null $keys - * @return static + * @return static */ public function except($keys) { diff --git a/types/Database/Eloquent/Collection.php b/types/Database/Eloquent/Collection.php index 48933d24eef1..e95003a304fd 100644 --- a/types/Database/Eloquent/Collection.php +++ b/types/Database/Eloquent/Collection.php @@ -5,8 +5,9 @@ $collection = User::all(); assertType('Illuminate\Database\Eloquent\Collection', $collection); -assertType('Illuminate\Database\Eloquent\Collection|User|null', $collection->find(1)); -assertType('Illuminate\Database\Eloquent\Collection|string|User', $collection->find(1, 'string')); +assertType('User|null', $collection->find(1)); +assertType('string|User', $collection->find(1, 'string')); +assertType('Illuminate\Database\Eloquent\Collection', $collection->find([1])); assertType('Illuminate\Database\Eloquent\Collection', $collection->load('string')); assertType('Illuminate\Database\Eloquent\Collection', $collection->load(['string'])); @@ -165,6 +166,9 @@ assertType('Illuminate\Database\Eloquent\Collection', $collection->append('string')); assertType('Illuminate\Database\Eloquent\Collection', $collection->append(['string'])); +assertType('Illuminate\Database\Eloquent\Collection', $collection->unique()); +assertType('Illuminate\Database\Eloquent\Collection', $collection->uniqueStrict()); + assertType('array', $collection->getDictionary()); assertType('array', $collection->getDictionary($collection)); assertType('array', $collection->getDictionary([new User]));