Skip to content

php-doc-parser:^2.x #6984

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
soyuka opened this issue Feb 24, 2025 · 1 comment
Closed

php-doc-parser:^2.x #6984

soyuka opened this issue Feb 24, 2025 · 1 comment

Comments

@soyuka
Copy link
Member

soyuka commented Feb 24, 2025

@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

@maxhelias
Copy link
Contributor

@soyuka This issue is already fixed here : #6789 😉

@soyuka soyuka closed this as completed Apr 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants