Skip to content

File passes after config cache when it should fail because of cache #7835

@jackbentley

Description

@jackbentley

Bug Report

Subject Details
Rector version Rector 5db390cb7b67d3537acc34d3eabb04de1ef4b35a

If a file has been cached with a different config/ruleset, it will still pass when the ruleset changes even though the file should not pass.

Minimal PHP Code Causing Issue

See https://getrector.com/demo/da1a6029-6842-4ddb-a7fd-1be936e2cc80

Using this example file:

<?php

final class DemoFile
{
    public function run()
    {
        return array();
    }
}

and this config:

<?php

use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\LevelSetList;
use Rector\Php54\Rector\Array_\LongArrayToShortArrayRector;

return static function (RectorConfig $rectorConfig): void {
    $rectorConfig->sets([
        LevelSetList::UP_TO_PHP_53,
    ]);
};
  1. Run with the given config - ensure cache is created
  2. Change config to be UP_TO_PHP_54
  3. Re-run
  4. Notice no files changed
  5. Re-run with --cache-clear
  6. Notice 1 files changed

Expected Behaviour

All cache should be invalidated upon config change.

PHPStan also invalidates cache on any config change and more https://phpstan.org/user-guide/result-cache

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