Skip to content

Commit

Permalink
Merge pull request #40899 from joecampo/fix-reject-method-definition
Browse files Browse the repository at this point in the history
[9.x] Fix Support\Collection reject method type definition
  • Loading branch information
nunomaduro authored Feb 9, 2022
2 parents afeb58d + 45e7973 commit 039cde6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/Illuminate/Collections/Enumerable.php
Original file line number Diff line number Diff line change
Expand Up @@ -1099,7 +1099,7 @@ public function pluck($value, $key = null);
/**
* Create a collection of all elements that do not pass a given truth test.
*
* @param (callable(TValue): bool)|bool $callback
* @param (callable(TValue, TKey): bool)|bool $callback
* @return static
*/
public function reject($callback = true);
Expand Down
2 changes: 1 addition & 1 deletion src/Illuminate/Collections/Traits/EnumeratesValues.php
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,7 @@ class_basename(static::class), gettype($result)
/**
* Create a collection of all elements that do not pass a given truth test.
*
* @param (callable(TValue): bool)|bool $callback
* @param (callable(TValue, TKey): bool)|bool $callback
* @return static
*/
public function reject($callback = true)
Expand Down
6 changes: 6 additions & 0 deletions types/Support/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -735,6 +735,12 @@

return true;
}));
assertType('Illuminate\Support\Collection<int, User>', $collection->reject(function ($user, $int) {
assertType('User', $user);
assertType('int', $int);

return true;
}));

assertType('Illuminate\Support\Collection<int, User>', $collection->unique());
assertType('Illuminate\Support\Collection<int, User>', $collection->unique(function ($user, $int) {
Expand Down

0 comments on commit 039cde6

Please sign in to comment.