|
1 | 1 | <?php
|
2 | 2 |
|
| 3 | +use PhpParser\Node\Expr\Cast\Bool_; |
| 4 | +use PhpParser\Node\Expr\Cast\Double; |
| 5 | +use PhpParser\Node\Expr\Cast\Int_; |
3 | 6 | use Rector\Config\RectorConfig;
|
4 | 7 | use Rector\DeadCode\Rector\ClassLike\RemoveAnnotationRector;
|
5 | 8 | use Rector\Php70\Rector\StmtsAwareInterface\IfIssetToCoalescingRector;
|
6 | 9 | use Rector\Php71\Rector\FuncCall\RemoveExtraParametersRector;
|
7 | 10 | use Rector\Php80\Rector\Switch_\ChangeSwitchToMatchRector;
|
8 | | -use Rector\PHPUnit\PHPUnit100\Rector\Class_\StaticDataProviderClassMethodRector; |
9 | | -use Rector\PHPUnit\Set\PHPUnitSetList; |
10 | | -use Rector\Set\ValueObject\LevelSetList; |
| 11 | +use Rector\Renaming\Rector\Cast\RenameCastRector; |
| 12 | +use Rector\Renaming\ValueObject\RenameCast; |
11 | 13 |
|
12 | | -return staticfunction (RectorConfig$rectorConfig): void { |
13 | | - $rectorConfig->paths([ |
| 14 | +return RectorConfig::configure() |
| 15 | + ->withPaths([ |
14 | 16 | __DIR__ . '/examples',
|
15 | 17 | __DIR__ . '/src',
|
16 | 18 | __DIR__ . '/tests',
|
17 | 19 | __DIR__ . '/tools',
|
18 | | - ]); |
19 | | - |
20 | | - // Modernize code |
21 | | - $rectorConfig->sets([ |
22 | | - LevelSetList::UP_TO_PHP_74, |
23 | | - PHPUnitSetList::PHPUNIT_100, |
24 | | - ]); |
25 | | - |
26 | | - $rectorConfig->rule(ChangeSwitchToMatchRector::class); |
27 | | - $rectorConfig->rule(StaticDataProviderClassMethodRector::class); |
28 | | - |
| 20 | + ]) |
| 21 | + ->withPhpSets(php74: true) |
| 22 | + ->withComposerBased(phpunit: true) |
| 23 | + ->withRules([ |
| 24 | + ChangeSwitchToMatchRector::class, |
| 25 | + ]) |
| 26 | + // All classes are public API by default, unless marked with @internal. |
| 27 | + ->withConfiguredRule(RemoveAnnotationRector::class, ['api']) |
| 28 | + // Fix PHP 8.5 deprecations |
| 29 | + ->withConfiguredRule( |
| 30 | + RenameCastRector::class, |
| 31 | + [ |
| 32 | + new RenameCast(Int_::class, Int_::KIND_INTEGER, Int_::KIND_INT), |
| 33 | + new RenameCast(Bool_::class, Bool_::KIND_BOOLEAN, Bool_::KIND_BOOL), |
| 34 | + new RenameCast(Double::class, Double::KIND_DOUBLE, Double::KIND_FLOAT), |
| 35 | + ], |
| 36 | + ) |
29 | 37 | // phpcs:disable Squiz.Arrays.ArrayDeclaration.KeySpecified
|
30 | | - $rectorConfig->skip([ |
| 38 | + ->withSkip([ |
31 | 39 | RemoveExtraParametersRector::class,
|
32 | 40 | // Do not use ternaries extensively
|
33 | 41 | IfIssetToCoalescingRector::class,
|
34 | 42 | ChangeSwitchToMatchRector::class => [
|
35 | 43 | __DIR__ . '/tests/SpecTests/Operation.php',
|
36 | 44 | ],
|
37 | | - ]); |
| 45 | + ]) |
38 | 46 | // phpcs:enable
|
39 | | - |
40 | | - // All classes are public API by default, unless marked with @internal. |
41 | | - $rectorConfig->ruleWithConfiguration(RemoveAnnotationRector::class, ['api']); |
42 | | -}; |
| 47 | + ->withImportNames(importNames: false, removeUnusedImports: true); |
0 commit comments