function Inspector::assertTraversable

Same name in other branches
  1. 9 core/lib/Drupal/Component/Assertion/Inspector.php \Drupal\Component\Assertion\Inspector::assertTraversable()
  2. 8.9.x core/lib/Drupal/Component/Assertion/Inspector.php \Drupal\Component\Assertion\Inspector::assertTraversable()

Asserts argument can be traversed with foreach.

Parameters

mixed $traversable: Variable to be examined.

Return value

bool TRUE if $traversable can be traversed with foreach.

Deprecated

in drupal:10.3.0 and is removed from drupal:11.0.0. Use is_iterable() instead.

See also

https://www.drupal.org/node/3422775

1 call to Inspector::assertTraversable()
InspectorTest::testAssertTraversable in core/tests/Drupal/Tests/Component/Assertion/InspectorTest.php
Tests asserting argument is an array or traversable object.

File

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

Class

Inspector
Generic inspections for the assert() statement.

Namespace

Drupal\Component\Assertion

Code

public static function assertTraversable($traversable) {
    @trigger_error(__METHOD__ . '() is deprecated in drupal:10.3.0 and is removed from drupal:11.0.0. Use is_iterable() instead. See https://www.drupal.org/node/3422775', E_USER_DEPRECATED);
    return is_iterable($traversable);
}

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