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

Error occurs when PHP-Parser 5.x is installed #10401

Closed
zonuexe opened this issue Jan 8, 2024 · 6 comments
Closed

Error occurs when PHP-Parser 5.x is installed #10401

zonuexe opened this issue Jan 8, 2024 · 6 comments

Comments

@zonuexe
Copy link
Contributor

zonuexe commented Jan 8, 2024

Bug report

When creating a new PHPStan extension repository or updating composer, PHP-Parser 5.x conflicts.

% ./vendor/bin/phpunit
PHPUnit 10.5.5 by Sebastian Bergmann and contributors.

Runtime:       PHP 8.3.1
Configuration: /Users/megurine/repo/php/tadsan-phpstan-rules/phpunit.xml.dist

PHP Fatal error:  Declaration of PhpParser\ParserAbstract::parse(string $code, ?PhpParser\ErrorHandler $errorHandler = null) must be compatible with PhpParser\Parser::parse(string $code, ?PhpParser\ErrorHandler $errorHandler = null): ?array in phar:///Users/megurine/repo/php/tadsan-phpstan-rules/vendor/phpstan/phpstan/phpstan.phar/vendor/nikic/php-parser/lib/PhpParser/ParserAbstract.php on line 142

Fatal error: Declaration of PhpParser\ParserAbstract::parse(string $code, ?PhpParser\ErrorHandler $errorHandler = null) must be compatible with PhpParser\Parser::parse(string $code, ?PhpParser\ErrorHandler $errorHandler = null): ?array in phar:///Users/megurine/repo/php/tadsan-phpstan-rules/vendor/phpstan/phpstan/phpstan.phar/vendor/nikic/php-parser/lib/PhpParser/ParserAbstract.php on line 142

This issue can be prevented by conflict in composer.json.

Code snippet that reproduces the problem

No response

Expected output

This problem does not occur if PHP-Parser 5.x is prevented from being installed in the same package.

% composer why nikic/php-parser
zonuexe/tadsan-phpstan-rules -       conflicts nikic/php-parser (>= 5.0.0)      
phpunit/php-code-coverage    10.1.11 requires  nikic/php-parser (^4.18 || ^5.0) 
sebastian/complexity         3.2.0   requires  nikic/php-parser (^4.18 || ^5.0) 
sebastian/lines-of-code      2.0.2   requires  nikic/php-parser (^4.18 || ^5.0) 

Did PHPStan help you today? Did it make you happy in any way?

I noticed this problem when I created a new repository to write a PHPStan tutorial in Japanese.

Copy link

mergeable bot commented Jan 8, 2024

This bug report is missing a link to reproduction at phpstan.org/try.

It will most likely be closed after manual review.

@ondrejmirtes
Copy link
Member

Hi, please publish the repository where this problem occurs, I'd like to look into it in more detail.

@zonuexe
Copy link
Contributor Author

zonuexe commented Jan 8, 2024

@ondrejmirtes
I published this extension to https://github.com/zonuexe/tadsan-phpstan-rules.
It works fine on master, but I can see the error on PR's branch.

@ondrejmirtes
Copy link
Member

This commit avoids the problem: phpstan/phpstan-src@9dac90d

@zonuexe
Copy link
Contributor Author

zonuexe commented Jan 8, 2024

Thank you!

Copy link

github-actions bot commented Feb 9, 2024

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 9, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants