Skip to content

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

@zonuexe

Description

@zonuexe

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions