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

Breadcrumb

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

function Assert::string

@psalm-pure @psalm-assert string $value

Parameters

mixed $value:

string $message:

Throws

InvalidArgumentException

16 calls to Assert::string()
Assert::alpha in vendor/webmozart/assert/src/Assert.php
@psalm-pure
Assert::fileExists in vendor/webmozart/assert/src/Assert.php
Will also pass if $value is a directory, use Assert::file() instead if you need to be sure it is a file.
Assert::isAnyOf in vendor/webmozart/assert/src/Assert.php
@psalm-pure @psalm-param array<class-string> $classes
Assert::isAOf in vendor/webmozart/assert/src/Assert.php
@psalm-pure @psalm-template ExpectedType of object @psalm-param class-string<ExpectedType> $class @psalm-assert ExpectedType|class-string<ExpectedType> $value
Assert::isNotA in vendor/webmozart/assert/src/Assert.php
@psalm-pure @psalm-template UnexpectedType of object @psalm-param class-string<UnexpectedType> $class @psalm-assert !UnexpectedType $value @psalm-assert !class-string<UnexpectedType> $value

... See full list

File

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

Class

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

Namespace

Webmozart\Assert

Code

public static function string($value, $message = '') {
    if (!\is_string($value)) {
        static::reportInvalidArgument(\sprintf($message ?: 'Expected a string. Got: %s', static::typeToString($value)));
    }
}
RSS feed
Powered by Drupal