Adds assertion to check all keys exist in an array#282
Open
junaidbinfarooq wants to merge 1 commit intowebmozarts:masterfrom
Open
Adds assertion to check all keys exist in an array#282junaidbinfarooq wants to merge 1 commit intowebmozarts:masterfrom
junaidbinfarooq wants to merge 1 commit intowebmozarts:masterfrom
Conversation
junaidbinfarooq
commented
Jan 3, 2023
- Adds the assertion to assert if all the provided keys exist in the given array
zerkms
reviewed
Jan 3, 2023
shadowhand
requested changes
Nov 24, 2025
Collaborator
shadowhand
left a comment
There was a problem hiding this comment.
I like this idea, but a couple of things:
- It needs to be rebased to current
master. - Return type needs to be added.
- The type needs to be changed.
- The mixin needs to be regenerated with
php bin/generate.php.
f3066ad to
9bd7b44
Compare
Author
@shadowhand |
shadowhand
requested changes
Jan 5, 2026
shadowhand
reviewed
Jan 5, 2026
- Adds the assertion to assert if all the provided keys exist in the given array - Adds types - Regenerates mixin
9bd7b44 to
1736b76
Compare
shadowhand
requested changes
Jan 5, 2026
| * | ||
| * @throws InvalidArgumentException | ||
| */ | ||
| public static function KeysExist(mixed $array, array $keys, string $message = ''): void |
Collaborator
There was a problem hiding this comment.
Should be camelCase, keysExist.
| static::isArray($array); | ||
|
|
||
| foreach ($keys as $key) { | ||
| static::keyExists($array, $key, $message ?: 'Expected the key %s to exist.',); |
Collaborator
There was a problem hiding this comment.
Suggested change
| static::keyExists($array, $key, $message ?: 'Expected the key %s to exist.',); | |
| static::keyExists($array, $key, $message); |
Collaborator
|
@junaidbinfarooq need to add unit tests as well, and correct existing test failures. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.