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

Breadcrumb

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

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\Generator

Code

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);
}

API Navigation

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