diff --git a/rules/architecture/tests/Rector/DoctrineRepositoryAsService/DoctrineRepositoryAsServiceTest.php b/rules/architecture/tests/Rector/DoctrineRepositoryAsService/DoctrineRepositoryAsServiceTest.php index 1bfda921ca0..aa8041abc9e 100644 --- a/rules/architecture/tests/Rector/DoctrineRepositoryAsService/DoctrineRepositoryAsServiceTest.php +++ b/rules/architecture/tests/Rector/DoctrineRepositoryAsService/DoctrineRepositoryAsServiceTest.php @@ -36,10 +36,10 @@ final class DoctrineRepositoryAsServiceTest extends AbstractRectorTestCase { return [ # order matters, this needs to be first to correctly detect parent repository - MoveRepositoryFromParentToConstructorRector::class => null, - ServiceLocatorToDIRector::class => null, - ReplaceParentRepositoryCallsByRepositoryPropertyRector::class => null, - RemoveRepositoryFromEntityAnnotationRector::class => null, + MoveRepositoryFromParentToConstructorRector::class => [], + ServiceLocatorToDIRector::class => [], + ReplaceParentRepositoryCallsByRepositoryPropertyRector::class => [], + RemoveRepositoryFromEntityAnnotationRector::class => [], ]; } } diff --git a/src/DependencyInjection/RectorContainerFactory.php b/src/DependencyInjection/RectorContainerFactory.php index 6084ed5888e..080911a7c65 100644 --- a/src/DependencyInjection/RectorContainerFactory.php +++ b/src/DependencyInjection/RectorContainerFactory.php @@ -5,44 +5,11 @@ declare(strict_types=1); namespace Rector\Core\DependencyInjection; use Psr\Container\ContainerInterface; -use Rector\Core\Exception\ShouldNotHappenException; use Rector\Core\HttpKernel\RectorKernel; -use Rector\Core\Set\Set; use Symplify\PackageBuilder\Console\Input\InputDetector; -use Symplify\SetConfigResolver\SetResolver; final class RectorContainerFactory { - /** - * @var string[] - * local config has priority - */ - private const LOCAL_CONFIGS = ['rector.yml', 'rector.yaml']; - - /** - * @var SetResolver - */ - private $setResolver; - - public function __construct() - { - $this->setResolver = new SetResolver(); - } - - public function createFromSet(string $set): ContainerInterface - { - $configs = []; - $configs[] = $this->resolveConfigFromSet($set); - - $localConfigs = $this->resolveLocalConfigs(); - if ($localConfigs !== []) { - // local config has priority, so it's first here - $configs = array_merge($localConfigs, $configs); - } - - return $this->createFromConfigs($configs); - } - /** * @api * @param string[] $configFiles @@ -62,32 +29,4 @@ final class RectorContainerFactory return $rectorKernel->getContainer(); } - - private function resolveConfigFromSet(string $set): string - { - $config = $this->setResolver->detectFromNameAndDirectory($set, Set::SET_DIRECTORY); - if ($config === null) { - throw new ShouldNotHappenException(sprintf('Config file for "%s" set was not found', $set)); - } - - return $config; - } - - /** - * @return string[] - */ - private function resolveLocalConfigs(): array - { - $configs = []; - foreach (self::LOCAL_CONFIGS as $localConfig) { - $configRealPath = getcwd() . DIRECTORY_SEPARATOR . $localConfig; - if (! file_exists($configRealPath)) { - continue; - } - - $configs[] = $configRealPath; - } - - return $configs; - } } diff --git a/tests/DependencyInjection/RectorContainerFactoryTest.php b/tests/DependencyInjection/RectorContainerFactoryTest.php deleted file mode 100644 index f5629e62084..00000000000 --- a/tests/DependencyInjection/RectorContainerFactoryTest.php +++ /dev/null @@ -1,29 +0,0 @@ -createFromSet('doctrine'); - $this->assertInstanceOf(ContainerInterface::class, $rectorContainer); - } - - public function testMissingSet(): void - { - $rectorContainerFactory = new RectorContainerFactory(); - - $this->expectException(SetNotFoundException::class); - $rectorContainerFactory->createFromSet('bla'); - } -}