public static function Inspector::assertAll in Drupal 10
Same name and namespace in other branches
- 8 core/lib/Drupal/Component/Assertion/Inspector.php \Drupal\Component\Assertion\Inspector::assertAll()
- 9 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
6 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.
- HTMLRestrictions::applyOperation in core/
modules/ ckeditor5/ src/ HTMLRestrictions.php - Applies an operation (difference/intersection/union) with wildcard support.
- HTMLRestrictions::validateAllowedRestrictionsPhase4 in core/
modules/ ckeditor5/ src/ HTMLRestrictions.php - Validates allowed elements — phase 4: HTML tag attr restriction values.
- Link::__construct in core/
modules/ jsonapi/ src/ JsonApiResource/ Link.php - JSON:API Link constructor.
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;
}