Skip to content

Preloading failure when running tests with phpunit #9401

Description

@Androoha1

The bundled dependencies of the tool (vendor dir) are namespace prefixed to avoid conflicts. But nicik/php-parser package is not prefixed.

Example file:
vendor/nikic/php-parser/lib/PhpParser/NodeVisitor.php

In my project I am developing a custom rector rule, I run rector tests as a separate test suit, and then I get this conflict when trying to run my tests:

~\Desktop\BTA_projects\Mobile-App\rest-api\web git:[ONE-11888-clean-up-obsolete-code-parts-with-rector]
vendor/bin/phpunit --testdox --testsuite Rector
PHPUnit 12.3.0 by Sebastian Bergmann and contributors.

Runtime: PHP 8.4.7
Configuration: C:\Users\andrii.posternak\Desktop\BTA_projects\Mobile-App\rest-api\web\phpunit.xml

PHP Fatal error: Cannot redeclare interface PhpParser\NodeVisitor (previously declared in C:\Users\andrii.posternak\Desktop\BTA_projects\Mobile-App\rest-api\web\vendor\nikic\php-parser\lib\PhpParser\NodeVisitor.php:5) in C:\Users\andrii.posternak\Desktop\BTA_projects\Mobile-App\rest-api\web\vendor\rector\rector\vendor\nikic\php-parser\lib\PhpParser\NodeVisitor.php on line 6

Fatal error: Cannot redeclare interface PhpParser\NodeVisitor (previously declared in C:\Users\andrii.posternak\Desktop\BTA_projects\Mobile-App\rest-api\web\vendor\nikic\php-parser\lib\PhpParser\NodeVisitor.php:5) in C:\Users\andrii.posternak\Desktop\BTA_projects\Mobile-App\rest-api\web\vendor\rector\rector\vendor\nikic\php-parser\lib\PhpParser\NodeVisitor.php on line 6

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions