Ejemplo n.º 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);
     }
 }