Skip to content

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

Merged
nunomaduro merged 1 commit into
laravel:9.xfrom
joecampo:fix-reject-method-definition
Feb 9, 2022
Merged

[9.x] Fix Support\Collection reject method type definition#40899
nunomaduro merged 1 commit into
laravel:9.xfrom
joecampo:fix-reject-method-definition

Conversation

@joecampo

@joecampo joecampo commented Feb 9, 2022

Copy link
Copy Markdown
Contributor

This PR fixes the type definition for the reject collection method.

The reject method also passes the $key to the closure as the second param.

$collection = collect([1, 2, 3, 4]);
 
$filtered = $collection->reject(function ($value, $key) {
    return $value > 2;
});
 
$filtered->all();
 
// [1, 2]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants