public static function Inspector::assertAll in Drupal 9
Same name and namespace in other branches
- 8 core/lib/Drupal/Component/Assertion/Inspector.php \Drupal\Component\Assertion\Inspector::assertAll()
- 10 core/lib/Drupal/Component/Assertion/Inspector.php \Drupal\Component\Assertion\Inspector::assertAll()
Asserts callback returns TRUE for each member of a traversable.
This is less memory intensive than using array_filter() to build a second array and then comparing the arrays. Many of the other functions in this collection alias this function passing a specific callback to make the code more readable.
Parameters
callable $callable: Callback function.
mixed $traversable: Variable to be examined.
Return value
bool TRUE if $traversable can be traversed and $callable returns TRUE on all members.
See also
http://php.net/manual/language.types.callable.php
11 calls to Inspector::assertAll()
- EntityResourceTestBase::assertPatchProtectedFieldNamesStructure in core/
modules/ rest/ tests/ src/ Functional/ EntityResource/ EntityResourceTestBase.php - Asserts structure of $patchProtectedFieldNames.
- ErrorCollection::__construct in core/
modules/ jsonapi/ src/ JsonApiResource/ ErrorCollection.php - Instantiates an ErrorCollection object.
- Inspector::assertAllArrays in core/
lib/ Drupal/ Component/ Assertion/ Inspector.php - Asserts that all members are arrays.
- Inspector::assertAllCallable in core/
lib/ Drupal/ Component/ Assertion/ Inspector.php - Asserts that all members are callable.
- Inspector::assertAllFloat in core/
lib/ Drupal/ Component/ Assertion/ Inspector.php - Asserts that all members are float values.
File
- core/
lib/ Drupal/ Component/ Assertion/ Inspector.php, line 53
Class
Namespace
Drupal\Component\AssertionCode
public static function assertAll(callable $callable, $traversable) {
if (static::assertTraversable($traversable)) {
foreach ($traversable as $member) {
if (!$callable($member)) {
return FALSE;
}
}
return TRUE;
}
return FALSE;
}