Skip to content

Commit abccb4f

Browse files
committed
fix: properly support for phpstan/phpdoc-parser 2
1 parent 17c916c commit abccb4f

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@
150150
"justinrainbow/json-schema": "^5.2.1",
151151
"phpspec/prophecy-phpunit": "^2.0",
152152
"phpstan/extension-installer": "^1.1",
153-
"phpstan/phpdoc-parser": "^1.13",
153+
"phpstan/phpdoc-parser": "^1.13|^2.0",
154154
"phpstan/phpstan": "^1.10",
155155
"phpstan/phpstan-doctrine": "^1.0",
156156
"phpstan/phpstan-phpunit": "^1.0",

src/Metadata/Resource/Factory/PhpDocResourceMetadataCollectionFactory.php

+6-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
use PHPStan\PhpDocParser\Parser\PhpDocParser;
2626
use PHPStan\PhpDocParser\Parser\TokenIterator;
2727
use PHPStan\PhpDocParser\Parser\TypeParser;
28+
use PHPStan\PhpDocParser\ParserConfig;
2829

2930
/**
3031
* Extracts descriptions from PHPDoc.
@@ -58,7 +59,11 @@ public function __construct(private readonly ResourceMetadataCollectionFactoryIn
5859
}
5960
$phpDocParser = null;
6061
$lexer = null;
61-
if (class_exists(PhpDocParser::class)) {
62+
if (class_exists(PhpDocParser::class) && class_exists(ParserConfig::class)) {
63+
$config = new ParserConfig([]);
64+
$phpDocParser = new PhpDocParser($config, new TypeParser($config, new ConstExprParser($config)), new ConstExprParser($config));
65+
$lexer = new Lexer($config);
66+
} elseif (class_exists(PhpDocParser::class)) {
6267
$phpDocParser = new PhpDocParser(new TypeParser(new ConstExprParser()), new ConstExprParser());
6368
$lexer = new Lexer();
6469
}

0 commit comments

Comments
 (0)