Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[9.x] Fix Support\Collection reject method type definition #40899

Merged
merged 1 commit into from
Feb 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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