You are here

private function ClassMirror::reflectArgumentToNode 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::reflectArgumentToNode()
1 call to ClassMirror::reflectArgumentToNode()
ClassMirror::reflectMethodToNode in vendor/phpspec/prophecy/src/Prophecy/Doubler/Generator/ClassMirror.php

File

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

Class

ClassMirror
Class mirror. Core doubler class. Mirrors specific class and/or interfaces into class node tree.

Namespace

Prophecy\Doubler\Generator

Code

private function reflectArgumentToNode(ReflectionParameter $parameter, Node\MethodNode $methodNode) {
  $name = $parameter
    ->getName() == '...' ? '__dot_dot_dot__' : $parameter
    ->getName();
  $node = new Node\ArgumentNode($name);
  $typeHint = $this
    ->getTypeHint($parameter);
  $node
    ->setTypeHint($typeHint);
  if (true === $parameter
    ->isDefaultValueAvailable()) {
    $node
      ->setDefault($parameter
      ->getDefaultValue());
  }
  elseif (true === $parameter
    ->isOptional() || true === $parameter
    ->allowsNull() && $typeHint) {
    $node
      ->setDefault(null);
  }
  if (true === $parameter
    ->isPassedByReference()) {
    $node
      ->setAsPassedByReference();
  }
  $methodNode
    ->addArgument($node);
}