[DX] Add deprecation exception about old ContainerConfigurator, to prepare for removal even in CI

This commit is contained in:
Tomas Votruba 2022-06-09 12:14:06 +02:00
parent d1b7a49e35
commit bdf11c5968
2 changed files with 14 additions and 8 deletions

View File

@ -8,9 +8,9 @@ use Nette\Utils\FileSystem;
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 @@ final class RectorContainerFactory
// 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 */

View File

@ -0,0 +1,11 @@
<?php
declare(strict_types=1);
namespace Rector\Core\Exception;
use Exception;
final class DeprecatedException extends Exception
{
}