Skip to content

Commit

Permalink
fix: update stubs
Browse files Browse the repository at this point in the history
  • Loading branch information
canvural committed Nov 9, 2022
1 parent 0936d48 commit 325d2f3
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 3 deletions.
20 changes: 20 additions & 0 deletions stubs/Collection.stub
Expand Up @@ -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<array-key, TCombineValue>|iterable<array-key, TCombineValue> $values
* @return static<array-key, TCombineValue>
*/
public function combine($values) {}
}

/**
Expand All @@ -43,4 +53,14 @@ class LazyCollection implements CanBeEscapedWhenCastToString, Enumerable
* @use \Illuminate\Support\Traits\EnumeratesValues<TKey, TValue>
*/
use EnumeratesValues;

/**
* Create a collection by using this collection for keys and another for its values.
*
* @template TCombineValue
*
* @param \Illuminate\Contracts\Support\Arrayable<array-key, TCombineValue>|iterable<array-key, TCombineValue> $values
* @return static<array-key, TCombineValue>
*/
public function combine($values) {}
}
10 changes: 10 additions & 0 deletions stubs/Enumerable.stub
Expand Up @@ -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<array-key, TCombineValue>|iterable<array-key, TCombineValue> $values
* @return static<array-key, TCombineValue>
*/
public function combine($values);
}
6 changes: 3 additions & 3 deletions tests/Type/data/collection-generic-static-methods.php
Expand Up @@ -74,10 +74,10 @@
assertType('App\UserCollection', $secondCustomEloquentCollection->mergeRecursive([1 => new User()]));
assertType('Illuminate\Support\Collection<string, int>', $items->mergeRecursive(['foo' => 2]));

assertType('Illuminate\Database\Eloquent\Collection<string, int>', $collection->combine([1]));
assertType('App\TransactionCollection<string, int>', $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<int, string>', $items->combine(['foo']));
assertType('Illuminate\Support\Collection<(int|string), string>', $items->combine(['foo']));

assertType('App\User|Illuminate\Database\Eloquent\Collection<int, App\User>|null', $collection->pop(1));
assertType('App\Transaction|App\TransactionCollection<int, App\Transaction>|null', $customEloquentCollection->pop(2));
Expand Down

0 comments on commit 325d2f3

Please sign in to comment.