Skip to content

RemovedAndAddedFilesCollector no longer seems to add files #7231

@jtojnar

Description

@jtojnar

Bug Report

Subject Details
Rector version ≥0.13.1

With Rector 0.13.0 running a custom Rector rule form j0k3r/graby#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: rectorphp/rector-src@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.

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