From d4fb0a89b05b7a6fb7cc1b8fc771feeea601f8bc Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Wed, 17 Jan 2024 16:23:18 +0100 Subject: [PATCH] add warning about deprecated Symfony/Twig/PHPUnit level sets --- src/Config/RectorConfig.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/Config/RectorConfig.php b/src/Config/RectorConfig.php index 4e621e67160..6d3c2537457 100644 --- a/src/Config/RectorConfig.php +++ b/src/Config/RectorConfig.php @@ -18,6 +18,9 @@ use Rector\ValueObject\PhpVersion; use Rector\ValueObject\PolyfillPackage; use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Input\ArrayInput; +use Symfony\Component\Console\Output\ConsoleOutput; +use Symfony\Component\Console\Style\SymfonyStyle; use Webmozart\Assert\Assert; /** @@ -66,6 +69,25 @@ public function sets(array $sets): void $this->import($set); } + // notify about deprecated sets + foreach ($sets as $set) { + if (! str_contains($set, 'deprecated-level-set')) { + continue; + } + + // display only on main command run, skip spamming in workers + $commandArguments = $_SERVER['argv']; + if (! in_array('worker', $commandArguments, trueg)) { + // show warning, to avoid confusion + $symfonyStyle = new SymfonyStyle(new ArrayInput([]), new ConsoleOutput()); + $symfonyStyle->warning( + "The Symfony/Twig/PHPUnit level sets are deprecated since Rector 0.19.2, because of heavy performance load and conflicting overrides. Instead, use latest major set instead.\n\nFor more, see https://getrector.com/blog/5-common-mistakes-in-rector-config-and-how-to-avoid-them" + ); + + break; + } + } + // for cache invalidation in case of sets change SimpleParameterProvider::addParameter(Option::REGISTERED_RECTOR_SETS, $sets); }