sebastianbergmann / phpcov

TextUI frontend for php-code-coverage
BSD 3-Clause "New" or "Revised" License
223 stars 58 forks source link

Error on nikic/PhpParser/Lexer.php #113

Closed arno09 closed 2 years ago

arno09 commented 2 years ago

When I'm running phpcov 8.2.0 on a php 8.1 environment with phpUnit 9.5.10 I've got this error :

phpcov 8.2.0 by Sebastian Bergmann.

Generating code coverage report in HTML format ... 
Warning: Undefined array key 336 in phar:///var/www/app/phpcov/nikic/PhpParser/Lexer.php on line 324

Fatal error: Uncaught TypeError: PhpParser\Lexer::getNextToken(): Return value must be of type int, null returned in phar:///var/www/app/phpcov/nikic/PhpParser/Lexer.php:364

For information, I get phpcov by doing wget -q https://phar.phpunit.de/phpcov.phar -O phpcov

SamMousa commented 2 years ago

For me this happened when running on PHP8.1 code which uses some tokens with new indexes in the token map. nikic/php-parser has added support for php8.1 since 4.13.0.

I worked around it by installing this package via composer and manually requiring nikic/php-parser:^4.13.2.

SamMousa commented 2 years ago

It seems all that is needed to fix this is a new build. This commit: https://github.com/sebastianbergmann/php-code-coverage/commit/347a87a7f8b2b78e87200d7de0058dd4ae05f76d adds the correct version of php-parser to the coverage library.

Phpcov requires phpunit/php-code-coverage: ^9.2, and the fix (dependency update) is included from 9.2.8 onwards.

Since this repo does not include a composer.lock file it is essentially saying that it'll work with dependency ranges as specified in the composer.json file; if that's the case then maybe it makes sense to automatically rebuild the PHAR archive and do a minor release every time one of the dependencies comes with a new release. Assumptions:

iamrekas commented 2 years ago

Today is 2022-03-23 and still this issue are not fixed. its need just update dependencies as i understand. In readme phive way is recommended using this tool. Please fix it ASAP. Thank you.

iamrekas commented 2 years ago

Create PR for this. #117 For temporary published phar too in the fork.