Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions config/set/early-return.php

This file was deleted.

10 changes: 0 additions & 10 deletions config/set/if.php

This file was deleted.

10 changes: 0 additions & 10 deletions config/set/instanceof.php

This file was deleted.

5 changes: 5 additions & 0 deletions src/Configuration/Option.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,11 @@ final class Option
*/
public const string DEPRECATED_COMPOSER_BASED_ARGS = 'deprecated_composer_based_args';

/**
* @internal For reporting deprecated withPreparedSets() arguments
*/
public const string DEPRECATED_PREPARED_SETS_ARGS = 'deprecated_prepared_sets_args';

/**
* @internal For collect skipped start with short open tag files to be reported
*/
Expand Down
1 change: 1 addition & 0 deletions src/Configuration/Parameter/SimpleParameterProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ final class SimpleParameterProvider
Option::SKIPPED_START_WITH_SHORT_OPEN_TAG_FILES,
Option::DEPRECATED_ATTRIBUTES_SETS_ARGS,
Option::DEPRECATED_COMPOSER_BASED_ARGS,
Option::DEPRECATED_PREPARED_SETS_ARGS,
Option::LEVEL_OVERFLOWS,
Option::COMPOSER_BOUND_RULE_CONFIGURATIONS,
Option::ROOT_STANDALONE_REGISTERED_RULES,
Expand Down
20 changes: 14 additions & 6 deletions src/Configuration/RectorConfigBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -604,9 +604,9 @@ public function withPhpSets(

/**
* @param bool $naming @deprecated The naming set often causes conflicting variable and param names; use a coding standard tool instead
* @param bool $instanceOf @deprecated Use $codeQuality instead, as most instanceof rules were moved there
* @param bool $if @deprecated Use $codeQuality and $codingStyle instead, as the if rules were moved there or deprecated
* @param bool $earlyReturn @deprecated Use $codeQuality instead, as all early return rules were moved there
* @param bool $instanceOf @deprecated No longer applied, use $codeQuality instead, as most instanceof rules were moved there
* @param bool $if @deprecated No longer applied, use $codeQuality and $codingStyle instead, as the if rules were moved there or deprecated
* @param bool $earlyReturn @deprecated No longer applied, use $codeQuality instead, as all early return rules were moved there
*/
public function withPreparedSets(
bool $deadCode = false,
Expand Down Expand Up @@ -635,6 +635,17 @@ public function withPreparedSets(
Notifier::notifyDeprecatedNamingSet();
}

$deprecatedArgs = [
'instanceOf' => $instanceOf,
'if' => $if,
'earlyReturn' => $earlyReturn,
];
foreach ($deprecatedArgs as $deprecatedArgName => $isEnabled) {
if ($isEnabled) {
SimpleParameterProvider::addParameter(Option::DEPRECATED_PREPARED_SETS_ARGS, $deprecatedArgName);
}
}

$setMap = [
SetList::DEAD_CODE => $deadCode,
SetList::CODE_QUALITY => $codeQuality,
Expand All @@ -644,9 +655,6 @@ public function withPreparedSets(
SetList::PRIVATIZATION => $privatization,
SetList::NAMING => $naming,
SetList::NAMED_ARGS => $namedArgs,
SetList::INSTANCEOF => $instanceOf,
SetList::IF => $if,
SetList::EARLY_RETURN => $earlyReturn,
SetList::CARBON => $carbon,
SetList::RECTOR_PRESET => $rectorPreset,
PHPUnitSetList::PHPUNIT_CODE_QUALITY => $phpunitCodeQuality,
Expand Down
1 change: 1 addition & 0 deletions src/Console/Command/ProcessCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$this->deprecatedRulesReporter->reportDeprecatedSkippedRules();
$this->deprecatedRulesReporter->reportDeprecatedAttributesSetsArgs();
$this->deprecatedRulesReporter->reportDeprecatedComposerBasedArgs();
$this->deprecatedRulesReporter->reportDeprecatedPreparedSetsArgs();

$this->missConfigurationReporter->reportSkippedNeverRegisteredRules();
$this->missConfigurationReporter->reportSkippedNonRectorClasses();
Expand Down
1 change: 1 addition & 0 deletions src/Console/Command/ValidateConfigCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$issueCount += $this->deprecatedRulesReporter->reportDeprecatedSkippedRules();
$issueCount += $this->deprecatedRulesReporter->reportDeprecatedAttributesSetsArgs();
$issueCount += $this->deprecatedRulesReporter->reportDeprecatedComposerBasedArgs();
$issueCount += $this->deprecatedRulesReporter->reportDeprecatedPreparedSetsArgs();

$issueCount += $this->missConfigurationReporter->reportSkippedNeverRegisteredRules();
$issueCount += $this->missConfigurationReporter->reportSkippedNonRectorClasses();
Expand Down
19 changes: 19 additions & 0 deletions src/Reporting/DeprecatedRulesReporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,23 @@ public function reportDeprecatedComposerBasedArgs(): int

return $reportedCount;
}

public function reportDeprecatedPreparedSetsArgs(): int
{
/** @var string[] $deprecatedPreparedSetsArgs */
$deprecatedPreparedSetsArgs = SimpleParameterProvider::provideArrayParameter(
Option::DEPRECATED_PREPARED_SETS_ARGS
);

$reportedCount = 0;
foreach (array_unique($deprecatedPreparedSetsArgs) as $deprecatedPreparedSetsArg) {
$this->symfonyStyle->warning(sprintf(
'The "->withPreparedSets(%s: true)" argument is deprecated and no longer applied. Its rules were moved to the "codeQuality" and "codingStyle" sets, use them instead.',
$deprecatedPreparedSetsArg
));
++$reportedCount;
}

return $reportedCount;
}
}
15 changes: 0 additions & 15 deletions src/Set/ValueObject/SetList.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,6 @@ final class SetList

public const string TYPE_DECLARATION_DOCBLOCKS = __DIR__ . '/../../../config/set/type-declaration-docblocks.php';

/**
* @deprecated Use code-quality set instead, as all early return rules were moved there
*/
public const string EARLY_RETURN = __DIR__ . '/../../../config/set/early-return.php';

/**
* @deprecated Use code-quality set instead, as most instanceof rules were moved there
*/
public const string INSTANCEOF = __DIR__ . '/../../../config/set/instanceof.php';

/**
* @deprecated Use code-quality and coding-style sets instead, as the if rules were moved there or deprecated
*/
public const string IF = __DIR__ . '/../../../config/set/if.php';

public const string CARBON = __DIR__ . '/../../../config/set/datetime-to-carbon.php';

public const string BEHAT_ANNOTATIONS_TO_ATTRIBUTES = __DIR__ . '/../../../config/set/behat-annotations-to-attributes.php';
Expand Down
9 changes: 9 additions & 0 deletions tests/Console/Command/ValidateConfigCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ protected function setUp(): void
Option::SKIPPED_START_WITH_SHORT_OPEN_TAG_FILES,
Option::DEPRECATED_ATTRIBUTES_SETS_ARGS,
Option::DEPRECATED_COMPOSER_BASED_ARGS,
Option::DEPRECATED_PREPARED_SETS_ARGS,
Option::ROOT_STANDALONE_REGISTERED_RULES,
Option::SET_REGISTERED_RULES,
] as $optionName) {
Expand Down Expand Up @@ -74,6 +75,14 @@ public function testFailsOnDeprecatedRegisteredRule(): void
$this->assertSame(ExitCode::FAILURE, $this->commandTester->execute([]));
}

public function testFailsOnDeprecatedPreparedSetsArg(): void
{
SimpleParameterProvider::setParameter(Option::REGISTERED_RECTOR_RULES, [OrdSingleByteRector::class]);
SimpleParameterProvider::setParameter(Option::DEPRECATED_PREPARED_SETS_ARGS, ['earlyReturn']);

$this->assertSame(ExitCode::FAILURE, $this->commandTester->execute([]));
}

public function testSucceedsOnCleanConfig(): void
{
SimpleParameterProvider::setParameter(Option::REGISTERED_RECTOR_RULES, [OrdSingleByteRector::class]);
Expand Down
Loading