示例#1
0
 protected function addMethod(\PHPParser_Node_Stmt_ClassMethod $node)
 {
     $method = new MethodReflection($node->name, $node->getLine());
     $method->setModifiers((string) $node->type);
     if ($this->context->getFilter()->acceptMethod($method)) {
         $this->context->getClass()->addMethod($method);
         $method->setByRef((string) $node->byRef);
         foreach ($node->params as $param) {
             $parameter = new ParameterReflection($param->name, $param->getLine());
             $parameter->setModifiers((string) $param->type);
             $parameter->setByRef($param->byRef);
             if ($param->default) {
                 $parameter->setDefault($this->context->getPrettyPrinter()->prettyPrintExpr($param->default));
             }
             if ((string) $param->type) {
                 $parameter->setHint($this->resolveHint(array(array((string) $param->type, false))));
             }
             $method->addParameter($parameter);
         }
         $comment = $this->context->getDocBlockParser()->parse($node->getDocComment(), $this->context, $method);
         $method->setDocComment($node->getDocComment());
         $method->setShortDesc($comment->getShortDesc());
         $method->setLongDesc($comment->getLongDesc());
         if (!($errors = $comment->getErrors())) {
             $errors = $this->updateMethodParametersFromTags($method, $comment->getTag('param'));
             if ($tag = $comment->getTag('return')) {
                 $method->setHint($this->resolveHint($tag[0][0]));
                 $method->setHintDesc($tag[0][1]);
             }
             $method->setExceptions($comment->getTag('throws'));
             $method->setTags($comment->getOtherTags());
         }
         $this->context->addErrors((string) $method, $node->getLine(), $errors);
     }
 }
示例#2
0
 /**
  * @param \PHPParser_Node_Stmt_ClassMethod $node
  */
 private function processMethod(\PHPParser_Node_Stmt_ClassMethod $node)
 {
     /** @var $method \TheSeer\phpDox\Collector\MethodObject */
     $method = $this->unit->addMethod($node->name);
     $method->setStartLine($node->getAttribute('startLine'));
     $method->setEndLine($node->getAttribute('endLine'));
     $method->setAbstract($node->isAbstract());
     $method->setFinal($node->isFinal());
     $method->setStatic($node->isStatic());
     $visibility = 'public';
     if ($node->isPrivate()) {
         $visibility = 'private';
     } elseif ($node->isProtected()) {
         $visibility = 'protected';
     }
     $method->setVisibility($visibility);
     $docComment = $node->getDocComment();
     if ($docComment !== NULL) {
         $block = $this->dockblocParser->parse($docComment, $this->aliasMap);
         $method->setDocBlock($block);
     }
     $this->processMethodParams($method, $node->params);
     if ($node->stmts) {
         $this->processInlineComments($method, $node->stmts);
     }
 }