Skip to content

Commit 7ffc550

Browse files
committed
rector config update
1 parent 57c75ad commit 7ffc550

File tree

1 file changed

+26
-28
lines changed

1 file changed

+26
-28
lines changed

rector.php

Lines changed: 26 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
<?php
22

33
use Rector\CodeQuality\Rector\BooleanAnd\SimplifyEmptyArrayCheckRector;
4+
use Rector\CodeQuality\Rector\Class_\CompleteDynamicPropertiesRector;
45
use Rector\CodeQuality\Rector\Expression\InlineIfToExplicitIfRector;
5-
use Rector\CodeQuality\Rector\For_\ForToForeachRector;
66
use Rector\CodeQuality\Rector\Foreach_\UnusedForeachValueToArrayKeysRector;
7-
use Rector\CodeQuality\Rector\FuncCall\AddPregQuoteDelimiterRector;
87
use Rector\CodeQuality\Rector\FuncCall\ChangeArrayPushToArrayAssignRector;
98
use Rector\CodeQuality\Rector\FuncCall\SimplifyRegexPatternRector;
109
use Rector\CodeQuality\Rector\FuncCall\SimplifyStrposLowerRector;
@@ -20,28 +19,32 @@
2019
use Rector\Config\RectorConfig;
2120
use Rector\Core\ValueObject\PhpVersion;
2221
use Rector\DeadCode\Rector\ClassMethod\RemoveUnusedPromotedPropertyRector;
23-
use Rector\DeadCode\Rector\MethodCall\RemoveEmptyMethodCallRector;
2422
use Rector\EarlyReturn\Rector\Foreach_\ChangeNestedForeachIfsToEarlyContinueRector;
2523
use Rector\EarlyReturn\Rector\If_\ChangeIfElseValueAssignToEarlyReturnRector;
2624
use Rector\EarlyReturn\Rector\If_\RemoveAlwaysElseRector;
2725
use Rector\EarlyReturn\Rector\Return_\PreparedValueToEarlyReturnRector;
2826
use Rector\Php55\Rector\String_\StringClassNameToClassConstantRector;
29-
use Rector\Php56\Rector\FunctionLike\AddDefaultValueForUndefinedVariableRector;
3027
use Rector\Php73\Rector\FuncCall\JsonThrowOnErrorRector;
3128
use Rector\Php73\Rector\FuncCall\StringifyStrNeedlesRector;
32-
use Rector\Php80\Rector\Class_\AnnotationToAttributeRector;
33-
use Rector\PHPUnit\Set\PHPUnitLevelSetList;
3429
use Rector\PHPUnit\Set\PHPUnitSetList;
35-
use Rector\PSR4\Rector\FileWithoutNamespace\NormalizeNamespaceByPSR4ComposerAutoloadRector;
30+
use Rector\Privatization\Rector\Property\PrivatizeFinalClassPropertyRector;
3631
use Rector\Set\ValueObject\LevelSetList;
3732
use Rector\Set\ValueObject\SetList;
33+
use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromAssignsRector;
3834

3935
return static function (RectorConfig $rectorConfig): void {
40-
$rectorConfig->sets([SetList::DEAD_CODE, LevelSetList::UP_TO_PHP_80, PHPUnitSetList::PHPUNIT_SPECIFIC_METHOD, PHPUnitLevelSetList::UP_TO_PHPUNIT_100]);
36+
$rectorConfig->sets([
37+
SetList::DEAD_CODE,
38+
LevelSetList::UP_TO_PHP_80,
39+
PHPUnitSetList::PHPUNIT_CODE_QUALITY,
40+
PHPUnitSetList::PHPUNIT_100,
41+
]);
42+
4143
$rectorConfig->parallel();
44+
4245
// The paths to refactor (can also be supplied with CLI arguments)
4346
$rectorConfig->paths([
44-
__DIR__ . '/src/',
47+
__DIR__ . '/app/',
4548
__DIR__ . '/tests/',
4649
]);
4750

@@ -76,30 +79,16 @@
7679
// Note: requires php 8
7780
RemoveUnusedPromotedPropertyRector::class,
7881

79-
// Ignore tests that might make calls without a result
80-
RemoveEmptyMethodCallRector::class => [
81-
__DIR__ . '/tests',
82-
],
83-
84-
// Ignore files that should not be namespaced
85-
NormalizeNamespaceByPSR4ComposerAutoloadRector::class => [
86-
__DIR__ . '/src/Common.php',
87-
__DIR__ . '/tests/_support/Views/',
88-
],
89-
9082
// May load view files directly when detecting classes
9183
StringClassNameToClassConstantRector::class,
84+
]);
9285

93-
// May be uninitialized on purpose
94-
AddDefaultValueForUndefinedVariableRector::class,
86+
// auto import fully qualified class names
87+
$rectorConfig->importNames();
9588

96-
// PHPUnit attributes
97-
AnnotationToAttributeRector::class,
98-
]);
9989
$rectorConfig->rule(SimplifyUselessVariableRector::class);
10090
$rectorConfig->rule(RemoveAlwaysElseRector::class);
10191
$rectorConfig->rule(CountArrayToEmptyArrayComparisonRector::class);
102-
$rectorConfig->rule(ForToForeachRector::class);
10392
$rectorConfig->rule(ChangeNestedForeachIfsToEarlyContinueRector::class);
10493
$rectorConfig->rule(ChangeIfElseValueAssignToEarlyReturnRector::class);
10594
$rectorConfig->rule(SimplifyStrposLowerRector::class);
@@ -112,10 +101,19 @@
112101
$rectorConfig->rule(UnusedForeachValueToArrayKeysRector::class);
113102
$rectorConfig->rule(ChangeArrayPushToArrayAssignRector::class);
114103
$rectorConfig->rule(UnnecessaryTernaryExpressionRector::class);
115-
$rectorConfig->rule(AddPregQuoteDelimiterRector::class);
116104
$rectorConfig->rule(SimplifyRegexPatternRector::class);
117105
$rectorConfig->rule(FuncGetArgsToVariadicParamRector::class);
118106
$rectorConfig->rule(MakeInheritedMethodVisibilitySameAsParentRector::class);
119107
$rectorConfig->rule(SimplifyEmptyArrayCheckRector::class);
120-
$rectorConfig->rule(NormalizeNamespaceByPSR4ComposerAutoloadRector::class);
108+
$rectorConfig
109+
->ruleWithConfiguration(TypedPropertyFromAssignsRector::class, [
110+
/**
111+
* 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
112+
* Set to true for projects that allow BC break
113+
*/
114+
TypedPropertyFromAssignsRector::INLINE_PUBLIC => true,
115+
]);
116+
$rectorConfig->rule(StringClassNameToClassConstantRector::class);
117+
$rectorConfig->rule(PrivatizeFinalClassPropertyRector::class);
118+
$rectorConfig->rule(CompleteDynamicPropertiesRector::class);
121119
};

0 commit comments

Comments
 (0)