function Inspector::assertAll

Same name in other branches
  1. 9 core/lib/Drupal/Component/Assertion/Inspector.php \Drupal\Component\Assertion\Inspector::assertAll()
  2. 8.9.x core/lib/Drupal/Component/Assertion/Inspector.php \Drupal\Component\Assertion\Inspector::assertAll()
  3. 11.x 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

15 calls to Inspector::assertAll()
ComponentPluginManager::alterDefinitions in core/modules/sdc/src/ComponentPluginManager.php
Invokes the hook to alter the definitions if the alter hook is set.
ComponentPluginManager::alterDefinitions in core/lib/Drupal/Core/Theme/ComponentPluginManager.php
Invokes the hook to alter the definitions if the alter hook is set.
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.

... See full list

File

core/lib/Drupal/Component/Assertion/Inspector.php, line 59

Class

Inspector
Generic inspections for the assert() statement.

Namespace

Drupal\Component\Assertion

Code

public static function assertAll(callable $callable, $traversable) {
    if (is_iterable($traversable)) {
        foreach ($traversable as $member) {
            if (!$callable($member)) {
                return FALSE;
            }
        }
        return TRUE;
    }
    return FALSE;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.