2121use PHPStan \PhpDocParser \Parser \PhpDocParser ;
2222use PHPStan \PhpDocParser \Parser \TokenIterator ;
2323use PHPStan \PhpDocParser \Parser \TypeParser ;
24+ use PHPStan \PhpDocParser \ParserConfig ;
2425
2526/**
2627 * Common functionality around doc block parsing and writing.
@@ -36,13 +37,27 @@ trait DocBlockTrait {
3637 protected static function getValueNode (string $ tagName , string $ tagComment ): PhpDocTagValueNode {
3738 static $ phpDocParser ;
3839 if (!$ phpDocParser ) {
39- $ constExprParser = new ConstExprParser ();
40- $ phpDocParser = new PhpDocParser (new TypeParser ($ constExprParser ), $ constExprParser );
40+ if (class_exists (ParserConfig::class)) {
41+ $ config = new ParserConfig (usedAttributes: []);
42+ $ constExprParser = new ConstExprParser ($ config );
43+ $ phpDocParser = new PhpDocParser ($ config , new TypeParser ($ config , $ constExprParser ), $ constExprParser );
44+ } else {
45+ /** @phpstan-ignore-next-line */
46+ $ constExprParser = new ConstExprParser ();
47+ /** @phpstan-ignore-next-line */
48+ $ phpDocParser = new PhpDocParser (new TypeParser ($ constExprParser ), $ constExprParser );
49+ }
4150 }
4251
4352 static $ phpDocLexer ;
4453 if (!$ phpDocLexer ) {
45- $ phpDocLexer = new Lexer ();
54+ if (class_exists (ParserConfig::class)) {
55+ $ config = new ParserConfig (usedAttributes: []);
56+ $ phpDocLexer = new Lexer ($ config );
57+ } else {
58+ /** @phpstan-ignore-next-line */
59+ $ phpDocLexer = new Lexer ();
60+ }
4661 }
4762
4863 return $ phpDocParser ->parseTagValue (new TokenIterator ($ phpDocLexer ->tokenize ($ tagComment )), $ tagName );
0 commit comments