Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[12.x] Introducing Arr::hasAll #55815

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

Merged
merged 3 commits into from
May 22, 2025

Conversation

devajmeireles
Copy link
Contributor

@devajmeireles devajmeireles commented May 22, 2025

Continuation of #55770, #26543


Previously, I made a new attempt to introduce hasAll due to frequent needs, but for the wrong target, Collections. Following PR #55770 I am now targeting the correct place, the Arr helper.

Example

use Illuminate\Support\Arr;

$array = ['name' => 'Taylor', 'language' => 'php'];

Arr::hasAll($array, ['name']); // ✅
Arr::hasAll($array, ['name', 'language']); // ✅
Arr::hasAll($array, ['name', 'ide']); // ❌, $array does not have all these keys

Although there are manual ways - PHP only, to achieve the same result without relying on the Arr helper, this brings benefits to framework users in favor of having a helper ready to use, without relying on framework macros or PHP codes written when necessary.

Behind the scenes, we ensure that we use the native has, so that dot notation is fully supported in it.

src/Illuminate/Collections/Arr.php Outdated Show resolved Hide resolved
Co-authored-by: Muhammad Rizky Rizaldi  <myquinn489@gmail.com>
@taylorotwell taylorotwell merged commit 87fa7e2 into laravel:12.x May 22, 2025
59 checks passed
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.

3 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.