Skip to content

Conversation

@junaidbinfarooq
Copy link

  • Adds the assertion to assert if all the provided keys exist in the given array

Copy link
Collaborator

@shadowhand shadowhand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this idea, but a couple of things:

  1. It needs to be rebased to current master.
  2. Return type needs to be added.
  3. The type needs to be changed.
  4. The mixin needs to be regenerated with php bin/generate.php.

@junaidbinfarooq junaidbinfarooq force-pushed the patch-1 branch 2 times, most recently from f3066ad to 9bd7b44 Compare January 4, 2026 09:58
@junaidbinfarooq
Copy link
Author

I like this idea, but a couple of things:

  1. It needs to be rebased to current master.
  2. Return type needs to be added.
  3. The type needs to be changed.
  4. The mixin needs to be regenerated with php bin/generate.php.

@shadowhand
Done. Please re-review the changes.

- Adds the assertion to assert if all the provided keys exist in the given array
- Adds types
- Regenerates mixin
*
* @throws InvalidArgumentException
*/
public static function KeysExist(mixed $array, array $keys, string $message = ''): void
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be camelCase, keysExist.

static::isArray($array);

foreach ($keys as $key) {
static::keyExists($array, $key, $message ?: 'Expected the key %s to exist.',);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
static::keyExists($array, $key, $message ?: 'Expected the key %s to exist.',);
static::keyExists($array, $key, $message);

@shadowhand
Copy link
Collaborator

shadowhand commented Jan 5, 2026

@junaidbinfarooq need to add unit tests as well, and correct existing test failures.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants