@@ -31,6 +31,9 @@ class NameResolver extends NodeVisitorAbstract
3131 /** @var bool Whether to replace resolved nodes in place, or to add resolvedNode attributes */
3232 protected $ replaceNodes ;
3333
34+ /** @var bool Whether to parse DocBlock Custom Tags */
35+ protected $ parseDocBlockCustomTags ;
36+
3437 /**
3538 * Constructs a name resolution visitor.
3639 *
@@ -40,6 +43,7 @@ class NameResolver extends NodeVisitorAbstract
4043 * * replaceNodes (default true): Resolved names are replaced in-place. Otherwise, a
4144 * resolvedName attribute is added. (Names that cannot be statically resolved receive a
4245 * namespacedName attribute, as usual.)
46+ * * parseDocBlockCustomTags (default true): Whether to parse DocBlock Custom Tags.
4347 *
4448 * @param ErrorHandler|null $errorHandler Error handler
4549 * @param array $options Options
@@ -49,6 +53,7 @@ public function __construct(ErrorHandler $errorHandler = null, array $options =
4953 $ this ->nameContext = new NameContext ($ errorHandler ?? new ErrorHandler \Throwing ());
5054 $ this ->preserveOriginalNames = $ options ['preserveOriginalNames ' ] ?? false ;
5155 $ this ->replaceNodes = $ options ['replaceNodes ' ] ?? true ;
56+ $ this ->parseDocBlockCustomTags = $ options ['parseDocBlockCustomTags ' ] ?? true ;
5257 }
5358
5459 /**
@@ -148,14 +153,16 @@ public function enterNode(Node $node)
148153 break ;
149154 }
150155
151- if (!($ node ->type instanceof FullyQualified)) {
152- foreach ($ phpDocNode ->getTags () as $ tagValue ) {
153- if ('@ ' === $ tagValue ->name [0 ] && false === strpos ($ tagValue ->name , '@var ' )) {
154- $ customTag = str_replace ('@ ' , '' , $ tagValue ->name );
155- $ type = $ this ->resolveName (new Node \Name ($ customTag ), Use_::TYPE_NORMAL );
156- $ node ->type = $ type ;
156+ if ($ this ->parseDocBlockCustomTags ) {
157+ if (!($ node ->type instanceof FullyQualified)) {
158+ foreach ($ phpDocNode ->getTags () as $ tagValue ) {
159+ if ('@ ' === $ tagValue ->name [0 ] && false === strpos ($ tagValue ->name , '@var ' )) {
160+ $ customTag = str_replace ('@ ' , '' , $ tagValue ->name );
161+ $ type = $ this ->resolveName (new Node \Name ($ customTag ), Use_::TYPE_NORMAL );
162+ $ node ->type = $ type ;
157163
158- break ;
164+ break ;
165+ }
159166 }
160167 }
161168 }
0 commit comments