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

Breadcrumb

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

function ClassMirror::reflect

Reflects provided arguments into class node.

Parameters

ReflectionClass<object>|null $class:

ReflectionClass<object>[] $interfaces:

Return value

Node\ClassNode

File

vendor/phpspec/prophecy/src/Prophecy/Doubler/Generator/ClassMirror.php, line 53

Class

ClassMirror
Class mirror. Core doubler class. Mirrors specific class and/or interfaces into class node tree.

Namespace

Prophecy\Doubler\Generator

Code

public function reflect(?ReflectionClass $class, array $interfaces) {
    $node = new Node\ClassNode();
    if (null !== $class) {
        if (true === $class->isInterface()) {
            throw new InvalidArgumentException(sprintf("Could not reflect %s as a class, because it\n" . "is interface - use the second argument instead.", $class->getName()));
        }
        $this->reflectClassToNode($class, $node);
    }
    foreach ($interfaces as $interface) {
        if (!$interface instanceof ReflectionClass) {
            throw new InvalidArgumentException(sprintf("[ReflectionClass \$interface1 [, ReflectionClass \$interface2]] array expected as\n" . "a second argument to `ClassMirror::reflect(...)`, but got %s.", is_object($interface) ? get_class($interface) . ' class' : gettype($interface)));
        }
        if (false === $interface->isInterface()) {
            throw new InvalidArgumentException(sprintf("Could not reflect %s as an interface, because it\n" . "is class - use the first argument instead.", $interface->getName()));
        }
        $this->reflectInterfaceToNode($interface, $node);
    }
    $node->addInterface('Prophecy\\Doubler\\Generator\\ReflectionInterface');
    return $node;
}

API Navigation

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