You are here

private function ClassCodeGenerator::generateArguments in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/phpspec/prophecy/src/Prophecy/Doubler/Generator/ClassCodeGenerator.php \Prophecy\Doubler\Generator\ClassCodeGenerator::generateArguments()
1 call to ClassCodeGenerator::generateArguments()
ClassCodeGenerator::generateMethod in vendor/phpspec/prophecy/src/Prophecy/Doubler/Generator/ClassCodeGenerator.php

File

vendor/phpspec/prophecy/src/Prophecy/Doubler/Generator/ClassCodeGenerator.php, line 70

Class

ClassCodeGenerator
Class code creator. Generates PHP code for specific class node tree.

Namespace

Prophecy\Doubler\Generator

Code

private function generateArguments(array $arguments) {
  return array_map(function (Node\ArgumentNode $argument) {
    $php = '';
    if ($hint = $argument
      ->getTypeHint()) {
      if ('array' === $hint || 'callable' === $hint) {
        $php .= $hint;
      }
      else {
        $php .= '\\' . $hint;
      }
    }
    $php .= ' ' . ($argument
      ->isPassedByReference() ? '&' : '') . '$' . $argument
      ->getName();
    if ($argument
      ->isOptional()) {
      $php .= ' = ' . var_export($argument
        ->getDefault(), true);
    }
    return $php;
  }, $arguments);
}