Skip to content

Assert an array of values is a non-empty, non-associative list of a specific type #288

@PHLAK

Description

@PHLAK

I find myself repeating the following assertions often to ensure an array of values is a non-associative list, not empty and all values are of a particular type.

Assert::isNonEmptyList($someValues);
Assert::allIsInstanceOf($someValues, SomeClass::class);

Would there be interest in adding methods to unify this use case to a single method? For example.

Assert::listIsInstanceOf($someValues, SomeClass::class);

// and

Assert::nonEmptyListIsInstanceOf($someValues, SomeClass::class);

If so, I'd gladly work on a PR for this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions