本文整理汇总了PHP中Docs::source方法的典型用法代码示例。如果您正苦于以下问题:PHP Docs::source方法的具体用法?PHP Docs::source怎么用?PHP Docs::source使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Docs
的用法示例。
在下文中一共展示了Docs::source方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
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;
}