RemovedAndAddedFilesCollector no longer seems to add files
Bug Report
| Subject | Details |
|---|---|
| Rector version | ≥0.13.1 |
With Rector 0.13.0 running a custom Rector rule form https://github.com/j0k3r/graby/pull/293 is able to add files using RemovedAndAddedFilesCollector. It stops creating the files after updating Rector to 0.13.1 or newer version, even though the rule still performs the code transformation.
I do not see anything suspicious in the changes: https://github.com/rectorphp/rector-src/compare/0.13.0...0.13.1.
Minimal PHP Code Causing Issue
https://github.com/jtojnar/repro/tree/73e3e1813f7ef5ff39484fbe50de13c3c2d13e4b/rector-7231
1 file with changes
===================
1) test.php:0
---------- begin diff ----------
@@ @@
<?php
+use Test\Foo;
function test() {
new Foo;
}
----------- end diff -----------
Applied rules:
* TestRector
[OK] 1 file has been changed by Rector
It works with Rector 0.13.0
https://github.com/jtojnar/repro/tree/43c2b8890704e3f27090cb9376ef6b391dbe3ed3/rector-7231
! [NOTE] File "/home/jtojnar/Projects/repro/rector-7231/test" was added
1 file with changes
===================
1) test.php:0
---------- begin diff ----------
@@ @@
<?php
+use Test\Foo;
function test() {
new Foo;
}
----------- end diff -----------
Applied rules:
* TestRector
! [NOTE] 1 files were added
[OK] 2 files have been changed by Rector
Expected Behaviour
New files should be created.
Hi, this part of Rector is quite complex. We'd need a simple reproducer repository to be able to find the bug.
If this is still relevant, share a repository with failing Github action and we can re-open the issue and check it.
I have updated the repository with latest Rector (0.13.9) and added CI (not sure what it adds, when there is a already composer lockfile). It is still an issue.
I have updated the repository with latest Rector (0.13.9) and added CI (not sure what it adds, when there is a already composer lockfile). It is still an issue.
I don't know whether this suits you, but as a workaround, by disabling the parallel processing, you can make it work:
// rector.php
$rectorConfig->disableParallel();
We'll need a reproducible test case here in Rector.
@TomasVotruba Should I open a PR copying the example above as a failing integration test?
@jtojnar That would be great 👍
Okay, opened https://github.com/rectorphp/rector-src/pull/3058.