forked from deprecated-packages/symplify
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rector.php
110 lines (94 loc) · 4.79 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<?php
declare(strict_types=1);
use PHPUnit\Framework\TestCase;
use Rector\CodeQuality\Rector\Array_\CallableThisArrayToAnonymousFunctionRector;
use Rector\CodingStyle\Enum\PreferenceSelfThis;
use Rector\CodingStyle\Rector\ClassMethod\UnSpreadOperatorRector;
use Rector\CodingStyle\Rector\MethodCall\PreferThisOrSelfMethodCallRector;
use Rector\Core\Configuration\Option;
use Rector\Naming\Rector\Foreach_\RenameForeachValueVariableToMatchExprVariableRector;
use Rector\Php55\Rector\String_\StringClassNameToClassConstantRector;
use Rector\Php74\Rector\Closure\ClosureToArrowFunctionRector;
use Rector\Php74\Rector\Property\TypedPropertyRector;
use Rector\Php80\Rector\Class_\ClassPropertyAssignToConstructorPromotionRector;
use Rector\Php80\Rector\Switch_\ChangeSwitchToMatchRector;
use Rector\PHPUnit\Set\PHPUnitSetList;
use Rector\Set\ValueObject\SetList;
use Rector\TypeDeclaration\Rector\FunctionLike\ParamTypeDeclarationRector;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use Symplify\SymfonyPhpConfig\ValueObjectInliner;
return static function (ContainerConfigurator $containerConfigurator): void {
$containerConfigurator->import(SetList::CODE_QUALITY);
$containerConfigurator->import(SetList::CODE_QUALITY_STRICT);
$containerConfigurator->import(SetList::DEAD_CODE);
$containerConfigurator->import(SetList::CODING_STYLE);
$containerConfigurator->import(SetList::PHP_54);
$containerConfigurator->import(SetList::PHP_55);
$containerConfigurator->import(SetList::PHP_56);
$containerConfigurator->import(SetList::PHP_70);
$containerConfigurator->import(SetList::PHP_71);
$containerConfigurator->import(SetList::PHP_72);
$containerConfigurator->import(SetList::PHP_73);
$containerConfigurator->import(SetList::PHP_74);
$containerConfigurator->import(SetList::PHP_80);
$containerConfigurator->import(SetList::TYPE_DECLARATION);
$containerConfigurator->import(SetList::TYPE_DECLARATION_STRICT);
$containerConfigurator->import(SetList::NAMING);
$containerConfigurator->import(SetList::PRIVATIZATION);
$containerConfigurator->import(SetList::EARLY_RETURN);
$containerConfigurator->import(PHPUnitSetList::PHPUNIT_CODE_QUALITY);
$services = $containerConfigurator->services();
// PHP 8+
$services->set(ClosureToArrowFunctionRector::class);
$services->set(ClassPropertyAssignToConstructorPromotionRector::class);
$services->set(ChangeSwitchToMatchRector::class);
$services->set(ClassPropertyAssignToConstructorPromotionRector::class);
$services->set(TypedPropertyRector::class);
$services->set(StringClassNameToClassConstantRector::class)
->call('configure', [[
StringClassNameToClassConstantRector::CLASSES_TO_SKIP => [
'Error',
'Exception',
'Doctrine\ORM\EntityManagerInterface',
'Doctrine\ORM\EntityManager',
'Nette\Application\UI\Template',
'Nette\DI\Attributes\Inject',
'Nette\Bridges\ApplicationLatte\Template',
'Nette\Bridges\ApplicationLatte\DefaultTemplate',
],
]]);
$services->set(PreferThisOrSelfMethodCallRector::class)
->call('configure', [[
PreferThisOrSelfMethodCallRector::TYPE_TO_PREFERENCE => [
TestCase::class => ValueObjectInliner::inline(PreferenceSelfThis::PREFER_THIS()),
],
]]);
$parameters = $containerConfigurator->parameters();
$parameters->set(Option::AUTO_IMPORT_NAMES, true);
$parameters->set(Option::AUTOLOAD_PATHS, [__DIR__ . '/tests/bootstrap.php', __DIR__ . '/ecs.php']);
$parameters->set(Option::PATHS, [__DIR__ . '/packages']);
$parameters->set(Option::SKIP, [
'*/scoper.php',
'*/vendor/*',
'*/init/*',
'*/Source/*',
'*/Fixture/*',
'*/Fixture*/*',
'*/ChangedFilesDetectorSource/*',
__DIR__ . '/packages/monorepo-builder/templates',
__DIR__ . '/packages/easy-coding-standard/build/build-preload.php',
// many false positives related to file class autoload
__DIR__ . '/packages/easy-coding-standard/bin/ecs.php',
# tests
__DIR__ . '/packages/vendor-patches/tests/Finder/VendorFilesFinderSource/Vendor/some/package/src/PackageClass.php',
// many false postivies
RenameForeachValueVariableToMatchExprVariableRector::class,
// buggy with parent interface contract
ParamTypeDeclarationRector::class => [__DIR__ . '/packages/skipper/src/SkipVoter/*SkipVoter.php'],
UnSpreadOperatorRector::class => [__DIR__ . '/packages/git-wrapper'],
CallableThisArrayToAnonymousFunctionRector::class => [
// not a callable, accidental array
__DIR__ . '/packages/phpstan-rules/src/Rules/',
],
]);
};