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\GeneratorCode
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;
}