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

Breadcrumb

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

function CodeUnit::ensureUserDefinedClass

@psalm-param class-string $className

Throws

InvalidCodeUnitException

2 calls to CodeUnit::ensureUserDefinedClass()
CodeUnit::forClass in vendor/sebastian/code-unit/src/CodeUnit.php
@psalm-param class-string $className
CodeUnit::forClassMethod in vendor/sebastian/code-unit/src/CodeUnit.php
@psalm-param class-string $className

File

vendor/sebastian/code-unit/src/CodeUnit.php, line 301

Class

CodeUnit
@psalm-immutable

Namespace

SebastianBergmann\CodeUnit

Code

private static function ensureUserDefinedClass(string $className) : void {
    try {
        $reflector = new ReflectionClass($className);
        if ($reflector->isInterface()) {
            throw new InvalidCodeUnitException(sprintf('"%s" is an interface and not a class', $className));
        }
        if ($reflector->isTrait()) {
            throw new InvalidCodeUnitException(sprintf('"%s" is a trait and not a class', $className));
        }
        if (!$reflector->isUserDefined()) {
            throw new InvalidCodeUnitException(sprintf('"%s" is not a user-defined class', $className));
        }
        // @codeCoverageIgnoreStart
    } catch (\ReflectionException $e) {
        throw new ReflectionException($e->getMessage(), $e->getCode(), $e);
    }
    // @codeCoverageIgnoreEnd
}

API Navigation

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