forked from redaxo/redaxo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrector.php
85 lines (73 loc) · 3.58 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
<?php
declare(strict_types=1);
use Rector\CodeQuality\Rector\BooleanNot\SimplifyDeMorganBinaryRector;
use Rector\CodeQuality\Rector\Identical\SimplifyBoolIdenticalTrueRector;
use Rector\CodeQuality\Rector\Identical\SimplifyConditionsRector;
use Rector\CodeQuality\Rector\If_\SimplifyIfReturnBoolRector;
use Rector\CodeQuality\Rector\Ternary\UnnecessaryTernaryExpressionRector;
use Rector\Core\Configuration\Option;
use Rector\Core\ValueObject\PhpVersion;
use Rector\Php80\Rector\Identical\StrEndsWithRector;
use Rector\Php80\Rector\Identical\StrStartsWithRector;
use Rector\Php80\Rector\NotIdentical\StrContainsRector;
use Rector\Set\ValueObject\SetList;
use Redaxo\Rector\Rule\UnderscoreToCamelCasePropertyNameRector;
use Redaxo\Rector\Rule\UnderscoreToCamelCaseVariableNameRector;
use Redaxo\Rector\Util\UnderscoreCamelCaseConflictingNameGuard;
use Redaxo\Rector\Util\UnderscoreCamelCaseExpectedNameResolver;
use Redaxo\Rector\Util\UnderscoreCamelCasePropertyRenamer;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
require_once __DIR__.'/.tools/rector/autoload.php';
return static function (ContainerConfigurator $containerConfigurator): void {
// get parameters
$parameters = $containerConfigurator->parameters();
$parameters->set(Option::BOOTSTRAP_FILES, [
__DIR__.'/.tools/constants.php',
]);
// this list will grow over time.
// to make sure we can review every transformation and not introduce unseen bugs
$parameters->set(Option::PATHS, [
// restrict to core and core addons, ignore other locally installed addons
'redaxo/src/core/',
'redaxo/src/addons/backup/',
'redaxo/src/addons/be_style/',
'redaxo/src/addons/cronjob/',
'redaxo/src/addons/debug/',
'redaxo/src/addons/install/',
'redaxo/src/addons/media_manager/',
'redaxo/src/addons/mediapool/',
'redaxo/src/addons/metainfo/',
'redaxo/src/addons/phpmailer/',
'redaxo/src/addons/project/',
'redaxo/src/addons/structure/',
'redaxo/src/addons/users/',
]);
$parameters->set(Option::SKIP, [
'redaxo/src/core/vendor',
'redaxo/src/addons/backup/vendor',
'redaxo/src/addons/be_style/vendor',
'redaxo/src/addons/debug/vendor',
'redaxo/src/addons/phpmailer/vendor',
]);
$parameters->set(Option::PHP_VERSION_FEATURES, PhpVersion::PHP_80);
// get services (needed for register a single rule)
$services = $containerConfigurator->services();
// we will grow this rector list step by step.
// after some basic rectors have been enabled we can finally enable whole-sets (when diffs get stable and reviewable)
// $services->set(Rector\SOLID\Rector\If_\ChangeAndIfToEarlyReturnRector::class);
$services->set(SimplifyBoolIdenticalTrueRector::class);
$services->set(SimplifyConditionsRector::class);
$services->set(SimplifyDeMorganBinaryRector::class);
$services->set(SimplifyIfReturnBoolRector::class);
$services->set(StrContainsRector::class);
$services->set(StrEndsWithRector::class);
$services->set(StrStartsWithRector::class);
// Util services for own rules
$services->set(UnderscoreCamelCaseConflictingNameGuard::class)->autowire();
$services->set(UnderscoreCamelCaseExpectedNameResolver::class)->autowire();
$services->set(UnderscoreCamelCasePropertyRenamer::class)->autowire();
// Own rules
$services->set(UnderscoreToCamelCasePropertyNameRector::class);
$services->set(UnderscoreToCamelCaseVariableNameRector::class);
$services->set(UnnecessaryTernaryExpressionRector::class);
};