function Inspector::assertStrictArray
Same name in other branches
- 8.9.x core/lib/Drupal/Component/Assertion/Inspector.php \Drupal\Component\Assertion\Inspector::assertStrictArray()
- 10 core/lib/Drupal/Component/Assertion/Inspector.php \Drupal\Component\Assertion\Inspector::assertStrictArray()
- 11.x core/lib/Drupal/Component/Assertion/Inspector.php \Drupal\Component\Assertion\Inspector::assertStrictArray()
Asserts that the array is strict.
What PHP calls arrays are more formally called maps in most other programming languages. A map is a datatype that associates values to keys. The term 'strict array' here refers to a 0-indexed array in the classic sense found in programming languages other than PHP.
Parameters
mixed $array: Variable to be examined.
Return value
bool TRUE if $traversable is a 0-indexed array.
See also
http://php.net/manual/language.types.array.php
1 call to Inspector::assertStrictArray()
- InspectorTest::testAssertStrictArray in core/
tests/ Drupal/ Tests/ Component/ Assertion/ InspectorTest.php - Tests asserting array is 0-indexed - the strict definition of array.
File
-
core/
lib/ Drupal/ Component/ Assertion/ Inspector.php, line 148
Class
Namespace
Drupal\Component\AssertionCode
public static function assertStrictArray($array) {
if (!is_array($array)) {
return FALSE;
}
$i = 0;
foreach (array_keys($array) as $key) {
if ($i !== $key) {
return FALSE;
}
$i++;
}
return TRUE;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.