diff --git a/packages/NodeTypeResolver/Reflection/BetterReflection/SourceLocatorProvider/DynamicSourceLocatorProvider.php b/packages/NodeTypeResolver/Reflection/BetterReflection/SourceLocatorProvider/DynamicSourceLocatorProvider.php index d7722cbf8bd..26bbd4bc337 100644 --- a/packages/NodeTypeResolver/Reflection/BetterReflection/SourceLocatorProvider/DynamicSourceLocatorProvider.php +++ b/packages/NodeTypeResolver/Reflection/BetterReflection/SourceLocatorProvider/DynamicSourceLocatorProvider.php @@ -10,13 +10,14 @@ use PHPStan\Reflection\BetterReflection\SourceLocator\FileNodesFetcher; use PHPStan\Reflection\BetterReflection\SourceLocator\OptimizedDirectorySourceLocator; use PHPStan\Reflection\BetterReflection\SourceLocator\OptimizedSingleFileSourceLocator; +use Rector\Core\Contract\DependencyInjection\ResetableInterface; use Rector\Testing\PHPUnit\StaticPHPUnitEnvironment; use Webmozart\Assert\Assert; /** * @api phpstan external */ -final class DynamicSourceLocatorProvider +final class DynamicSourceLocatorProvider implements ResetableInterface { /** * @var string[] diff --git a/src/Configuration/RenamedClassesDataCollector.php b/src/Configuration/RenamedClassesDataCollector.php index b37bc37d5e3..5f75aebc798 100644 --- a/src/Configuration/RenamedClassesDataCollector.php +++ b/src/Configuration/RenamedClassesDataCollector.php @@ -5,8 +5,9 @@ namespace Rector\Core\Configuration; use PHPStan\Type\ObjectType; +use Rector\Core\Contract\DependencyInjection\ResetableInterface; -final class RenamedClassesDataCollector +final class RenamedClassesDataCollector implements ResetableInterface { /** * @var array @@ -55,4 +56,9 @@ public function getOldClasses(): array { return array_keys($this->oldToNewClasses); } + + public function reset(): void + { + $this->oldToNewClasses = []; + } } diff --git a/src/Contract/DependencyInjection/ResetableInterface.php b/src/Contract/DependencyInjection/ResetableInterface.php new file mode 100644 index 00000000000..503dd26eb91 --- /dev/null +++ b/src/Contract/DependencyInjection/ResetableInterface.php @@ -0,0 +1,10 @@ +tag(DynamicSourceLocatorProvider::class, ResetableInterface::class); + $lazyRectorConfig->tag(RenamedClassesDataCollector::class, ResetableInterface::class); + // caching $lazyRectorConfig->singleton(Cache::class, static function (Container $container): Cache { /** @var CacheFactory $cacheFactory */