-
Notifications
You must be signed in to change notification settings - Fork 2
/
rector.php
54 lines (47 loc) · 2.03 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
51
52
53
54
<?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__ . '/bin',
__DIR__ . '/cache',
__DIR__ . '/gulp',
__DIR__ . '/logs',
__DIR__ . '/vendor',
__DIR__ . '/web',
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,
]);
};