-
-
Notifications
You must be signed in to change notification settings - Fork 927
Description
@soyuka, I think you closed this issue a bit too early. The main problem is getting the API platform to support version 2.x of phpstan/phpdoc-parser.
I played a bit with this and I got it working by making following changes
diff --git a/src/Metadata/Resource/Factory/PhpDocResourceMetadataCollectionFactory.php b/src/Metadata/Resource/Factory/PhpDocResourceMetadataCollectionFacto ry.php index 2a5163f42..521a9bf30 100644 --- a/src/Metadata/Resource/Factory/PhpDocResourceMetadataCollectionFactory.php +++ b/src/Metadata/Resource/Factory/PhpDocResourceMetadataCollectionFactory.php @@ -25,6 +25,7 @@ use PHPStan\PhpDocParser\Parser\ConstExprParser; use PHPStan\PhpDocParser\Parser\PhpDocParser; use PHPStan\PhpDocParser\Parser\TokenIterator; use PHPStan\PhpDocParser\Parser\TypeParser; +use PHPStan\PhpDocParser\ParserConfig; /** * Extracts descriptions from PHPDoc. @@ -59,8 +60,10 @@ final class PhpDocResourceMetadataCollectionFactory implements ResourceMetadataC $phpDocParser = null; $lexer = null; if (class_exists(PhpDocParser::class)) { - $phpDocParser = new PhpDocParser(new TypeParser(new ConstExprParser()), new ConstExprParser()); - $lexer = new Lexer(); + $config = new ParserConfig(usedAttributes: []); + $lexer = new Lexer($config); + $constExprParser = new ConstExprParser($config); + $phpDocParser = new PhpDocParser($config, new TypeParser($config, $constExprParser), $constExprParser); } $this->phpDocParser = $phpDocParser; $this->lexer = $lexer;However to be noted, upgrading phpstan/phpdoc-parser in project level might break something else. It's a major version bump anyways. Sadly I am currently unable to invest enough time to investigate this deeper, so I am just pinning in my composer.json
"phpstan/phpdoc-parser": "^1.26",
.I think it would be a good idea to either open this issue or create new issue, where goal is to make sure we could bump phpstan/phpdoc-parser to next major version. Support for both versions major of phpstan/phpdoc-parser should be supported, but version 1.x deprecated -> remove support for 1.x in some major/minor patch of api-platform.
Originally posted by @NikoGrano in #2797