You are here

private function ClassMirror::reflectMethodToNode 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::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 128

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) {
  $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 (version_compare(PHP_VERSION, '7.0', '>=') && true === $method
    ->hasReturnType()) {
    $node
      ->setReturnType((string) $method
      ->getReturnType());
  }
  if (is_array($params = $method
    ->getParameters()) && count($params)) {
    foreach ($params as $param) {
      $this
        ->reflectArgumentToNode($param, $node);
    }
  }
  $classNode
    ->addMethod($node);
}