本文整理汇总了PHP中Docs::parse方法的典型用法代码示例。如果您正苦于以下问题:PHP Docs::parse方法的具体用法?PHP Docs::parse怎么用?PHP Docs::parse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Docs
的用法示例。
在下文中一共展示了Docs::parse方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例2: __construct
/**
* Loads a class and uses [reflection](http://php.net/reflection) to parse
* the class. Reads the class modifiers, constants and comment. Parses the
* comment to find the description and tags.
*
* @param string class name
* @return void
*/
public function __construct($class)
{
$this->class = new ReflectionClass($class);
if ($modifiers = $this->class->getModifiers()) {
$this->modifiers = '<small>' . implode(' ', Reflection::getModifierNames($modifiers)) . '</small> ';
}
if ($constants = $this->class->getConstants()) {
foreach ($constants as $name => $value) {
$this->constants[$name] = Docs::debug($value);
}
}
$parent = $this->class;
do {
if ($comment = $parent->getDocComment()) {
// Found a description for this class
break;
}
} while ($parent = $parent->getParentClass());
list($this->description, $this->tags) = Docs::parse($comment);
}
示例3: __construct
public function __construct($class, $property)
{
$property = new ReflectionProperty($class, $property);
list($description, $tags) = Docs::parse($property->getDocComment());
$this->description = $description;
if ($modifiers = $property->getModifiers()) {
$this->modifiers = '<small>' . implode(' ', Reflection::getModifierNames($modifiers)) . '</small> ';
}
if (isset($tags['var'])) {
if (preg_match('/^(\\S*)(?:\\s*(.+?))?$/', $tags['var'][0], $matches)) {
$this->type = $matches[1];
if (isset($matches[2])) {
$this->description = $matches[2];
}
}
}
$this->property = $property;
if ($property->isStatic()) {
$this->value = Docs::debug($property->getValue($class));
}
}