We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Laravel 5.7.13 introduced an alias (#26376), named some, for the contains method on the Illuminate\Support\Collection class.
5.7.13
alias
some
contains
Illuminate\Support\Collection
Although contains is working , some is not.
For instance, this is the actual behavior using contains:
$collection = collect(['name' => 'Desk', 'price' => 100]); $collection->contains('New York'); // false
However, when using some, the output isn't the same as contains:
$collection = collect(['name' => 'Desk', 'price' => 100]); $collection->some('New York'); // true
Another example (same as from the Laravel documentation):
$collection = collect([1, 2, 3, 4, 5]); $collection->contains(function ($value, $key) { return $value > 5; }); // false
Now using some:
$collection = collect([1, 2, 3, 4, 5]); $collection->some(function ($value, $key) { return $value > 5; }); // PHP Warning: explode() expects parameter 2 to be string, object given ...
I wrote a testSome() test using the same logic for the testContains() and it failed.
testSome()
testContains()
I believe the reason for such a odd behavior is because of the func_num_args() call used by the contains method.
func_num_args()
Anyways, I'm going to submit a PR that tries to handle that situation.
The text was updated successfully, but these errors were encountered:
Gonna close this as your PR was merged.
Sorry, something went wrong.
No branches or pull requests
Laravel
5.7.13
introduced analias
(#26376), namedsome
, for thecontains
method on theIlluminate\Support\Collection
class.Although
contains
is working ,some
is not.For instance, this is the actual behavior using
contains
:However, when using
some
, the output isn't the same ascontains
:Another example (same as from the Laravel documentation):
Now using
some
:I wrote a
testSome()
test using the same logic for thetestContains()
and it failed.I believe the reason for such a odd behavior is because of the
func_num_args()
call used by thecontains
method.Anyways, I'm going to submit a PR that tries to handle that situation.
The text was updated successfully, but these errors were encountered: