Skip to content

Commit 5a02c2f

Browse files
committed
add support for phpstan/phpdoc-parser 2
1 parent 1fb5ba8 commit 5a02c2f

File tree

4 files changed

+13
-5
lines changed

4 files changed

+13
-5
lines changed

composer-require-checker.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"symbol-whitelist" : [
33
"null", "true", "false",
44
"static", "self", "parent",
5-
"array", "string", "int", "float", "bool", "iterable", "callable", "void", "object", "XSLTProcessor",
5+
"array", "string", "int", "float", "bool", "iterable", "callable", "void", "object", "XSLTProcessor", "PHPStan\\PhpDocParser\\ParserConfig",
66
"T_NAME_QUALIFIED", "T_NAME_FULLY_QUALIFIED"
77
],
88
"php-core-extensions" : [

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"require": {
1313
"php": "^7.3 || ^8.0",
1414
"phpdocumentor/reflection-common": "^2.0",
15-
"phpstan/phpdoc-parser": "^1.18",
15+
"phpstan/phpdoc-parser": "^1.18|^2.0",
1616
"doctrine/deprecations": "^1.0"
1717
},
1818
"require-dev": {

composer.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/TypeResolver.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@
9898
use PHPStan\PhpDocParser\Parser\ParserException;
9999
use PHPStan\PhpDocParser\Parser\TokenIterator;
100100
use PHPStan\PhpDocParser\Parser\TypeParser;
101+
use PHPStan\PhpDocParser\ParserConfig;
101102
use RuntimeException;
102103

103104
use function array_filter;
@@ -189,8 +190,15 @@ final class TypeResolver
189190
public function __construct(?FqsenResolver $fqsenResolver = null)
190191
{
191192
$this->fqsenResolver = $fqsenResolver ?: new FqsenResolver();
192-
$this->typeParser = new TypeParser(new ConstExprParser());
193-
$this->lexer = new Lexer();
193+
194+
if (class_exists(ParserConfig::class)) {
195+
$parserConfig = new ParserConfig([]);
196+
$this->typeParser = new TypeParser($parserConfig, new ConstExprParser($parserConfig));
197+
$this->lexer = new Lexer($parserConfig);
198+
} else {
199+
$this->typeParser = new TypeParser(new ConstExprParser());
200+
$this->lexer = new Lexer();
201+
}
194202
}
195203

196204
/**

0 commit comments

Comments
 (0)