Skip to content

Commit

Permalink
[DX] Depreate heavy and conflicting Symfony/Twig/PHPUnit level sets (#…
Browse files Browse the repository at this point in the history
…5477)

* add warning about deprecated Symfony/Twig/PHPUnit level sets

* Update src/Config/RectorConfig.php

Co-authored-by: Abdul Malik Ikhsan <samsonasik@gmail.com>

---------

Co-authored-by: Abdul Malik Ikhsan <samsonasik@gmail.com>
  • Loading branch information
TomasVotruba and samsonasik committed Jan 17, 2024
1 parent 985d5ea commit 863a5ed
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/Config/RectorConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down Expand Up @@ -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, true)) {
// show warning, to avoid confusion
$symfonyStyle = new SymfonyStyle(new ArrayInput([]), new ConsoleOutput());
$symfonyStyle->warning(
"The Symfony/Twig/PHPUnit level sets have been deprecated since Rector 0.19.2 due to heavy performance loads and conflicting overrides. Instead, please use the latest major set.\n\nFor more information, visit 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);
}
Expand Down

0 comments on commit 863a5ed

Please sign in to comment.