diff --git a/composer-require-checker.json b/composer-require-checker.json
index 137522d..e8eb031 100644
--- a/composer-require-checker.json
+++ b/composer-require-checker.json
@@ -2,7 +2,7 @@
"symbol-whitelist" : [
"null", "true", "false",
"static", "self", "parent",
- "array", "string", "int", "float", "bool", "iterable", "callable", "void", "object", "XSLTProcessor",
+ "array", "string", "int", "float", "bool", "iterable", "callable", "void", "object", "XSLTProcessor", "PHPStan\\PhpDocParser\\ParserConfig",
"T_NAME_QUALIFIED", "T_NAME_FULLY_QUALIFIED"
],
"php-core-extensions" : [
diff --git a/composer.json b/composer.json
index 13045ef..5c280e3 100644
--- a/composer.json
+++ b/composer.json
@@ -12,7 +12,7 @@
"require": {
"php": "^7.3 || ^8.0",
"phpdocumentor/reflection-common": "^2.0",
- "phpstan/phpdoc-parser": "^1.18",
+ "phpstan/phpdoc-parser": "^1.18|^2.0",
"doctrine/deprecations": "^1.0"
},
"require-dev": {
diff --git a/composer.lock b/composer.lock
index eec91a0..e05c360 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
- "content-hash": "2d7307b14c95f0d2eb310a28ae73dae0",
+ "content-hash": "142e0ed9e505415b092f3963da4939cc",
"packages": [
{
"name": "doctrine/deprecations",
diff --git a/phpstan.neon b/phpstan.neon
index 6c6f50b..e53acac 100644
--- a/phpstan.neon
+++ b/phpstan.neon
@@ -7,3 +7,20 @@ parameters:
- tests/benchmark/Assets/*
paths:
- src
+ ignoreErrors:
+ -
+ message: "#^Parameter \\#1 \\$constExprParser of class PHPStan\\\\PhpDocParser\\\\Parser\\\\TypeParser constructor expects PHPStan\\\\PhpDocParser\\\\Parser\\\\ConstExprParser\\|null, PHPStan\\\\PhpDocParser\\\\ParserConfig given\\.$#"
+ count: 1
+ path: src/TypeResolver.php
+ -
+ message: "#^Parameter \\#1 \\$parseDoctrineAnnotations of class PHPStan\\\\PhpDocParser\\\\Lexer\\\\Lexer constructor expects bool, PHPStan\\\\PhpDocParser\\\\ParserConfig given\\.$#"
+ count: 1
+ path: src/TypeResolver.php
+ -
+ message: "#^Parameter \\#1 \\$unescapeStrings of class PHPStan\\\\PhpDocParser\\\\Parser\\\\ConstExprParser constructor expects bool, PHPStan\\\\PhpDocParser\\\\ParserConfig given\\.$#"
+ count: 1
+ path: src/TypeResolver.php
+ -
+ message: "#^Parameter \\#2 \\$quoteAwareConstExprString of class PHPStan\\\\PhpDocParser\\\\Parser\\\\TypeParser constructor expects bool, PHPStan\\\\PhpDocParser\\\\Parser\\\\ConstExprParser given\\.$#"
+ count: 1
+ path: src/TypeResolver.php
diff --git a/psalm.xml b/psalm.xml
index e72c6d9..2d308a8 100644
--- a/psalm.xml
+++ b/psalm.xml
@@ -38,5 +38,27 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/TypeResolver.php b/src/TypeResolver.php
index a820fee..af57226 100644
--- a/src/TypeResolver.php
+++ b/src/TypeResolver.php
@@ -98,6 +98,7 @@
use PHPStan\PhpDocParser\Parser\ParserException;
use PHPStan\PhpDocParser\Parser\TokenIterator;
use PHPStan\PhpDocParser\Parser\TypeParser;
+use PHPStan\PhpDocParser\ParserConfig;
use RuntimeException;
use function array_filter;
@@ -189,8 +190,14 @@ final class TypeResolver
public function __construct(?FqsenResolver $fqsenResolver = null)
{
$this->fqsenResolver = $fqsenResolver ?: new FqsenResolver();
- $this->typeParser = new TypeParser(new ConstExprParser());
- $this->lexer = new Lexer();
+
+ if (class_exists(ParserConfig::class)) {
+ $this->typeParser = new TypeParser(new ParserConfig([]), new ConstExprParser(new ParserConfig([])));
+ $this->lexer = new Lexer(new ParserConfig([]));
+ } else {
+ $this->typeParser = new TypeParser(new ConstExprParser());
+ $this->lexer = new Lexer();
+ }
}
/**