From 429114ff979386079b0ef441199f649e66918d5e Mon Sep 17 00:00:00 2001 From: Felix Becker Date: Sat, 19 Nov 2016 13:04:13 +0100 Subject: [PATCH] Handle group use declarations in DocBlockParser (#166) --- src/NodeVisitor/DocBlockParser.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/NodeVisitor/DocBlockParser.php b/src/NodeVisitor/DocBlockParser.php index 6a4c77a..78f928e 100644 --- a/src/NodeVisitor/DocBlockParser.php +++ b/src/NodeVisitor/DocBlockParser.php @@ -26,6 +26,13 @@ class DocBlockParser extends NodeVisitorAbstract */ private $namespace; + /** + * Prefix from a parent group use declaration + * + * @var string + */ + private $prefix; + /** * Namespace aliases in the current context * @@ -46,6 +53,7 @@ class DocBlockParser extends NodeVisitorAbstract public function beforeTraverse(array $nodes) { $this->namespace = ''; + $this->prefix = ''; $this->aliases = []; } @@ -53,8 +61,10 @@ class DocBlockParser extends NodeVisitorAbstract { if ($node instanceof Node\Stmt\Namespace_) { $this->namespace = (string)$node->name; + } else if ($node instanceof Node\Stmt\GroupUse) { + $this->prefix = (string)$node->prefix . '\\'; } 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(); if ($docComment === null) { @@ -79,6 +89,8 @@ class DocBlockParser extends NodeVisitorAbstract if ($node instanceof Node\Stmt\Namespace_) { $this->namespace = ''; $this->aliases = []; + } else if ($node instanceof Node\Stmt\GroupUse) { + $this->prefix = ''; } } }