コード例 #1
0
 public function store_function(Node\Stmt\Function_ $function)
 {
     $parameters = array_map(function ($param) {
         return array('name' => $param->name, 'default' => !empty($param->default), 'type' => ltrim((string) $param->type, '\\'));
     }, $function->getParams());
     $description = '';
     $return_types = array();
     if ($comments = $function->getAttribute('comments')) {
         $phpdoc = new DocBlock($comments[0]->getText());
         $description = $phpdoc->getShortDescription();
         if ($return = $phpdoc->getTagsByName('return')) {
             $return_types = array_map('ltrim', explode('|', $return[0]->getType()), array('\\'));
         }
         // short circuit @ignore functions
         if ($phpdoc->hasTag('ignore')) {
             return;
         }
     }
     $this->store_model('functions', array('function' => $function->name, 'namespace' => !empty($function->namespacedName) ? implode('\\', array_slice($function->namespacedName->parts, 0, -1)) : '', 'file' => $this->_current_file, 'line' => $function->getLine(), 'description' => $description, 'return_types' => json_encode($return_types), 'parameters' => json_encode($parameters)));
 }
コード例 #2
0
 /**
  * @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];
 }
コード例 #3
0
 /**
  * @return int
  */
 public function getLine()
 {
     return $this->functionAfter->getLine();
 }
コード例 #4
0
 function getStartingLine()
 {
     return $this->function->getLine();
 }
コード例 #5
0
 /**
  * @return int
  */
 public function getLine()
 {
     return $this->functionBefore->getLine();
 }