Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Assert.php

function Assert::isList

Same name in this branch
  1. 11.1.x vendor/phpunit/phpunit/src/Framework/Assert.php \PHPUnit\Framework\Assert::isList()

@psalm-pure @psalm-assert list $array

Parameters

mixed $array:

string $message:

Throws

InvalidArgumentException

1 call to Assert::isList()
Assert::isNonEmptyList in vendor/webmozart/assert/src/Assert.php
@psalm-pure @psalm-assert non-empty-list $array

File

vendor/webmozart/assert/src/Assert.php, line 1823

Class

Assert
Efficient assertions to validate the input/output of your methods.

Namespace

Webmozart\Assert

Code

public static function isList($array, $message = '') {
    if (!\is_array($array)) {
        static::reportInvalidArgument($message ?: 'Expected list - non-associative array.');
    }
    if ($array === \array_values($array)) {
        return;
    }
    $nextKey = -1;
    foreach ($array as $k => $v) {
        if ($k !== ++$nextKey) {
            static::reportInvalidArgument($message ?: 'Expected list - non-associative array.');
        }
    }
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal