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) = Kodoc::parse($comment); if ($file = $this->class->getFileName()) { $this->source = Kodoc::source($file, $this->method->getStartLine(), $this->method->getEndLine()); } if (isset($tags['param'])) { $params = array(); foreach ($this->method->getParameters() as $i => $param) { if (isset($tags['param'][$i])) { if ($param->isDefaultValueAvailable()) { $name = $param->name . ' = ' . var_export($param->getDefaultValue(), TRUE); } else { $name = $param->name; } preg_match('/^(\\S+)(?:\\s*(.+))?$/', $tags['param'][$i], $matches); $verbose = '<small>' . $matches[1] . '</small> '; if (isset($matches[2])) { $verbose .= '<span class="param" title="' . $matches[2] . '">$' . $name . '</span>'; } else { $verbose .= '<span class="param">$' . $name . '</span>'; } $params[] = $verbose; } } $this->params = implode(', ', $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; }
public function __construct($class, $method) { $method = new ReflectionMethod($class, $method); $this->name = $method->name; $class = $parent = $method->getDeclaringClass(); if ($modifiers = $method->getModifiers()) { $this->modifiers = '<small>' . implode(' ', Reflection::getModifierNames($modifiers)) . '</small> '; } $comment = ''; do { if ($parent->hasMethod($this->name)) { $comment = $parent->getMethod($this->name)->getDocComment(); // Found a description for this method break; } } while ($parent = $parent->getParentClass()); list($this->description, $tags) = Kodoc::parse($comment); if ($file = $class->getFileName()) { $this->source = Kodoc::source($file, $method->getStartLine(), $method->getEndLine()); } if (isset($tags['param'])) { $params = array(); foreach ($method->getParameters() as $i => $param) { $param = new Kodoc_Method_Param(array($method->class, $method->name), $i); if (isset($tags['param'][$i])) { if (preg_match('/^(\\S*)\\s*(\\$\\w+)?(?:\\s*(.+?))?$/', $tags['param'][$i], $matches)) { $param->type = $matches[1]; $param->description = arr::get($matches, 3); } } $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; }