function ClassMirror::reflectMethodToNode
2 calls to ClassMirror::reflectMethodToNode()
- ClassMirror::reflectClassToNode in vendor/
phpspec/ prophecy/ src/ Prophecy/ Doubler/ Generator/ ClassMirror.php - ClassMirror::reflectInterfaceToNode in vendor/
phpspec/ prophecy/ src/ Prophecy/ Doubler/ Generator/ ClassMirror.php
File
-
vendor/
phpspec/ prophecy/ src/ Prophecy/ Doubler/ Generator/ ClassMirror.php, line 145
Class
- ClassMirror
- Class mirror. Core doubler class. Mirrors specific class and/or interfaces into class node tree.
Namespace
Prophecy\Doubler\GeneratorCode
private function reflectMethodToNode(ReflectionMethod $method, Node\ClassNode $classNode) : void {
$node = new Node\MethodNode($method->getName());
if (true === $method->isProtected()) {
$node->setVisibility('protected');
}
if (true === $method->isStatic()) {
$node->setStatic();
}
if (true === $method->returnsReference()) {
$node->setReturnsReference();
}
if ($method->hasReturnType()) {
\assert($method->getReturnType() !== null);
$returnTypes = $this->getTypeHints($method->getReturnType(), $method->getDeclaringClass(), $method->getReturnType()
->allowsNull());
$node->setReturnTypeNode(new ReturnTypeNode(...$returnTypes));
}
elseif (method_exists($method, 'hasTentativeReturnType') && $method->hasTentativeReturnType()) {
\assert($method->getTentativeReturnType() !== null);
$returnTypes = $this->getTypeHints($method->getTentativeReturnType(), $method->getDeclaringClass(), $method->getTentativeReturnType()
->allowsNull());
$node->setReturnTypeNode(new ReturnTypeNode(...$returnTypes));
}
if (is_array($params = $method->getParameters()) && count($params)) {
foreach ($params as $param) {
$this->reflectArgumentToNode($param, $method->getDeclaringClass(), $node);
}
}
$classNode->addMethod($node);
}