Skip to content

Commit e486c54

Browse files
committed
Updated Rector to commit ca6cf9cc8e20dbb5350af21d2da872fe348775bb
rectorphp/rector-src@ca6cf9c [dx] warn early about deprecated skipped rules, as not neccessary to skip anymore (#7742)
1 parent 4674fb4 commit e486c54

File tree

8 files changed

+67
-20
lines changed

8 files changed

+67
-20
lines changed

rules/Php81/Rector/Array_/ArrayToFirstClassCallableRector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
* @see RFC https://wiki.php.net/rfc/first_class_callable_syntax
3030
* @see \Rector\Tests\Php81\Rector\Array_\ArrayToFirstClassCallableRector\ArrayToFirstClassCallableRectorTest
3131
*/
32-
final class ArrayToFirstClassCallableRector extends AbstractRector implements MinPhpVersionInterface
32+
class ArrayToFirstClassCallableRector extends AbstractRector implements MinPhpVersionInterface
3333
{
3434
/**
3535
* @readonly
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
declare (strict_types=1);
4+
namespace Rector\Php81\Rector\Array_;
5+
6+
use PhpParser\Node;
7+
use PhpParser\Node\Expr\MethodCall;
8+
use PhpParser\Node\Expr\StaticCall;
9+
use Rector\Configuration\Deprecation\Contract\DeprecatedInterface;
10+
use Rector\Exception\ShouldNotHappenException;
11+
/**
12+
* @deprecated Renamed to \Rector\Php81\Rector\Array_\ArrayToFirstClassCallableRector
13+
*/
14+
final class FirstClassCallableRector extends \Rector\Php81\Rector\Array_\ArrayToFirstClassCallableRector implements DeprecatedInterface
15+
{
16+
/**
17+
* @return \PhpParser\Node\Expr\StaticCall|\PhpParser\Node\Expr\MethodCall|null
18+
*/
19+
public function refactor(Node $node)
20+
{
21+
throw new ShouldNotHappenException(sprintf('%s is deprecated and renamed to "%s". Use it instead.', self::class, \Rector\Php81\Rector\Array_\ArrayToFirstClassCallableRector::class));
22+
}
23+
}

src/Application/VersionResolver.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ final class VersionResolver
1919
* @api
2020
* @var string
2121
*/
22-
public const PACKAGE_VERSION = '2.2.13';
22+
public const PACKAGE_VERSION = 'ca6cf9cc8e20dbb5350af21d2da872fe348775bb';
2323
/**
2424
* @api
2525
* @var string
2626
*/
27-
public const RELEASE_DATE = '2025-12-09 07:41:03';
27+
public const RELEASE_DATE = '2025-12-09 11:53:46';
2828
/**
2929
* @var int
3030
*/

src/Console/Command/ListRulesCommand.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ protected function configure(): void
5050
protected function execute(InputInterface $input, OutputInterface $output): int
5151
{
5252
$rectorClasses = $this->resolveRectorClasses();
53-
$skippedClasses = $this->getSkippedCheckers();
53+
$skippedClasses = $this->getSkippedRectorClasses();
5454
$outputFormat = $input->getOption(Option::OUTPUT_FORMAT);
5555
if ($outputFormat === 'json') {
5656
$data = ['rectors' => $rectorClasses, 'skipped-rectors' => $skippedClasses];
@@ -78,18 +78,18 @@ private function resolveRectorClasses(): array
7878
return array_unique($rectorClasses);
7979
}
8080
/**
81-
* @return string[]
81+
* @return array<class-string>
8282
*/
83-
private function getSkippedCheckers(): array
83+
private function getSkippedRectorClasses(): array
8484
{
85-
$skippedCheckers = [];
86-
foreach ($this->skippedClassResolver->resolve() as $checkerClass => $fileList) {
85+
$skippedRectorClasses = [];
86+
foreach ($this->skippedClassResolver->resolve() as $rectorClass => $fileList) {
8787
// ignore specific skips
8888
if ($fileList !== null) {
8989
continue;
9090
}
91-
$skippedCheckers[] = $checkerClass;
91+
$skippedRectorClasses[] = $rectorClass;
9292
}
93-
return $skippedCheckers;
93+
return $skippedRectorClasses;
9494
}
9595
}

src/Console/Command/ProcessCommand.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use Rector\Exception\ShouldNotHappenException;
1919
use Rector\Reporting\DeprecatedRulesReporter;
2020
use Rector\Reporting\MissConfigurationReporter;
21+
use Rector\Skipper\SkipCriteriaResolver\SkippedClassResolver;
2122
use Rector\StaticReflection\DynamicSourceLocatorDecorator;
2223
use Rector\Util\MemoryLimiter;
2324
use Rector\ValueObject\Configuration;
@@ -78,7 +79,11 @@ final class ProcessCommand extends Command
7879
* @readonly
7980
*/
8081
private ConfigurationRuleFilter $configurationRuleFilter;
81-
public function __construct(AdditionalAutoloader $additionalAutoloader, ChangedFilesDetector $changedFilesDetector, ConfigInitializer $configInitializer, ApplicationFileProcessor $applicationFileProcessor, DynamicSourceLocatorDecorator $dynamicSourceLocatorDecorator, OutputFormatterCollector $outputFormatterCollector, SymfonyStyle $symfonyStyle, MemoryLimiter $memoryLimiter, ConfigurationFactory $configurationFactory, DeprecatedRulesReporter $deprecatedRulesReporter, MissConfigurationReporter $missConfigurationReporter, ConfigurationRuleFilter $configurationRuleFilter)
82+
/**
83+
* @readonly
84+
*/
85+
private SkippedClassResolver $skippedClassResolver;
86+
public function __construct(AdditionalAutoloader $additionalAutoloader, ChangedFilesDetector $changedFilesDetector, ConfigInitializer $configInitializer, ApplicationFileProcessor $applicationFileProcessor, DynamicSourceLocatorDecorator $dynamicSourceLocatorDecorator, OutputFormatterCollector $outputFormatterCollector, SymfonyStyle $symfonyStyle, MemoryLimiter $memoryLimiter, ConfigurationFactory $configurationFactory, DeprecatedRulesReporter $deprecatedRulesReporter, MissConfigurationReporter $missConfigurationReporter, ConfigurationRuleFilter $configurationRuleFilter, SkippedClassResolver $skippedClassResolver)
8287
{
8388
$this->additionalAutoloader = $additionalAutoloader;
8489
$this->changedFilesDetector = $changedFilesDetector;
@@ -92,6 +97,7 @@ public function __construct(AdditionalAutoloader $additionalAutoloader, ChangedF
9297
$this->deprecatedRulesReporter = $deprecatedRulesReporter;
9398
$this->missConfigurationReporter = $missConfigurationReporter;
9499
$this->configurationRuleFilter = $configurationRuleFilter;
100+
$this->skippedClassResolver = $skippedClassResolver;
95101
parent::__construct();
96102
}
97103
protected function configure(): void
@@ -139,6 +145,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int
139145
foreach ($configuration->getLevelOverflows() as $levelOverflow) {
140146
$this->reportLevelOverflow($levelOverflow);
141147
}
148+
// 0. warn about skipped rules that are deprecated
149+
if ($this->skippedClassResolver->resolveDeprecatedSkippedClasses() !== []) {
150+
$this->symfonyStyle->warning(sprintf('These rules are skipped, but are deprecated. Most likely you do not need to skip them anymore as not part of any set and remove them: %s* %s', "\n\n", implode(' * ', $this->skippedClassResolver->resolveDeprecatedSkippedClasses()) . "\n"));
151+
}
142152
// 1. warn about rules registered in both withRules() and sets to avoid bloated rector.php configs
143153
$setAndRulesDuplicatedRegistrations = $configuration->getBothSetAndRulesDuplicatedRegistrations();
144154
if ($setAndRulesDuplicatedRegistrations !== []) {

src/Skipper/SkipCriteriaResolver/SkippedClassResolver.php

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,30 +3,42 @@
33
declare (strict_types=1);
44
namespace Rector\Skipper\SkipCriteriaResolver;
55

6+
use Rector\Configuration\Deprecation\Contract\DeprecatedInterface;
67
use Rector\Configuration\Option;
78
use Rector\Configuration\Parameter\SimpleParameterProvider;
89
use Rector\Testing\PHPUnit\StaticPHPUnitEnvironment;
10+
/**
11+
* @see \Rector\Tests\Skipper\Skipper\SkippedClassResolverTest
12+
*/
913
final class SkippedClassResolver
1014
{
1115
/**
12-
* @var null|array<string, string[]|null>
16+
* @var null|array<class-string, string[]|null>
1317
*/
14-
private $skippedClasses = null;
18+
private $skippedClassesToFiles = null;
1519
/**
16-
* @return array<string, string[]|null>
20+
* @return array<class-string<DeprecatedInterface>>
21+
*/
22+
public function resolveDeprecatedSkippedClasses(): array
23+
{
24+
$skippedClassNames = array_keys($this->resolve());
25+
return array_filter($skippedClassNames, fn(string $class): bool => is_a($class, DeprecatedInterface::class, \true));
26+
}
27+
/**
28+
* @return array<class-string, string[]|null>
1729
*/
1830
public function resolve(): array
1931
{
2032
// disable cache in tests
2133
if (StaticPHPUnitEnvironment::isPHPUnitRun()) {
22-
$this->skippedClasses = null;
34+
$this->skippedClassesToFiles = null;
2335
}
2436
// already cached, even only empty array
25-
if ($this->skippedClasses !== null) {
26-
return $this->skippedClasses;
37+
if ($this->skippedClassesToFiles !== null) {
38+
return $this->skippedClassesToFiles;
2739
}
2840
$skip = SimpleParameterProvider::provideArrayParameter(Option::SKIP);
29-
$this->skippedClasses = [];
41+
$this->skippedClassesToFiles = [];
3042
foreach ($skip as $key => $value) {
3143
// e.g. [SomeClass::class] → shift values to [SomeClass::class => null]
3244
if (is_int($key)) {
@@ -40,8 +52,8 @@ public function resolve(): array
4052
if (!class_exists($key) && !interface_exists($key)) {
4153
continue;
4254
}
43-
$this->skippedClasses[$key] = $value;
55+
$this->skippedClassesToFiles[$key] = $value;
4456
}
45-
return $this->skippedClasses;
57+
return $this->skippedClassesToFiles;
4658
}
4759
}

vendor/composer/autoload_classmap.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2197,6 +2197,7 @@
21972197
'Rector\\Php81\\NodeFactory\\EnumFactory' => $baseDir . '/rules/Php81/NodeFactory/EnumFactory.php',
21982198
'Rector\\Php81\\NodeManipulator\\NullToStrictStringIntConverter' => $baseDir . '/rules/Php81/NodeManipulator/NullToStrictStringIntConverter.php',
21992199
'Rector\\Php81\\Rector\\Array_\\ArrayToFirstClassCallableRector' => $baseDir . '/rules/Php81/Rector/Array_/ArrayToFirstClassCallableRector.php',
2200+
'Rector\\Php81\\Rector\\Array_\\FirstClassCallableRector' => $baseDir . '/rules/Php81/Rector/Array_/FirstClassCallableRector.php',
22002201
'Rector\\Php81\\Rector\\ClassMethod\\NewInInitializerRector' => $baseDir . '/rules/Php81/Rector/ClassMethod/NewInInitializerRector.php',
22012202
'Rector\\Php81\\Rector\\Class_\\MyCLabsClassToEnumRector' => $baseDir . '/rules/Php81/Rector/Class_/MyCLabsClassToEnumRector.php',
22022203
'Rector\\Php81\\Rector\\Class_\\SpatieEnumClassToEnumRector' => $baseDir . '/rules/Php81/Rector/Class_/SpatieEnumClassToEnumRector.php',

vendor/composer/autoload_static.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2457,6 +2457,7 @@ class ComposerStaticInit74acfc93a8a335df0429191cbf621bda
24572457
'Rector\\Php81\\NodeFactory\\EnumFactory' => __DIR__ . '/../..' . '/rules/Php81/NodeFactory/EnumFactory.php',
24582458
'Rector\\Php81\\NodeManipulator\\NullToStrictStringIntConverter' => __DIR__ . '/../..' . '/rules/Php81/NodeManipulator/NullToStrictStringIntConverter.php',
24592459
'Rector\\Php81\\Rector\\Array_\\ArrayToFirstClassCallableRector' => __DIR__ . '/../..' . '/rules/Php81/Rector/Array_/ArrayToFirstClassCallableRector.php',
2460+
'Rector\\Php81\\Rector\\Array_\\FirstClassCallableRector' => __DIR__ . '/../..' . '/rules/Php81/Rector/Array_/FirstClassCallableRector.php',
24602461
'Rector\\Php81\\Rector\\ClassMethod\\NewInInitializerRector' => __DIR__ . '/../..' . '/rules/Php81/Rector/ClassMethod/NewInInitializerRector.php',
24612462
'Rector\\Php81\\Rector\\Class_\\MyCLabsClassToEnumRector' => __DIR__ . '/../..' . '/rules/Php81/Rector/Class_/MyCLabsClassToEnumRector.php',
24622463
'Rector\\Php81\\Rector\\Class_\\SpatieEnumClassToEnumRector' => __DIR__ . '/../..' . '/rules/Php81/Rector/Class_/SpatieEnumClassToEnumRector.php',

0 commit comments

Comments
 (0)