Skip to content

Endless loop of : [OK] 1 file has been changed by Rector #9661

Closed
rectorphp/rector-src
#7903

Description

@t-liesche-tqgg

Bug Report

Subject Details
Rector version 2.3.7

We can't really tell what's going on, but in some of our projects the CI pipeline started failing after upgrading rector to version 2.3.7. Downgrading the library to 2.3.6 fixes the issue.

Minimal PHP Code Causing Issue

`vendor/bin/rector --debug
[info] Sets loaded based on installed packages:

  • /opt/host/projects/***/vendor/rector/rector/vendor/rector/rector-phpunit/config/sets/phpunit120.php
  • /opt/host/projects/***/vendor/rector/rector/vendor/rector/rector-phpunit/config/sets/phpunit125.php
  • /opt/host/projects/***/vendor/rector/rector/vendor/rector/rector-symfony/config/sets/symfony/symfony7/symfony70/symfony70-http-foundation.php
  • /opt/host/projects/***/vendor/rector/rector/vendor/rector/rector-symfony/config/sets/symfony/symfony7/symfony72/symfony72-http-foundation.php

[...]

1/1 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%

[OK] 1 file has been changed by Rector`

There is not a single error or change indication in the list of processed files.

Running the command repeatedly will always print the exact same output without actually changing anything. Dry run fails as well with return code 2:

`vendor/bin/rector --dry-run
1/1 [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%

[OK] 1 file would have been changed (dry-run) by Rector`

Expected Behaviour

Rector should either fix the code or not fail.

Activity

  1. samsonasik commented on Feb 20, 2026

    @samsonasik
    Member

    Could you provide reproducible repo? Thank you.

  2. tc-cristian-radu commented on Feb 20, 2026

    @tc-cristian-radu

    Same issue, here is an example file which triggers this bug:

    <?php
    
    declare(strict_types=1);
    
    namespace Tests\Feature;
    
    use App\Services\ServiceFactory;
    use Illuminate\Testing\PendingCommand;
    use Mockery;
    use Mockery\MockInterface;
    use Override;
    use RuntimeException;
    use Tests\TestCase;
    
    final class CommandTest extends TestCase
    {
        #[Override]
        protected function tearDown(): void
        {
            Mockery::close();
            parent::tearDown();
        }
    
    }
    
  3. samsonasik commented on Feb 20, 2026

    @samsonasik
    Member

    @tc-cristian-radu could you provide simple reproducible repo ( 1 file, 1 composer.json, 1 rector.php)? Thank you.

  4. tc-cristian-radu commented on Feb 20, 2026

    @tc-cristian-radu

    composer.json:

    {
        "require": {
            "laravel/framework": "^12.32"
        },
        "require-dev": {
            "driftingly/rector-laravel": "^2.1",
            "mockery/mockery": "^1.6",
            "rector/rector": "^2.2"
        },
        "autoload-dev": {
            "psr-4": {
                "Tests\\": "tests/"
            }
        }
    }
    

    rector.php

    <?php
    
    declare(strict_types=1);
    
    use Rector\Config\RectorConfig;
    use Rector\Set\ValueObject\LevelSetList;
    use Rector\PHPUnit\Set\PHPUnitSetList;
    
    return static function (RectorConfig $rectorConfig): void {
        $rectorConfig->paths([
            __DIR__ . '/tests',
        ]);
        
        $rectorConfig->importNames();
    
        // Define sets to use — adjust as needed
        $rectorConfig->sets([
            LevelSetList::UP_TO_PHP_83,
            PHPUnitSetList::PHPUNIT_80,
            PHPUnitSetList::PHPUNIT_90,
            PHPUnitSetList::PHPUNIT_100,
            PHPUnitSetList::PHPUNIT_110,
            PHPUnitSetList::PHPUNIT_120,
            PHPUnitSetList::PHPUNIT_CODE_QUALITY,
            PHPUnitSetList::ANNOTATIONS_TO_ATTRIBUTES,
        ]);
    };
    

    TestCase.php

    <?php
    
    declare(strict_types=1);
    
    namespace Tests;
    
    use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
    
    abstract class TestCase extends BaseTestCase
    {
        //
    }
    
  5. samsonasik commented on Feb 20, 2026

    @samsonasik
    Member

    @tc-cristian-radu I can't reproduce

    Image

    Could you share the repository we can clone, install, and run locally? Thank you.

  6. tc-cristian-radu commented on Feb 20, 2026

    @tc-cristian-radu

    @samsonasik You need also the initial file I provided - sorry I can't share the actual repo as it is private

  7. yoannblot commented on Feb 20, 2026

    @yoannblot

    FYI, we have the same errors on 2 repositories, both are up-to-date Laravel ones and it both concerns tests (with phpunit 13 + mockery).
    On the biggest repository:

    [OK] 5 files would have been changed (dry-run) by Rector
    and the other one:
    [OK] 3 files would have been changed (dry-run) by Rector

    And even with debug options, there is no information about the concerned files 🤷‍♂️

  8. samsonasik commented on Feb 20, 2026

    @samsonasik
    Member

    I see, it seems due to removal of #[Override] on tearDown()on PR:

    then, the AddOverrideAttributeToOverriddenMethodsRector re-add it so it infinite add/remove it, I will patch on AddOverrideAttributeToOverriddenMethodsRector

  9. github-actions commented on Aug 30, 2026

    @github-actions
    Contributor

    This issue has been automatically locked because it has been closed for 150 days. Please open a new issue if you have a similar problem.

  10. locked as resolved and limited conversation to collaborators on Aug 30, 2026
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