-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
rector.php
104 lines (91 loc) · 3.93 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
<?php
declare(strict_types=1);
use Rector\CodeQuality\Rector\FunctionLike\SimplifyUselessVariableRector;
use Rector\CodeQuality\Rector\Identical\FlipTypeControlToUseExclusiveTypeRector;
use Rector\CodeQuality\Rector\If_\CombineIfRector;
use Rector\CodeQuality\Rector\If_\ShortenElseIfRector;
use Rector\CodeQuality\Rector\If_\SimplifyIfElseToTernaryRector;
use Rector\CodingStyle\Rector\Catch_\CatchExceptionNameMatchingTypeRector;
use Rector\Config\RectorConfig;
use Rector\DeadCode\Rector\Assign\RemoveUnusedVariableAssignRector;
use Rector\DeadCode\Rector\ClassMethod\RemoveUselessReturnTagRector;
use Rector\DeadCode\Rector\If_\RemoveAlwaysTrueIfConditionRector;
use Rector\DeadCode\Rector\Node\RemoveNonExistingVarAnnotationRector;
use Rector\Php81\Rector\Array_\FirstClassCallableRector;
use Rector\Php81\Rector\FuncCall\NullToStrictStringFuncCallArgRector;
use Rector\Php83\Rector\ClassMethod\AddOverrideAttributeToOverriddenMethodsRector;
use Rector\Strict\Rector\Ternary\DisallowedShortTernaryRuleFixerRector;
use Rector\ValueObject\PhpVersion;
return RectorConfig::configure()
->withPhpVersion(PhpVersion::PHP_83)
->withPaths([
__DIR__ . '/packages',
__DIR__ . '/tests/bin',
__DIR__ . '/tests/config',
__DIR__ . '/tests/public',
__DIR__ . '/tests/src',
])
->withImportNames(importShortClasses: false)
->withPreparedSets(
deadCode: true,
codeQuality: true,
codingStyle: true,
typeDeclarations: true,
privatization: true,
instanceOf: true,
strictBooleans: true,
symfonyCodeQuality: true,
doctrineCodeQuality: true,
)
// uncomment to reach your current PHP version
->withPhpSets(php82: true)
->withRules([
AddOverrideAttributeToOverriddenMethodsRector::class,
])
->withSkip([
AddOverrideAttributeToOverriddenMethodsRector::class => [
// for symfony 6 compatibility
__DIR__ . '/packages/rekapager-api-platform/src/Implementation/PagerNormalizer.php',
],
SimplifyUselessVariableRector::class => [
// used for demo
__DIR__ . '/tests/src/App/PageableGenerator/*',
],
RemoveUselessReturnTagRector::class => [
// workaround psalm "@return static"
__DIR__ . '/packages/rekapager-contracts/src/PageableInterface.php',
],
RemoveNonExistingVarAnnotationRector::class => [
// workaround psalm
__DIR__ . '/packages/rekapager-symfony-bridge/src/PageIdentifierEncoderLocator.php',
],
// static analysis tools don't like this
RemoveUnusedVariableAssignRector::class,
// cognitive burden to many people
SimplifyIfElseToTernaryRector::class,
CombineIfRector::class => [
// this 'fixes' symfony makerbundle boilerplate code
__DIR__ . '/tests/src/App/Entity/*',
],
// potential cognitive burden
FlipTypeControlToUseExclusiveTypeRector::class,
// results in too long variables
CatchExceptionNameMatchingTypeRector::class,
// makes code unreadable
DisallowedShortTernaryRuleFixerRector::class,
RemoveAlwaysTrueIfConditionRector::class => [
// dealing with legacy code
__DIR__ . '/packages/rekapager-doctrine-dbal-adapter/src/QueryBuilderAdapter.php',
],
NullToStrictStringFuncCallArgRector::class => [
// false positive
__DIR__ . '/packages/rekapager-doctrine-dbal-adapter/src/QueryBuilderAdapter.php',
],
ShortenElseIfRector::class => [
__DIR__ . '/packages/rekapager-adapter-common/src/KeysetExpressionCalculator.php',
],
FirstClassCallableRector::class => [
__DIR__ . '/packages/rekapager-doctrine-dbal-adapter/src/QueryBuilderAdapter.php',
__DIR__ . '/packages/rekapager-doctrine-orm-adapter/src/QueryBuilderAdapter.php',
],
]);