Repository navigation
Expand file tree
/
Copy pathrector.php
More file actions
110 lines (100 loc) · 5.84 KB
/
Copy pathrector.php
File metadata and controls
110 lines (100 loc) · 5.84 KB
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
105
106
107
108
109
110
<?php
declare(strict_types=1);
use Rector\Caching\ValueObject\Storage\FileCacheStorage;
use Rector\CodeQuality\Rector\Class_\CompleteDynamicPropertiesRector;
use Rector\Config\RectorConfig;
use Rector\DeadCode\Rector\StaticCall\RemoveParentCallWithoutParentRector;
use Rector\EarlyReturn\Rector\Return_\ReturnBinaryOrToEarlyReturnRector;
use Rector\Php83\Rector\ClassMethod\AddOverrideAttributeToOverriddenMethodsRector;
use Rector\PHPUnit;
use Rector\Set\ValueObject\SetList;
use Rector\TypeDeclaration\Rector\ArrowFunction\AddArrowFunctionReturnTypeRector;
use Rector\TypeDeclaration\Rector\Closure\AddClosureVoidReturnTypeWhereNoReturnRector;
use Rector\TypeDeclaration\Rector\Closure\ClosureReturnTypeRector;
return RectorConfig::configure()
->withPaths([
__DIR__ . '/src',
__DIR__ . '/tests',
])
->withSets([
SetList::PHP_83,
SetList::CODE_QUALITY,
SetList::DEAD_CODE,
SetList::EARLY_RETURN,
SetList::TYPE_DECLARATION,
SetList::INSTANCEOF,
])
->withDowngradeSets(php83: true)
->withPreparedSets(
deadCode: true,
codeQuality: true,
typeDeclarations: true,
)
->withSkip([
__DIR__ . '/vendor',
AddClosureVoidReturnTypeWhereNoReturnRector::class,
ReturnBinaryOrToEarlyReturnRector::class,
ClosureReturnTypeRector::class,
AddArrowFunctionReturnTypeRector::class,
RemoveParentCallWithoutParentRector::class,
CompleteDynamicPropertiesRector::class,
AddOverrideAttributeToOverriddenMethodsRector::class,
])
->withRules([
// Laravel: classes / migrations / model structure
RectorLaravel\Rector\Class_\AnonymousMigrationsRector::class,
RectorLaravel\Rector\Class_\AddExtendsAnnotationToModelFactoriesRector::class,
RectorLaravel\Rector\ClassMethod\AddGenericReturnTypeToRelationsRector::class,
RectorLaravel\Rector\ClassMethod\MakeModelAttributesAndScopesProtectedRector::class,
// Laravel: query builder / Eloquent typing and relation helpers
RectorLaravel\Rector\MethodCall\EloquentWhereRelationTypeHintingParameterRector::class,
RectorLaravel\Rector\MethodCall\EloquentWhereTypeHintClosureParameterRector::class,
RectorLaravel\Rector\MethodCall\EloquentOrderByToLatestOrOldestRector::class,
// Laravel: collections / fluent chain cleanup
RectorLaravel\Rector\BooleanNot\AvoidNegatedCollectionContainsOrDoesntContainRector::class,
RectorLaravel\Rector\MethodCall\AvoidNegatedCollectionFilterOrRejectRector::class,
RectorLaravel\Rector\MethodCall\ConvertEnumerableToArrayToAllRector::class,
RectorLaravel\Rector\MethodCall\UnaliasCollectionMethodsRector::class,
RectorLaravel\Rector\MethodCall\ReverseConditionableMethodCallRector::class,
// Laravel: control flow / defaults / app helpers
RectorLaravel\Rector\If_\AbortIfRector::class,
RectorLaravel\Rector\If_\ReportIfRector::class,
RectorLaravel\Rector\Expr\AppEnvironmentComparisonToParameterRector::class,
RectorLaravel\Rector\FuncCall\AppToResolveRector::class,
// Laravel: framework helper normalizations + misc refactors
RectorLaravel\Rector\FuncCall\NotFilledBlankFuncCallToBlankFilledFuncCallRector::class,
RectorLaravel\Rector\FuncCall\RemoveDumpDataDeadCodeRector::class,
RectorLaravel\Rector\FuncCall\SleepFuncToSleepStaticCallRector::class,
RectorLaravel\Rector\FuncCall\ThrowIfAndThrowUnlessExceptionsToUseClassStringRector::class,
RectorLaravel\Rector\Expr\SubStrToStartsWithOrEndsWithStaticMethodCallRector\SubStrToStartsWithOrEndsWithStaticMethodCallRector::class,
RectorLaravel\Rector\Cast\DatabaseExpressionCastsToMethodCallRector::class,
RectorLaravel\Rector\PropertyFetch\OptionalToNullsafeOperatorRector::class,
RectorLaravel\Rector\PropertyFetch\ReplaceFakerInstanceWithHelperRector::class,
RectorLaravel\Rector\StaticCall\RouteActionCallableRector::class,
// Laravel :testing helpers
RectorLaravel\Rector\MethodCall\AssertStatusToAssertMethodRector::class,
RectorLaravel\Rector\MethodCall\JsonCallToExplicitJsonCallRector::class,
RectorLaravel\Rector\StaticCall\AssertWithClassStringToTypeHintedClosureRector::class,
RectorLaravel\Rector\StaticCall\CarbonSetTestNowToTravelToRector::class,
// PHPUnit: annotations to attributes + provider conventions
PHPUnit\AnnotationsToAttributes\Rector\Class_\CoversAnnotationWithValueToAttributeRector::class,
PHPUnit\AnnotationsToAttributes\Rector\ClassMethod\DataProviderAnnotationToAttributeRector::class,
PHPUnit\PHPUnit110\Rector\Class_\NamedArgumentForDataProviderRector::class,
PHPUnit\PHPUnit70\Rector\Class_\RemoveDataProviderTestPrefixRector::class,
PHPUnit\PHPUnit100\Rector\Class_\PublicDataProviderClassMethodRector::class,
PHPUnit\PHPUnit100\Rector\Class_\StaticDataProviderClassMethodRector::class,
// PHPUnit: assertion modernizations + code quality
PHPUnit\PHPUnit90\Rector\MethodCall\ReplaceAtMethodWithDesiredMatcherRector::class,
PHPUnit\PHPUnit80\Rector\MethodCall\SpecificAssertContainsRector::class,
PHPUnit\PHPUnit100\Rector\MethodCall\PropertyExistsWithoutAssertRector::class,
PHPUnit\CodeQuality\Rector\MethodCall\AssertNotOperatorRector::class,
PHPUnit\CodeQuality\Rector\MethodCall\AssertCompareOnCountableWithMethodToAssertCountRector::class,
PHPUnit\CodeQuality\Rector\MethodCall\FlipAssertRector::class,
PHPUnit\CodeQuality\Rector\FuncCall\AssertFuncCallToPHPUnitAssertRector::class,
PHPUnit\CodeQuality\Rector\Class_\PreferPHPUnitThisCallRector::class,
])
->withCache(
cacheDirectory: sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'rector',
cacheClass: FileCacheStorage::class,
)
->withParallel();