Skip to content

composer.json allows nikic/php-parser ^4.0 but Extractor requires ^5.0 (uses createForVersion) #180

@adeptofvoltron

Description

@adeptofvoltron

composer.json allows nikic/php-parser ^4.0 but Extractor requires ^5.0 (uses createForVersion)

Problem description

In Extractor, we are using the method PhpParser\ParserFactory::createForVersion.
You can see the usage here:
PHPFileExtractor.php#L36

This method was added in nikic/php-parser starting from version 5.0+.

However, the composer.json file of php-translation/extractor currently allows lower versions:

"nikic/php-parser": "^4.0 || ^5.0",

Composer may therefore install nikic/php-parser 4.x, which does not have the createForVersion method.
This leads to a runtime error when using the Extractor with a 4.x version of nikic/php-parser.

See composer.json entry here:
composer.json#L13

Suggested solution

Update the dependency in composer.json to require only version ^5.0 of nikic/php-parser, e.g.:

"nikic/php-parser": "^5.0",

This will prevent Composer from installing incompatible 4.x versions and avoid runtime errors.

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