|
1 | 1 | <?php
|
2 | 2 |
|
3 |
| -use Rector\Config\RectorConfig; |
4 | 3 | use Rector\CodeQuality\Rector\BooleanAnd\SimplifyEmptyArrayCheckRector;
|
| 4 | +use Rector\CodeQuality\Rector\Class_\CompleteDynamicPropertiesRector; |
5 | 5 | use Rector\CodeQuality\Rector\Expression\InlineIfToExplicitIfRector;
|
6 | 6 | use Rector\CodeQuality\Rector\For_\ForToForeachRector;
|
7 | 7 | use Rector\CodeQuality\Rector\Foreach_\UnusedForeachValueToArrayKeysRector;
|
|
18 | 18 | use Rector\CodingStyle\Rector\ClassMethod\FuncGetArgsToVariadicParamRector;
|
19 | 19 | use Rector\CodingStyle\Rector\ClassMethod\MakeInheritedMethodVisibilitySameAsParentRector;
|
20 | 20 | use Rector\CodingStyle\Rector\FuncCall\CountArrayToEmptyArrayComparisonRector;
|
| 21 | +use Rector\Config\RectorConfig; |
21 | 22 | use Rector\Core\ValueObject\PhpVersion;
|
22 | 23 | use Rector\DeadCode\Rector\ClassMethod\RemoveUnusedPromotedPropertyRector;
|
23 | 24 | use Rector\DeadCode\Rector\MethodCall\RemoveEmptyMethodCallRector;
|
|
29 | 30 | use Rector\Php56\Rector\FunctionLike\AddDefaultValueForUndefinedVariableRector;
|
30 | 31 | use Rector\Php73\Rector\FuncCall\JsonThrowOnErrorRector;
|
31 | 32 | use Rector\Php73\Rector\FuncCall\StringifyStrNeedlesRector;
|
32 |
| -use Rector\Php74\Rector\Property\TypedPropertyRector; |
33 | 33 | use Rector\PHPUnit\Set\PHPUnitSetList;
|
| 34 | +use Rector\Privatization\Rector\Property\PrivatizeFinalClassPropertyRector; |
34 | 35 | use Rector\PSR4\Rector\FileWithoutNamespace\NormalizeNamespaceByPSR4ComposerAutoloadRector;
|
35 | 36 | use Rector\Set\ValueObject\LevelSetList;
|
36 | 37 | use Rector\Set\ValueObject\SetList;
|
| 38 | +use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromAssignsRector; |
37 | 39 |
|
38 | 40 | return static function (RectorConfig $rectorConfig): void {
|
39 |
| - $rectorConfig->sets([SetList::DEAD_CODE, LevelSetList::UP_TO_PHP_74, PHPUnitSetList::PHPUNIT_SPECIFIC_METHOD, PHPUnitSetList::PHPUNIT_80]); |
| 41 | + $rectorConfig->sets([ |
| 42 | + SetList::DEAD_CODE, |
| 43 | + LevelSetList::UP_TO_PHP_74, |
| 44 | + PHPUnitSetList::PHPUNIT_SPECIFIC_METHOD, |
| 45 | + PHPUnitSetList::PHPUNIT_100, |
| 46 | + ]); |
| 47 | + |
40 | 48 | $rectorConfig->parallel();
|
| 49 | + |
41 | 50 | // The paths to refactor (can also be supplied with CLI arguments)
|
42 | 51 | $rectorConfig->paths([
|
43 | 52 | __DIR__ . '/src/',
|
|
78 | 87 | __DIR__ . '/tests',
|
79 | 88 | ],
|
80 | 89 |
|
81 |
| - // Ignore files that should not be namespaced |
| 90 | + // Ignore files that should not be namespaced to their folder |
82 | 91 | NormalizeNamespaceByPSR4ComposerAutoloadRector::class => [
|
83 | 92 | __DIR__ . '/src/Helpers',
|
84 | 93 | ],
|
|
89 | 98 | // May be uninitialized on purpose
|
90 | 99 | AddDefaultValueForUndefinedVariableRector::class,
|
91 | 100 | ]);
|
| 101 | + |
| 102 | + // auto import fully qualified class names |
| 103 | + $rectorConfig->importNames(); |
| 104 | + |
92 | 105 | $rectorConfig->rule(SimplifyUselessVariableRector::class);
|
93 | 106 | $rectorConfig->rule(RemoveAlwaysElseRector::class);
|
94 | 107 | $rectorConfig->rule(CountArrayToEmptyArrayComparisonRector::class);
|
|
112 | 125 | $rectorConfig->rule(SimplifyEmptyArrayCheckRector::class);
|
113 | 126 | $rectorConfig->rule(NormalizeNamespaceByPSR4ComposerAutoloadRector::class);
|
114 | 127 | $rectorConfig
|
115 |
| - ->ruleWithConfiguration(TypedPropertyRector::class, [ |
116 |
| - // Set to false if you use in libraries, or it does create breaking changes. |
117 |
| - TypedPropertyRector::INLINE_PUBLIC => true, |
| 128 | + ->ruleWithConfiguration(TypedPropertyFromAssignsRector::class, [ |
| 129 | + /** |
| 130 | + * The INLINE_PUBLIC value is default to false to avoid BC break, if you use for libraries and want to preserve BC break, you don't need to configure it, as it included in LevelSetList::UP_TO_PHP_74 |
| 131 | + * Set to true for projects that allow BC break |
| 132 | + */ |
| 133 | + TypedPropertyFromAssignsRector::INLINE_PUBLIC => true, |
118 | 134 | ]);
|
| 135 | + $rectorConfig->rule(StringClassNameToClassConstantRector::class); |
| 136 | + $rectorConfig->rule(PrivatizeFinalClassPropertyRector::class); |
| 137 | + $rectorConfig->rule(CompleteDynamicPropertiesRector::class); |
119 | 138 | };
|
0 commit comments