You are here

public function ClassMirror::reflect in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/phpspec/prophecy/src/Prophecy/Doubler/Generator/ClassMirror.php \Prophecy\Doubler\Generator\ClassMirror::reflect()

Reflects provided arguments into class node.

Parameters

ReflectionClass $class:

ReflectionClass[] $interfaces:

Return value

Node\ClassNode

Throws

\Prophecy\Exception\InvalidArgumentException

File

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

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 = null, 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;
}