Assert an array of values is a non-empty, non-associative list of a specific type
Author: PHLAKCreated Jul 3, 2023Updated Oct 15, 2024
Labelsfeature
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.
Source: webmozarts/assert