Skip to content
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

Add support for phpstan/phpdoc-parser 2 #205

Merged
merged 1 commit into from
Nov 17, 2024

Conversation

MrMeshok
Copy link
Contributor

I noticed locally that random test started to fail, turns out it's because phpdocumentor/type-resolver added support for phpstan/phpdoc-parser v2, but this library not ready for phpdoc-parser v2.
I chose minimal version of 1.13 because minimal version of phpdocumentor/type-resolver required it so there should be no changes to composer update --prefer-lowest

@Korbeil
Copy link
Member

Korbeil commented Nov 15, 2024

Is it not possible to have something compatible like Symfony did with TypeInfo with symfony/symfony#58804 ?

@MrMeshok
Copy link
Contributor Author

Is it not possible to have something compatible like Symfony did with TypeInfo with symfony/symfony#58804 ?

It's definitely possible, I just did quick fix, this issue probably gonna show up then someone does composer update in their project. Also phpstan/phpdoc-parser should stay in composer.json so this doesn't happen again

@MrMeshok MrMeshok changed the title Lock phpstan/phpdoc-parser to v1 Add support for phpstan/phpdoc-parser 2 Nov 17, 2024
@MrMeshok
Copy link
Contributor Author

@Korbeil I changed PR to add support to v2 instead of locking to v1

Copy link
Member

@Korbeil Korbeil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks perfect, thanks for the update! I'll try to get a look today to do a release!

@Korbeil Korbeil merged commit 42e9ec6 into jolicode:main Nov 17, 2024
5 checks passed
@MrMeshok MrMeshok deleted the lock-phpdoc-parser branch November 17, 2024 10:39
@IndraGunawan
Copy link
Contributor

hi @Korbeil , please do a release when you have time
thanks

@jorismak
Copy link

jorismak commented Nov 19, 2024

To clarify,

I have a Laravel project with jolicode/automapper in it. I recently did some composer require -W on some dependencies to update them. During this, apparently phpstan/phpdoc-parser upgraded from 1.x to 2.x. Because composer had no conflicts, it jumped to 2.0.0 for phpstan/phpdoc-parser.

But automapper now gives:

 Too few arguments to function PHPStan\PhpDocParser\Parser\ConstExprParser::__construct(), 0 passed in /home/joris/projects/prijsvrij-statamic/vendor/jolicode/automapper/src/Extractor/GetTypeTrait.php on line 46 and exactly 1 expected

  at vendor/phpstan/phpdoc-parser/src/Parser/ConstExprParser.php:18
     14▕        private ParserConfig $config;
     15▕ 
     16▕        private bool $parseDoctrineStrings;
     17▕ 
  ➜  18▕        public function __construct(
     19▕                ParserConfig $config
     20▕        )
     21▕        {
     22▕                $this->config = $config;

      +11 vendor frames 

  12  app/Services/Automapper.php:26
      AutoMapper\AutoMapper::map()
      +1 vendor frames 

So it seems something is incompatible with phpdoc-parser 2.0.
I'm running automapper 9.1.2 at the moment.

Now, do I read this issue correctly in that support for 2.x is added but has yet to be released?
Or do I encounter something else?

@MrMeshok
Copy link
Contributor Author

Now, do I read this issue correctly in that support for 2.x is added but has yet to be released?

Yes.
You can add "phpstan/phpdoc-parser": "^1.13" to your composer.json as workaround for now

@Korbeil
Copy link
Member

Korbeil commented Nov 19, 2024

I just released AutoMapper 9.2.0 which should resolve your issue without forcing v1 on phpstan/phpdoc-parser @jorismak https://github.com/jolicode/automapper/releases/tag/9.2.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants