/**
  * @param Function_|ClassMethod $node
  */
 function importReturnValue($node)
 {
     $comment = $node->getDocComment();
     if ($comment) {
         $str = $comment->getText();
         try {
             $docBlock = $this->factory->create($str, $this->getDocBlockContext());
             $return = $docBlock->getTagsByName("return");
             if (count($return)) {
                 $returnType = $return[0]->getType();
                 $types = explode("|", $returnType);
                 if (count($types) > 1) {
                     $node->setAttribute("namespacedReturn", \Guardrail\Scope::MIXED_TYPE);
                 } else {
                     foreach ($types as $type) {
                         if ($type[0] == '\\') {
                             $type = substr($type, 1);
                         }
                         $node->setAttribute("namespacedReturn", strval($type));
                         return;
                     }
                 }
             }
         } catch (\InvalidArgumentException $e) {
             // Skip it.
         }
     }
 }
 /**
  * @param Node\Stmt\Function_ $node
  */
 protected function parseFunctionNode(Node\Stmt\Function_ $node)
 {
     $parameters = [];
     /** @var \PhpParser\Node\Param $param */
     foreach ($node->params as $param) {
         $parameters[] = ['name' => $param->name, 'type' => (string) $param->type, 'isReference' => $param->byRef, 'isVariadic' => $param->variadic, 'isOptional' => $param->default ? true : false];
     }
     $this->globalFunctions[] = ['name' => $node->name, 'startLine' => $node->getLine(), 'returnType' => $node->getReturnType(), 'parameters' => $parameters, 'docComment' => $node->getDocComment() ? $node->getDocComment()->getText() : null];
 }
 public function addFunction(FunctionNode $node)
 {
     $function = new ReflectionFunction((string) $node->namespacedName);
     $function->setFilename((string) $this->context->getFilePath());
     $function->setStartLine((int) $node->getAttribute('startLine'));
     $function->setEndLine((int) $node->getAttribute('endLine'));
     $function->setAliases($this->context->getAliases());
     $function->setDocComment((string) $node->getDocComment());
     $this->addFunctionLikeParameters($function, $node->params);
     $this->context->enterReflection($function);
     $this->context->enterFunctionLike($function);
     return $function;
 }