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

Fatal error when trying to run a code coverage report #1031

Open
GiantCoder opened this issue Sep 30, 2024 · 4 comments
Open

Fatal error when trying to run a code coverage report #1031

GiantCoder opened this issue Sep 30, 2024 · 4 comments

Comments

@GiantCoder
Copy link

I'm running:
root@b00c3eb5d255:/app# XDEBUG_MODE=coverage php bin/phpunit --coverage-html .

The error is:
Testing
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 /app/vendor/nikic/php-parser/lib/PhpParser/ParserAbstract.php on line 158

Relevant part of my composer.json:
{ "name": "phpstan/phpdoc-parser", "version": "1.32.0", "source": { "type": "git", "url": "https://github.com/phpstan/phpdoc-parser.git", "reference": "6ca22b154efdd9e3c68c56f5d94670920a1c19a4" }, "dist": { "type": "zip", "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/6ca22b154efdd9e3c68c56f5d94670920a1c19a4", "reference": "6ca22b154efdd9e3c68c56f5d94670920a1c19a4", "shasum": "" }, "require": { "php": "^7.2 || ^8.0" }, "require-dev": { "doctrine/annotations": "^2.0", "nikic/php-parser": "^4.15",

@nikic
Copy link
Owner

nikic commented Oct 5, 2024

It looks like you end up mixing version 4.x and 5.x of PHP-Parser somehow. You have 4.x in your project and phpunit comes with it's own version -- how did you install phpunit? If it's a composer dependency things should be correctly resolved. If it's a phar, I'd expect it to be prefixed, but I'm not sure.

@mrunkel
Copy link

mrunkel commented Oct 29, 2024

I'm getting the same error. Like OP, I'm running with the symfony phpunit-bridge which will do it's own composer install before running phpunit. I'll dig around on my system and see what's happening.

@xabbuh
Copy link

xabbuh commented Oct 29, 2024

@mrunkel When using the PHPUnit bridge you can try using the SYMFONY_PHPUNIT_REQUIRE (to enforce a particular version of a packe) or SYMFONY_PHPUNIT_REMOVE (to try removing a package) environment variables.

@mrunkel
Copy link

mrunkel commented Oct 29, 2024 via email

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

No branches or pull requests

4 participants