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

Breadcrumb

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

function Assert::assertInstanceOf

Asserts that a variable is of a given type.

@psalm-template ExpectedType of object

@psalm-param class-string<ExpectedType> $expected

@psalm-assert =ExpectedType $actual

Throws

Exception

ExpectationFailedException

UnknownClassOrInterfaceException

1 call to Assert::assertInstanceOf()
Functions.php in vendor/phpunit/phpunit/src/Framework/Assert/Functions.php

File

vendor/phpunit/phpunit/src/Framework/Assert.php, line 1024

Class

Assert
@no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit

Namespace

PHPUnit\Framework

Code

public static final function assertInstanceOf(string $expected, mixed $actual, string $message = '') : void {
    if (!class_exists($expected) && !interface_exists($expected)) {
        throw new UnknownClassOrInterfaceException($expected);
    }
    static::assertThat($actual, new IsInstanceOf($expected), $message);
}
RSS feed
Powered by Drupal