示例#1
0
 public function __construct($class, $method)
 {
     $this->method = new ReflectionMethod($class, $method);
     $this->class = $parent = $this->method->getDeclaringClass();
     if ($modifiers = $this->method->getModifiers()) {
         $this->modifiers = '<small>' . implode(' ', Reflection::getModifierNames($modifiers)) . '</small> ';
     }
     do {
         if ($parent->hasMethod($method) and $comment = $parent->getMethod($method)->getDocComment()) {
             // Found a description for this method
             break;
         }
     } while ($parent = $parent->getParentClass());
     list($this->description, $tags) = Docs::parse($comment);
     if ($file = $this->class->getFileName()) {
         $this->source = Docs::source($file, $this->method->getStartLine(), $this->method->getEndLine());
     }
     if (isset($tags['param'])) {
         $params = array();
         foreach ($this->method->getParameters() as $i => $param) {
             $param = new Docs_Method_Param(array($this->method->class, $this->method->name), $i);
             if (isset($tags['param'][$i])) {
                 preg_match('/^(\\S+)(?:\\s*(?:\\$' . $param->name . '\\s*)?(.+))?$/', $tags['param'][$i], $matches);
                 $param->type = $matches[1];
                 if (isset($matches[2])) {
                     $param->description = $matches[2];
                 }
             }
             $params[] = $param;
         }
         $this->params = $params;
         unset($tags['param']);
     }
     if (isset($tags['return'])) {
         foreach ($tags['return'] as $return) {
             if (preg_match('/^(\\S*)(?:\\s*(.+?))?$/', $return, $matches)) {
                 $this->return[] = array($matches[1], isset($matches[2]) ? $matches[2] : '');
             }
         }
         unset($tags['return']);
     }
     $this->tags = $tags;
 }