-
Notifications
You must be signed in to change notification settings - Fork 0
/
rector.php
50 lines (43 loc) · 1.92 KB
/
rector.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
declare(strict_types=1);
use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\SetList;
use Rector\Set\ValueObject\LevelSetList;
// Skip Rules
use Rector\Naming\Rector\Foreach_\RenameForeachValueVariableToMatchExprVariableRector;
use Rector\CodeQuality\Rector\Array_\ArrayThisCallToThisMethodCallRector;
use Rector\CodeQuality\Rector\Array_\CallableThisArrayToAnonymousFunctionRector;
use Rector\CodingStyle\Rector\ClassConst\RemoveFinalFromConstRector;
use Rector\CodingStyle\Rector\Encapsed\EncapsedStringsToSprintfRector;
use Rector\DeadCode\Rector\ClassMethod\RemoveUnusedPromotedPropertyRector;
use Rector\Php74\Rector\FuncCall\ArraySpreadInsteadOfArrayMergeRector;
use Rector\Php55\Rector\String_\StringClassNameToClassConstantRector;
return static function (RectorConfig $rectorConfig): void {
$rectorConfig->paths([
__DIR__
]);
// is there a file you need to skip?
$rectorConfig->skip([
__DIR__ . '/node_modules',
__DIR__ . '/dist',
CallableThisArrayToAnonymousFunctionRector::class,
RenameForeachValueVariableToMatchExprVariableRector::class, // Foreach single var
ArrayThisCallToThisMethodCallRector::class, // Transform add_action + add_filter
RemoveUnusedPromotedPropertyRector::class, // Rule PHP8.0
RemoveFinalFromConstRector::class, // Rule PHP8.1
ArraySpreadInsteadOfArrayMergeRector::class, // array_merge is easier to read than array_spread
StringClassNameToClassConstantRector::class, // defined('WP_CLI') replace defined(\WP_CLI::class)
EncapsedStringsToSprintfRector::class // sprintf replace
]);
// define sets of rules
$rectorConfig->sets([
LevelSetList::UP_TO_PHP_74,
SetList::CODE_QUALITY,
SetList::DEAD_CODE,
SetList::CODING_STYLE,
SetList::NAMING,
// PHP 8 Migration
// LevelSetList::UP_TO_PHP_81,
// SetList::TYPE_DECLARATION,
]);
};