diff --git a/composer.json b/composer.json index 2f6b725b38c..aa0f287b9dc 100644 --- a/composer.json +++ b/composer.json @@ -150,7 +150,7 @@ "justinrainbow/json-schema": "^5.2.1", "phpspec/prophecy-phpunit": "^2.0", "phpstan/extension-installer": "^1.1", - "phpstan/phpdoc-parser": "^1.13", + "phpstan/phpdoc-parser": "^1.13|^2.0", "phpstan/phpstan": "^1.10", "phpstan/phpstan-doctrine": "^1.0", "phpstan/phpstan-phpunit": "^1.0", diff --git a/src/Metadata/Resource/Factory/PhpDocResourceMetadataCollectionFactory.php b/src/Metadata/Resource/Factory/PhpDocResourceMetadataCollectionFactory.php index 2a5163f424c..b7c1378b57b 100644 --- a/src/Metadata/Resource/Factory/PhpDocResourceMetadataCollectionFactory.php +++ b/src/Metadata/Resource/Factory/PhpDocResourceMetadataCollectionFactory.php @@ -25,6 +25,7 @@ use PHPStan\PhpDocParser\Parser\PhpDocParser; use PHPStan\PhpDocParser\Parser\TokenIterator; use PHPStan\PhpDocParser\Parser\TypeParser; +use PHPStan\PhpDocParser\ParserConfig; /** * Extracts descriptions from PHPDoc. @@ -58,9 +59,13 @@ public function __construct(private readonly ResourceMetadataCollectionFactoryIn } $phpDocParser = null; $lexer = null; - if (class_exists(PhpDocParser::class)) { - $phpDocParser = new PhpDocParser(new TypeParser(new ConstExprParser()), new ConstExprParser()); - $lexer = new Lexer(); + if (class_exists(PhpDocParser::class) && class_exists(ParserConfig::class)) { + $config = new ParserConfig([]); + $phpDocParser = new PhpDocParser($config, new TypeParser($config, new ConstExprParser($config)), new ConstExprParser($config)); + $lexer = new Lexer($config); + } elseif (class_exists(PhpDocParser::class)) { + $phpDocParser = new PhpDocParser(new TypeParser(new ConstExprParser()), new ConstExprParser()); // @phpstan-ignore-line + $lexer = new Lexer(); // @phpstan-ignore-line } $this->phpDocParser = $phpDocParser; $this->lexer = $lexer; diff --git a/tests/Fixtures/TestBundle/Document/DummyProduct.php b/tests/Fixtures/TestBundle/Document/DummyProduct.php index 0887236029b..cdd001ca68f 100644 --- a/tests/Fixtures/TestBundle/Document/DummyProduct.php +++ b/tests/Fixtures/TestBundle/Document/DummyProduct.php @@ -23,7 +23,7 @@ /** * Dummy Product. * - * https://github.com/api-platform/core/issues/1107. + * @see https://github.com/api-platform/core/issues/1107 * * @author Antoine Bluchet */ diff --git a/tests/Fixtures/TestBundle/Entity/DummyProduct.php b/tests/Fixtures/TestBundle/Entity/DummyProduct.php index 0f34fe8174d..d6e428f8a02 100644 --- a/tests/Fixtures/TestBundle/Entity/DummyProduct.php +++ b/tests/Fixtures/TestBundle/Entity/DummyProduct.php @@ -23,7 +23,7 @@ /** * Dummy Product. * - * https://github.com/api-platform/core/issues/1107. + * @see https://github.com/api-platform/core/issues/1107 * * @author Antoine Bluchet */