From bdf11c5968b1304f809781f9023dc7a2cf3642ad Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Thu, 9 Jun 2022 12:14:06 +0200 Subject: [PATCH] [DX] Add deprecation exception about old ContainerConfigurator, to prepare for removal even in CI --- src/DependencyInjection/RectorContainerFactory.php | 11 +++-------- src/Exception/DeprecatedException.php | 11 +++++++++++ 2 files changed, 14 insertions(+), 8 deletions(-) create mode 100644 src/Exception/DeprecatedException.php diff --git a/src/DependencyInjection/RectorContainerFactory.php b/src/DependencyInjection/RectorContainerFactory.php index 57bdc1ce82ed..d1a77b361ea4 100644 --- a/src/DependencyInjection/RectorContainerFactory.php +++ b/src/DependencyInjection/RectorContainerFactory.php @@ -8,9 +8,9 @@ use Psr\Container\ContainerInterface; use Rector\Caching\Detector\ChangedFilesDetector; use Rector\Core\Autoloading\BootstrapFilesIncluder; +use Rector\Core\Exception\DeprecatedException; use Rector\Core\Kernel\RectorKernel; use Rector\Core\ValueObject\Bootstrap\BootstrapConfigs; -use Symfony\Component\Console\Style\SymfonyStyle; final class RectorContainerFactory { @@ -24,17 +24,12 @@ public function createFromBootstrapConfigs(BootstrapConfigs $bootstrapConfigs): // warning about old syntax before RectorConfig $fileContents = FileSystem::read($mainConfigFile); if (str_contains($fileContents, 'ContainerConfigurator $containerConfigurator')) { - /** @var SymfonyStyle $symfonyStyle */ - $symfonyStyle = $container->get(SymfonyStyle::class); - $warningMessage = sprintf( - 'Your "%s" config is using old syntax with "ContainerConfigurator".%sUpgrade to "RectorConfig" that allows better autocomplete and future standard: https://getrector.org/blog/new-in-rector-012-introducing-rector-config-with-autocomplete', + 'Your "%s" config uses deprecated syntax with "ContainerConfigurator".%sUpgrade to "RectorConfig": https://getrector.org/blog/new-in-rector-012-introducing-rector-config-with-autocomplete', $mainConfigFile, PHP_EOL, ); - $symfonyStyle->error($warningMessage); - // to make message noticable - sleep(10); + throw new DeprecatedException($warningMessage); } /** @var ChangedFilesDetector $changedFilesDetector */ diff --git a/src/Exception/DeprecatedException.php b/src/Exception/DeprecatedException.php new file mode 100644 index 000000000000..bed0b65fe576 --- /dev/null +++ b/src/Exception/DeprecatedException.php @@ -0,0 +1,11 @@ +