1
0
Fork 0

Handle group use declarations in DocBlockParser (#166)

pull/180/head
Felix Becker 2016-11-19 13:04:13 +01:00 committed by GitHub
parent 5213940064
commit 429114ff97
1 changed files with 13 additions and 1 deletions

View File

@ -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 = '';
} }
} }
} }