-
-
Notifications
You must be signed in to change notification settings - Fork 431
[Scoped] Load early preload.php on scoped bootstrap.php on phpunit 12+ running #7451
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
Conversation
603b8bd to
d0fbaf9
Compare
|
PHPUnit has |
|
/cc @Androoha1 @nikophil @staabm @megawubs @ivastly @nikophil @devnix @ostrolucky @smnandre I need help to test this patch: Please try this patch:
I myself tested in repository https://github.com/ostrolucky/rector-rules and seems working ok
|
|
All checks have passed 🎉 @TomasVotruba it is ready for review. |
…nflict can be early
…nflict can be early
|
Hi @samsonasik here is what I did:
and I still have the error |
|
@nikophil you don't need to include it in your phpunit bootstrap, in phpunit 12, -require \dirname(__DIR__).'/../../bin/tools/rector/vendor/rector/rector/preload.php';the |
|
still the same problem 🤷 |
|
@nikophil Ok, it seems it is due to you load from different paths vendor locations, phpunit is load Could you create simpler repo so I can run locally? currently got database error. Thank you. |
|
you have DB error running |
|
I got error Probably some installation steps missing? |
|
we're using https://github.com/bamarni/composer-bin-plugin for tools like rector, phpstan, ... please run |
|
Okay, I reproduce the error I will look into it 👍 |
|
@nikophil I see, it seems you're using custom path for rector path, this is not recommended as autoload juggling may happen. Your Project autoload: Use same path of autoload should be easier to catch the autoload bug. This may not resolvable by this tweak, as autoload are different, can't guarantee if I can get the solution, as autoload are juggling, but I will still look into it for your use case :) |
|
I'll try this once I'm near laptop 👍 |
|
@nikophil after back and forth check, the solution for your use case is to avoid multiple autoloads definition, on this patch is the following steps:
# open root project
cd foundry
composer require --dev rector/rector
- bootstrap="utils/rector/tests/bootstrap.php"
+ bootstrap="vendor/autoload.php"
That's the way, PHPUnit 12 custom autoload is just not works as it should be, as the project autoload is loaded to early, this is the only way. I commented at PHPUnit issue on it: |
|
@TomasVotruba I got the line starter error why rector-src/src/Testing/PHPUnit/AbstractLazyTestCase.php Lines 62 to 66 in 7ccb174
this still needs to be verified if remove this from order may cause issue as rely on |
|
@TomasVotruba I created alternative PR for patch on |
|
Just testing it on ostrolucky rules. Works well 👍 I forgot we can change autolaod position by leveraging the I'll merge this, but keep the issue open, to track whole context around it and look for native ways solve this. |
|
@TomasVotruba I am thinking that the alternative solution is possibly better, since only change the rector code testing area; This PR is too a little too drastic since it change the autoload. |
@TomasVotruba @staabm per rectorphp/rector#9416 (comment) this is ensure load early
preload.phponbootstrap.phpwhen running PHPUnit.This preload is needed to avoid user require different
nikic/PHP-Parserorphpstan/phpdoc-parserversions because of their project requirement, eg:without the preload early, this will cause error as we are using nikic/php-parser v5 and phpstan/phpdoc-parser v2.
This patch ensure on version PHPUnit 12 only so we have issue patch isolated.