mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-18 22:08:00 +01:00
Updated Rector to commit 4570438319ff69196c28b13fad1e3567ca7bd1e5
4570438319
[Config] Make sure only one of type-declaration/dead-code or with*Level() is used to avoid duplicates (#5578)
This commit is contained in:
parent
7bb5d0c0c4
commit
80c79c976b
@ -19,12 +19,12 @@ final class VersionResolver
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const PACKAGE_VERSION = '5b3d656a003e72540050d47e00285341a96b5796';
|
||||
public const PACKAGE_VERSION = '4570438319ff69196c28b13fad1e3567ca7bd1e5';
|
||||
/**
|
||||
* @api
|
||||
* @var string
|
||||
*/
|
||||
public const RELEASE_DATE = '2024-02-07 17:26:36';
|
||||
public const RELEASE_DATE = '2024-02-07 22:46:43';
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
|
@ -136,9 +136,25 @@ final class RectorConfigBuilder
|
||||
* @var string|null
|
||||
*/
|
||||
private $symfonyContainerPhpFile;
|
||||
/**
|
||||
* To make sure type declarations set and level are not duplicated,
|
||||
* as both contain same rules
|
||||
* @var bool
|
||||
*/
|
||||
private $isTypeCoverageLevelUsed = \false;
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $isDeadCodeLevelUsed = \false;
|
||||
public function __invoke(RectorConfig $rectorConfig) : void
|
||||
{
|
||||
$uniqueSets = \array_unique($this->sets);
|
||||
if (\in_array(SetList::TYPE_DECLARATION, $uniqueSets, \true) && $this->isTypeCoverageLevelUsed) {
|
||||
throw new InvalidConfigurationException(\sprintf('Your config already enables type declarations set.%sRemove "->withTypeCoverageLevel()" as it only duplicates it, or remove type declaration set.', \PHP_EOL));
|
||||
}
|
||||
if (\in_array(SetList::DEAD_CODE, $uniqueSets, \true) && $this->isDeadCodeLevelUsed) {
|
||||
throw new InvalidConfigurationException(\sprintf('Your config already enables dead code set.%sRemove "->withDeadCodeLevel()" as it only duplicates it, or remove dead code set.', \PHP_EOL));
|
||||
}
|
||||
$rectorConfig->sets($uniqueSets);
|
||||
if ($this->paths !== []) {
|
||||
$rectorConfig->paths($this->paths);
|
||||
@ -477,6 +493,7 @@ final class RectorConfigBuilder
|
||||
*/
|
||||
public function withDeadCodeLevel(int $level) : self
|
||||
{
|
||||
$this->isDeadCodeLevelUsed = \true;
|
||||
$levelRules = LevelRulesResolver::resolve($level, DeadCodeLevel::RULE_LIST, 'RectorConfig::withDeadCodeLevel()');
|
||||
$this->rules = \array_merge($this->rules, $levelRules);
|
||||
return $this;
|
||||
@ -487,6 +504,7 @@ final class RectorConfigBuilder
|
||||
*/
|
||||
public function withTypeCoverageLevel(int $level) : self
|
||||
{
|
||||
$this->isTypeCoverageLevelUsed = \true;
|
||||
$levelRules = LevelRulesResolver::resolve($level, TypeCoverageLevel::RULE_LIST, 'RectorConfig::withTypeCoverageLevel()');
|
||||
$this->rules = \array_merge($this->rules, $levelRules);
|
||||
return $this;
|
||||
|
@ -3,7 +3,6 @@
|
||||
declare (strict_types=1);
|
||||
namespace Rector\Console\Command;
|
||||
|
||||
use Throwable;
|
||||
use RectorPrefix202402\Nette\Utils\Strings;
|
||||
use Rector\CustomRules\SimpleNodeDumper;
|
||||
use Rector\PhpParser\Parser\SimplePhpParser;
|
||||
@ -13,6 +12,7 @@ use RectorPrefix202402\Symfony\Component\Console\Input\InputOption;
|
||||
use RectorPrefix202402\Symfony\Component\Console\Output\OutputInterface;
|
||||
use RectorPrefix202402\Symfony\Component\Console\Question\Question;
|
||||
use RectorPrefix202402\Symfony\Component\Console\Style\SymfonyStyle;
|
||||
use Throwable;
|
||||
final class DetectNodeCommand extends Command
|
||||
{
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user