Handle group use declarations in DocBlockParser
parent
5213940064
commit
f4accfbf8d
|
@ -26,6 +26,13 @@ class DocBlockParser extends NodeVisitorAbstract
|
||||||
*/
|
*/
|
||||||
private $namespace;
|
private $namespace;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prefix from a parent group use declaration
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
private $prefix;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Namespace aliases in the current context
|
* Namespace aliases in the current context
|
||||||
*
|
*
|
||||||
|
@ -46,6 +53,7 @@ class DocBlockParser extends NodeVisitorAbstract
|
||||||
public function beforeTraverse(array $nodes)
|
public function beforeTraverse(array $nodes)
|
||||||
{
|
{
|
||||||
$this->namespace = '';
|
$this->namespace = '';
|
||||||
|
$this->prefix = '';
|
||||||
$this->aliases = [];
|
$this->aliases = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,8 +61,10 @@ class DocBlockParser extends NodeVisitorAbstract
|
||||||
{
|
{
|
||||||
if ($node instanceof Node\Stmt\Namespace_) {
|
if ($node instanceof Node\Stmt\Namespace_) {
|
||||||
$this->namespace = (string)$node->name;
|
$this->namespace = (string)$node->name;
|
||||||
|
} else if ($node instanceof Node\Stmt\GroupUse) {
|
||||||
|
$this->prefix = (string)$node->prefix . '\\';
|
||||||
} else if ($node instanceof Node\Stmt\UseUse) {
|
} else if ($node instanceof Node\Stmt\UseUse) {
|
||||||
$this->aliases[(string)$node->name] = $node->alias;
|
$this->aliases[$node->alias] = $this->prefix . (string)$node->name;
|
||||||
}
|
}
|
||||||
$docComment = $node->getDocComment();
|
$docComment = $node->getDocComment();
|
||||||
if ($docComment === null) {
|
if ($docComment === null) {
|
||||||
|
@ -79,6 +89,8 @@ class DocBlockParser extends NodeVisitorAbstract
|
||||||
if ($node instanceof Node\Stmt\Namespace_) {
|
if ($node instanceof Node\Stmt\Namespace_) {
|
||||||
$this->namespace = '';
|
$this->namespace = '';
|
||||||
$this->aliases = [];
|
$this->aliases = [];
|
||||||
|
} else if ($node instanceof Node\Stmt\GroupUse) {
|
||||||
|
$this->prefix = '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue