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

Breadcrumb

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

function Assert::inArray

Does strict comparison, so Assert::inArray(3, ['3']) does not pass the assertion.

@psalm-pure

Parameters

mixed $value:

array $values:

string $message:

Throws

InvalidArgumentException

1 call to Assert::inArray()
Assert::oneOf in vendor/webmozart/assert/src/Assert.php
A more human-readable alias of Assert::inArray().

File

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

Class

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

Namespace

Webmozart\Assert

Code

public static function inArray($value, array $values, $message = '') {
    if (!\in_array($value, $values, true)) {
        static::reportInvalidArgument(\sprintf($message ?: 'Expected one of: %2$s. Got: %s', static::valueToString($value), \implode(', ', \array_map(array(
            static::class,
            'valueToString',
        ), $values))));
    }
}

API Navigation

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