Skip to content

Commit 17fa468

Browse files
authored
[Configuration] Deprecate naming prepared set with a warning (#8555)
1 parent 770f1fc commit 17fa468

3 files changed

Lines changed: 14 additions & 1 deletion

File tree

‎rector.php‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
typeDeclarations: true,
1818
typeDeclarationDocblocks: true,
1919
privatization: true,
20-
naming: true,
2120
instanceOf: true,
2221
earlyReturn: true,
2322
rectorPreset: true,

‎src/Configuration/RectorConfigBuilder.php‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -641,6 +641,7 @@ public function withPhp74Sets(): self
641641
// as we already use PHP 8.0 and should go with withPhpSets() instead
642642

643643
/**
644+
* @param bool $naming @deprecated The naming set often causes conflicting variable and param names; use a coding standard tool instead
644645
* @param bool $instanceOf @deprecated Use $codeQuality instead, as most instanceof rules were moved there
645646
* @param bool $if @deprecated Use $codeQuality and $codingStyle instead, as the if rules were moved there or deprecated
646647
* @param bool $earlyReturn @deprecated Use $codeQuality instead, as all early return rules were moved there
@@ -668,6 +669,10 @@ public function withPreparedSets(
668669
): self {
669670
Notifier::notifyNotSuitableMethodForPHP74(__METHOD__);
670671

672+
if ($naming) {
673+
Notifier::notifyDeprecatedNamingSet();
674+
}
675+
671676
$setMap = [
672677
SetList::DEAD_CODE => $deadCode,
673678
SetList::CODE_QUALITY => $codeQuality,

‎src/Console/Notifier.php‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,15 @@ public static function notifyDeprecatedPhpSet(string $set): void
4040
$symfonyStyle->warning($message);
4141
}
4242

43+
public static function notifyDeprecatedNamingSet(): void
44+
{
45+
$message = 'The "naming" prepared set is deprecated, as it often causes conflicting variable and param names and removes context. '
46+
. 'Renaming to match types belongs to a coding standard tool rather than Rector.';
47+
48+
$symfonyStyle = new SymfonyStyle(new ArgvInput(), new ConsoleOutput());
49+
$symfonyStyle->warning($message);
50+
}
51+
4352
public static function errorWithPhpSetsNotSuitableForPHP74AndLower(): void
4453
{
4554
if (PHP_VERSION_ID >= 80000) {

0 commit comments

Comments
 (0)