|
16 | 16 | */ |
17 | 17 |
|
18 | 18 | use Ergebnis\Rector\Rules\Arrays\SortAssociativeArrayByKeyRector; |
19 | | -use Guanguans\RectorRules\Rector\Array_\SimplifyListIndexRector; |
20 | | -use Guanguans\RectorRules\Rector\Class_\UpdateRectorRefactorParamDocblockFromNodeTypesRector; |
21 | | -use Guanguans\RectorRules\Rector\Declare_\AddNoinspectionDocblockToDeclareRector; |
22 | | -use Guanguans\RectorRules\Rector\Name\RenameToPsrNameRector; |
23 | | -use Guanguans\RectorRules\Rector\Namespace_\RemoveNamespaceRector; |
24 | | -use Guanguans\RectorRules\Rector\New_\NewExceptionToNewAnonymousExtendsExceptionImplementsRector; |
25 | | -use Guanguans\SoarPHP\Contracts\Throwable; |
| 19 | +use Ergebnis\Rector\Rules\Faker\GeneratorPropertyFetchToMethodCallRector; |
| 20 | +use Guanguans\RectorRules\Rector\File\AddNoinspectionDocblockToFileFirstStmtRector; |
| 21 | +use Guanguans\RectorRules\Rector\Name\RenameToConventionalCaseNameRector; |
| 22 | +use Guanguans\RectorRules\Set\SetList; |
26 | 23 | use Guanguans\SoarPHP\Support\Rectors\AddDocCommentForHasOptionsRector; |
27 | | -use Illuminate\Support\Str; |
28 | 24 | use PhpParser\NodeVisitor\ParentConnectingVisitor; |
29 | 25 | use Rector\CodeQuality\Rector\If_\ExplicitBoolCompareRector; |
30 | 26 | use Rector\CodeQuality\Rector\LogicalAnd\LogicalToBooleanRector; |
|
34 | 30 | use Rector\CodingStyle\Rector\Closure\StaticClosureRector; |
35 | 31 | use Rector\CodingStyle\Rector\Encapsed\EncapsedStringsToSprintfRector; |
36 | 32 | use Rector\CodingStyle\Rector\Encapsed\WrapEncapsedVariableInCurlyBracesRector; |
| 33 | +use Rector\CodingStyle\Rector\Enum_\EnumCaseToPascalCaseRector; |
37 | 34 | use Rector\CodingStyle\Rector\FuncCall\ArraySpreadInsteadOfArrayMergeRector; |
38 | 35 | use Rector\CodingStyle\Rector\Stmt\NewlineAfterStatementRector; |
39 | 36 | use Rector\Config\RectorConfig; |
40 | 37 | use Rector\DeadCode\Rector\ClassLike\RemoveAnnotationRector; |
41 | 38 | use Rector\EarlyReturn\Rector\If_\ChangeOrIfContinueToMultiContinueRector; |
42 | 39 | use Rector\EarlyReturn\Rector\Return_\ReturnBinaryOrToEarlyReturnRector; |
43 | 40 | use Rector\Php73\Rector\FuncCall\JsonThrowOnErrorRector; |
44 | | -use Rector\Php80\Rector\Class_\AnnotationToAttributeRector; |
45 | | -use Rector\Php80\ValueObject\AnnotationToAttribute; |
46 | | -use Rector\PHPUnit\Set\PHPUnitSetList; |
47 | | -use Rector\Renaming\Rector\FuncCall\RenameFunctionRector; |
48 | | -use Rector\Transform\Rector\StaticCall\StaticCallToFuncCallRector; |
49 | | -use Rector\Transform\ValueObject\StaticCallToFuncCall; |
| 41 | +use Rector\TypeDeclaration\Rector\StmtsAwareInterface\SafeDeclareStrictTypesRector; |
50 | 42 | use Rector\ValueObject\PhpVersion; |
51 | | -use Rector\ValueObject\Visibility; |
52 | | -use Rector\Visibility\Rector\ClassMethod\ChangeMethodVisibilityRector; |
53 | | -use Rector\Visibility\ValueObject\ChangeMethodVisibility; |
54 | | -use function Guanguans\SoarPHP\Support\classes; |
55 | 43 |
|
56 | 44 | return RectorConfig::configure() |
57 | 45 | ->withPaths([ |
|
90 | 78 | naming: true, |
91 | 79 | instanceOf: true, |
92 | 80 | earlyReturn: true, |
| 81 | + // strictBooleans: true, |
93 | 82 | // carbon: true, |
| 83 | + rectorPreset: true, |
| 84 | + phpunitCodeQuality: true, |
94 | 85 | ) |
95 | | - ->withSets([ |
96 | | - PHPUnitSetList::PHPUNIT_100, |
97 | | - ]) |
| 86 | + ->withSets([SetList::ALL]) |
98 | 87 | ->withRules([ |
99 | 88 | AddDocCommentForHasOptionsRector::class, |
100 | | - RemoveNamespaceRector::class, |
101 | | - SimplifyListIndexRector::class, |
102 | | - SortAssociativeArrayByKeyRector::class, |
103 | | - UpdateRectorRefactorParamDocblockFromNodeTypesRector::class, |
104 | | - |
105 | 89 | ArraySpreadInsteadOfArrayMergeRector::class, |
| 90 | + EnumCaseToPascalCaseRector::class, |
| 91 | + GeneratorPropertyFetchToMethodCallRector::class, |
106 | 92 | JsonThrowOnErrorRector::class, |
| 93 | + SafeDeclareStrictTypesRector::class, |
| 94 | + SortAssociativeArrayByKeyRector::class, |
107 | 95 | StaticArrowFunctionRector::class, |
108 | 96 | StaticClosureRector::class, |
109 | 97 | ]) |
110 | | - ->withConfiguredRule(AddNoinspectionDocblockToDeclareRector::class, [ |
| 98 | + ->withConfiguredRule(AddNoinspectionDocblockToFileFirstStmtRector::class, [ |
111 | 99 | '*/tests/*' => [ |
112 | 100 | 'AnonymousFunctionStaticInspection', |
113 | 101 | 'NullPointerExceptionInspection', |
|
119 | 107 | 'StaticClosureCanBeUsedInspection', |
120 | 108 | ], |
121 | 109 | ]) |
122 | | - ->withConfiguredRule(NewExceptionToNewAnonymousExtendsExceptionImplementsRector::class, [Throwable::class]) |
123 | 110 | ->registerDecoratingNodeVisitor(ParentConnectingVisitor::class) |
124 | | - ->withConfiguredRule(RenameToPsrNameRector::class, [ |
| 111 | + ->withConfiguredRule(RenameToConventionalCaseNameRector::class, [ |
125 | 112 | 'assertMatches*Snapshot', |
126 | 113 | 'MIT', |
127 | 114 | ]) |
|
132 | 119 | 'phpstan-ignore-next-line', |
133 | 120 | 'psalm-suppress', |
134 | 121 | ]) |
135 | | - ->withConfiguredRule(StaticCallToFuncCallRector::class, [ |
136 | | - new StaticCallToFuncCall(Str::class, 'of', 'str'), |
137 | | - ]) |
138 | | - ->withConfiguredRule( |
139 | | - AnnotationToAttributeRector::class, |
140 | | - classes(static fn (string $class): bool => str_starts_with($class, 'PhpBench\Attributes')) |
141 | | - ->filter(static fn (ReflectionClass $reflectionClass): bool => $reflectionClass->isInstantiable()) |
142 | | - ->map(static fn (ReflectionClass $reflectionClass): AnnotationToAttribute => new AnnotationToAttribute( |
143 | | - lcfirst($reflectionClass->getShortName()), |
144 | | - $reflectionClass->getName(), |
145 | | - // [], |
146 | | - // true |
147 | | - )) |
148 | | - ->all(), |
149 | | - ) |
150 | | - ->withConfiguredRule( |
151 | | - ChangeMethodVisibilityRector::class, |
152 | | - classes(static fn (string $class, string $file): bool => str_starts_with($class, 'Guanguans\SoarPHP')) |
153 | | - ->filter(static fn (ReflectionClass $reflectionClass): bool => $reflectionClass->isTrait()) |
154 | | - ->map( |
155 | | - static fn (ReflectionClass $reflectionClass): array => collect($reflectionClass->getMethods(ReflectionMethod::IS_PRIVATE)) |
156 | | - ->reject(static fn (ReflectionMethod $reflectionMethod): bool => $reflectionMethod->isFinal() || $reflectionMethod->isInternal()) |
157 | | - ->map(static fn (ReflectionMethod $reflectionMethod): ChangeMethodVisibility => new ChangeMethodVisibility( |
158 | | - $reflectionClass->getName(), |
159 | | - $reflectionMethod->getName(), |
160 | | - Visibility::PROTECTED |
161 | | - )) |
162 | | - ->all() |
163 | | - ) |
164 | | - ->flatten() |
165 | | - // ->dd() |
166 | | - ->all(), |
167 | | - ) |
168 | | - ->withConfiguredRule(RenameFunctionRector::class, [ |
169 | | - 'Pest\Faker\fake' => 'fake', |
170 | | - 'Pest\Faker\faker' => 'fake', |
171 | | - 'test' => 'it', |
172 | | - ]) |
173 | 122 | ->withSkip([ |
174 | 123 | ChangeOrIfContinueToMultiContinueRector::class, |
175 | 124 | EncapsedStringsToSprintfRector::class, |
|
0 commit comments