Skip to content

Commit

Permalink
[DX] Add deprecation exception about old ContainerConfigurator, to pr…
Browse files Browse the repository at this point in the history
…epare for removal even in CI
  • Loading branch information
TomasVotruba committed Jun 9, 2022
1 parent d1b7a49 commit bdf11c5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
11 changes: 3 additions & 8 deletions src/DependencyInjection/RectorContainerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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 */
Expand Down
11 changes: 11 additions & 0 deletions src/Exception/DeprecatedException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

declare(strict_types=1);

namespace Rector\Core\Exception;

use Exception;

final class DeprecatedException extends Exception
{
}

0 comments on commit bdf11c5

Please sign in to comment.