Skip to content

Commit 786ef69

Browse files
committed
Update rector.php
From shield.
1 parent 0bf0998 commit 786ef69

File tree

2 files changed

+36
-5
lines changed

2 files changed

+36
-5
lines changed

rector.php

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22

33
use Rector\CodeQuality\Rector\BooleanAnd\SimplifyEmptyArrayCheckRector;
4+
use Rector\CodeQuality\Rector\Class_\CompleteDynamicPropertiesRector;
45
use Rector\CodeQuality\Rector\Expression\InlineIfToExplicitIfRector;
56
use Rector\CodeQuality\Rector\For_\ForToForeachRector;
67
use Rector\CodeQuality\Rector\Foreach_\UnusedForeachValueToArrayKeysRector;
@@ -30,14 +31,22 @@
3031
use Rector\Php73\Rector\FuncCall\JsonThrowOnErrorRector;
3132
use Rector\Php73\Rector\FuncCall\StringifyStrNeedlesRector;
3233
use Rector\PHPUnit\Set\PHPUnitSetList;
34+
use Rector\Privatization\Rector\Property\PrivatizeFinalClassPropertyRector;
3335
use Rector\PSR4\Rector\FileWithoutNamespace\NormalizeNamespaceByPSR4ComposerAutoloadRector;
3436
use Rector\Set\ValueObject\LevelSetList;
3537
use Rector\Set\ValueObject\SetList;
3638
use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromAssignsRector;
3739

3840
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+
4048
$rectorConfig->parallel();
49+
4150
// The paths to refactor (can also be supplied with CLI arguments)
4251
$rectorConfig->paths([
4352
__DIR__ . '/src/',
@@ -78,7 +87,7 @@
7887
__DIR__ . '/tests',
7988
],
8089

81-
// Ignore files that should not be namespaced
90+
// Ignore files that should not be namespaced to their folder
8291
NormalizeNamespaceByPSR4ComposerAutoloadRector::class => [
8392
__DIR__ . '/src/Helpers',
8493
],
@@ -89,6 +98,10 @@
8998
// May be uninitialized on purpose
9099
AddDefaultValueForUndefinedVariableRector::class,
91100
]);
101+
102+
// auto import fully qualified class names
103+
$rectorConfig->importNames();
104+
92105
$rectorConfig->rule(SimplifyUselessVariableRector::class);
93106
$rectorConfig->rule(RemoveAlwaysElseRector::class);
94107
$rectorConfig->rule(CountArrayToEmptyArrayComparisonRector::class);
@@ -116,4 +129,7 @@
116129
// Set to false if you use in libraries, or it does create breaking changes.
117130
TypedPropertyFromAssignsRector::INLINE_PUBLIC => true,
118131
]);
132+
$rectorConfig->rule(StringClassNameToClassConstantRector::class);
133+
$rectorConfig->rule(PrivatizeFinalClassPropertyRector::class);
134+
$rectorConfig->rule(CompleteDynamicPropertiesRector::class);
119135
};

src/Template/rector.php

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?php
22

33
use Rector\CodeQuality\Rector\BooleanAnd\SimplifyEmptyArrayCheckRector;
4+
use Rector\CodeQuality\Rector\Class_\CompleteDynamicPropertiesRector;
45
use Rector\CodeQuality\Rector\Expression\InlineIfToExplicitIfRector;
56
use Rector\CodeQuality\Rector\For_\ForToForeachRector;
67
use Rector\CodeQuality\Rector\Foreach_\UnusedForeachValueToArrayKeysRector;
@@ -29,16 +30,23 @@
2930
use Rector\Php56\Rector\FunctionLike\AddDefaultValueForUndefinedVariableRector;
3031
use Rector\Php73\Rector\FuncCall\JsonThrowOnErrorRector;
3132
use Rector\Php73\Rector\FuncCall\StringifyStrNeedlesRector;
32-
use Rector\PHPUnit\Set\PHPUnitLevelSetList;
3333
use Rector\PHPUnit\Set\PHPUnitSetList;
34+
use Rector\Privatization\Rector\Property\PrivatizeFinalClassPropertyRector;
3435
use Rector\PSR4\Rector\FileWithoutNamespace\NormalizeNamespaceByPSR4ComposerAutoloadRector;
3536
use Rector\Set\ValueObject\LevelSetList;
3637
use Rector\Set\ValueObject\SetList;
3738
use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromAssignsRector;
3839

3940
return static function (RectorConfig $rectorConfig): void {
40-
$rectorConfig->sets([SetList::DEAD_CODE, LevelSetList::UP_TO_PHP_74, PHPUnitSetList::PHPUNIT_SPECIFIC_METHOD, PHPUnitLevelSetList::UP_TO_PHPUNIT_100]);
41+
$rectorConfig->sets([
42+
SetList::DEAD_CODE,
43+
LevelSetList::UP_TO_PHP_74,
44+
PHPUnitSetList::PHPUNIT_SPECIFIC_METHOD,
45+
PHPUnitSetList::PHPUNIT_100,
46+
]);
47+
4148
$rectorConfig->parallel();
49+
4250
// The paths to refactor (can also be supplied with CLI arguments)
4351
$rectorConfig->paths([
4452
__DIR__ . '/app/',
@@ -80,7 +88,7 @@
8088
__DIR__ . '/tests',
8189
],
8290

83-
// Ignore files that should not be namespaced
91+
// Ignore files that should not be namespaced to their folder
8492
NormalizeNamespaceByPSR4ComposerAutoloadRector::class => [
8593
__DIR__ . '/app/Helpers',
8694
],
@@ -91,6 +99,10 @@
9199
// May be uninitialized on purpose
92100
AddDefaultValueForUndefinedVariableRector::class,
93101
]);
102+
103+
// auto import fully qualified class names
104+
$rectorConfig->importNames();
105+
94106
$rectorConfig->rule(SimplifyUselessVariableRector::class);
95107
$rectorConfig->rule(RemoveAlwaysElseRector::class);
96108
$rectorConfig->rule(CountArrayToEmptyArrayComparisonRector::class);
@@ -118,4 +130,7 @@
118130
// Set to false if you use in libraries, or it does create breaking changes.
119131
TypedPropertyFromAssignsRector::INLINE_PUBLIC => true,
120132
]);
133+
$rectorConfig->rule(StringClassNameToClassConstantRector::class);
134+
$rectorConfig->rule(PrivatizeFinalClassPropertyRector::class);
135+
$rectorConfig->rule(CompleteDynamicPropertiesRector::class);
121136
};

0 commit comments

Comments
 (0)