|
13 | 13 | * @see https://github.com/guanguans/laravel-exception-notify |
14 | 14 | */ |
15 | 15 |
|
| 16 | +use Composer\Autoload\ClassLoader; |
16 | 17 | use Ergebnis\Rector\Rules\Arrays\SortAssociativeArrayByKeyRector; |
17 | 18 | use Guanguans\LaravelExceptionNotify\Support\Rectors\HydratePipeFuncCallToStaticCallRector; |
18 | 19 | use Guanguans\LaravelExceptionNotify\Support\Rectors\ToInternalExceptionRector; |
| 20 | +use Illuminate\Support\Collection; |
19 | 21 | use Illuminate\Support\Str; |
20 | 22 | use Rector\CodeQuality\Rector\If_\ExplicitBoolCompareRector; |
21 | 23 | use Rector\CodeQuality\Rector\LogicalAnd\LogicalToBooleanRector; |
|
26 | 28 | use Rector\CodingStyle\Rector\FuncCall\ArraySpreadInsteadOfArrayMergeRector; |
27 | 29 | use Rector\CodingStyle\Rector\Stmt\NewlineAfterStatementRector; |
28 | 30 | use Rector\Config\RectorConfig; |
| 31 | +use Rector\Contract\Rector\ConfigurableRectorInterface; |
29 | 32 | use Rector\DeadCode\Rector\ClassLike\RemoveAnnotationRector; |
30 | 33 | use Rector\EarlyReturn\Rector\Return_\ReturnBinaryOrToEarlyReturnRector; |
31 | 34 | use Rector\PHPUnit\Set\PHPUnitSetList; |
|
35 | 38 | use Rector\Transform\ValueObject\FuncCallToStaticCall; |
36 | 39 | use Rector\Transform\ValueObject\StaticCallToFuncCall; |
37 | 40 | use Rector\ValueObject\PhpVersion; |
| 41 | +use RectorLaravel\Rector\Class_\ModelCastsPropertyToCastsMethodRector; |
| 42 | +use RectorLaravel\Rector\Empty_\EmptyToBlankAndFilledFuncRector; |
| 43 | +use RectorLaravel\Rector\FuncCall\HelperFuncCallToFacadeClassRector; |
| 44 | +use RectorLaravel\Rector\FuncCall\TypeHintTappableCallRector; |
| 45 | +use RectorLaravel\Rector\StaticCall\DispatchToHelperFunctionsRector; |
38 | 46 | use RectorLaravel\Set\LaravelSetList; |
39 | 47 |
|
40 | 48 | return RectorConfig::configure() |
|
49 | 57 | ->withSkip([ |
50 | 58 | '**/__snapshots__/*', |
51 | 59 | '**/Fixtures/*', |
52 | | - __FILE__, |
| 60 | + // __FILE__, |
53 | 61 | ]) |
54 | 62 | ->withCache(__DIR__.'/.build/rector/') |
55 | 63 | ->withParallel() |
|
76 | 84 | ) |
77 | 85 | ->withSets([ |
78 | 86 | PHPUnitSetList::PHPUNIT_90, |
| 87 | + LaravelSetList::LARAVEL_90, |
79 | 88 | ...collect((new ReflectionClass(LaravelSetList::class))->getConstants(ReflectionClassConstant::IS_PUBLIC)) |
80 | | - ->filter( |
| 89 | + ->reject( |
81 | 90 | static fn ( |
82 | 91 | string $constant, |
83 | 92 | string $name |
84 | | - ): bool => !\in_array($name, ['LARAVEL_STATIC_TO_INJECTION', 'LARAVEL_STATIC_TO_INJECTION'], true) |
85 | | - && ('LARAVEL_90' === $name || !preg_match('/^LARAVEL_\d{2,3}$/', $name)) |
| 93 | + ): bool => \in_array($name, ['LARAVEL_STATIC_TO_INJECTION', 'LARAVEL_'], true) |
| 94 | + || preg_match('/^LARAVEL_\d{2,3}$/', $name) |
86 | 95 | ) |
87 | 96 | // ->dd() |
88 | 97 | ->values() |
|
95 | 104 | StaticClosureRector::class, |
96 | 105 | HydratePipeFuncCallToStaticCallRector::class, |
97 | 106 | ToInternalExceptionRector::class, |
98 | | - ]) |
99 | | - ->withRules([ |
100 | | - // // RectorLaravel\Rector\Assign\CallOnAppArrayAccessToStandaloneAssignRector::class, |
101 | | - // // RectorLaravel\Rector\Cast\DatabaseExpressionCastsToMethodCallRector::class, |
102 | | - RectorLaravel\Rector\ClassMethod\AddParentBootToModelClassMethodRector::class, |
103 | | - RectorLaravel\Rector\ClassMethod\AddParentRegisterToEventServiceProviderRector::class, |
104 | | - RectorLaravel\Rector\ClassMethod\MigrateToSimplifiedAttributeRector::class, |
105 | | - RectorLaravel\Rector\Class_\AddExtendsAnnotationToModelFactoriesRector::class, |
106 | | - RectorLaravel\Rector\Class_\AddMockConsoleOutputFalseToConsoleTestsRector::class, |
107 | | - RectorLaravel\Rector\Class_\AnonymousMigrationsRector::class, |
108 | | - // RectorLaravel\Rector\Class_\ModelCastsPropertyToCastsMethodRector::class, |
109 | | - RectorLaravel\Rector\Class_\PropertyDeferToDeferrableProviderToRector::class, |
110 | | - RectorLaravel\Rector\Class_\RemoveModelPropertyFromFactoriesRector::class, |
111 | | - // // RectorLaravel\Rector\Class_\ReplaceExpectsMethodsInTestsRector::class, |
112 | | - // // RectorLaravel\Rector\Class_\UnifyModelDatesWithCastsRector::class, |
113 | | - // RectorLaravel\Rector\Empty_\EmptyToBlankAndFilledFuncRector::class, |
114 | | - RectorLaravel\Rector\Expr\AppEnvironmentComparisonToParameterRector::class, |
115 | | - RectorLaravel\Rector\Expr\SubStrToStartsWithOrEndsWithStaticMethodCallRector\SubStrToStartsWithOrEndsWithStaticMethodCallRector::class, |
116 | | - // // RectorLaravel\Rector\FuncCall\DispatchNonShouldQueueToDispatchSyncRector::class, |
117 | | - // // RectorLaravel\Rector\FuncCall\FactoryFuncCallToStaticCallRector::class, |
118 | | - // RectorLaravel\Rector\FuncCall\HelperFuncCallToFacadeClassRector::class, |
119 | | - RectorLaravel\Rector\FuncCall\NotFilledBlankFuncCallToBlankFilledFuncCallRector::class, |
120 | | - RectorLaravel\Rector\FuncCall\NowFuncWithStartOfDayMethodCallToTodayFuncRector::class, |
121 | | - RectorLaravel\Rector\FuncCall\RemoveDumpDataDeadCodeRector::class, |
122 | | - RectorLaravel\Rector\FuncCall\RemoveRedundantValueCallsRector::class, |
123 | | - RectorLaravel\Rector\FuncCall\RemoveRedundantWithCallsRector::class, |
124 | | - RectorLaravel\Rector\FuncCall\SleepFuncToSleepStaticCallRector::class, |
125 | | - RectorLaravel\Rector\FuncCall\ThrowIfAndThrowUnlessExceptionsToUseClassStringRector::class, |
126 | | - RectorLaravel\Rector\If_\AbortIfRector::class, |
127 | | - RectorLaravel\Rector\If_\ReportIfRector::class, |
128 | | - // RectorLaravel\Rector\If_\ThrowIfRector::class, |
129 | | - RectorLaravel\Rector\MethodCall\AssertStatusToAssertMethodRector::class, |
130 | | - RectorLaravel\Rector\MethodCall\ChangeQueryWhereDateValueWithCarbonRector::class, |
131 | | - // // RectorLaravel\Rector\MethodCall\DatabaseExpressionToStringToMethodCallRector::class, |
132 | | - RectorLaravel\Rector\MethodCall\EloquentWhereRelationTypeHintingParameterRector::class, |
133 | | - RectorLaravel\Rector\MethodCall\EloquentWhereTypeHintClosureParameterRector::class, |
134 | | - // // RectorLaravel\Rector\MethodCall\FactoryApplyingStatesRector::class, |
135 | | - RectorLaravel\Rector\MethodCall\JsonCallToExplicitJsonCallRector::class, |
136 | | - // RectorLaravel\Rector\MethodCall\LumenRoutesStringActionToUsesArrayRector::class, |
137 | | - // RectorLaravel\Rector\MethodCall\LumenRoutesStringMiddlewareToArrayRector::class, |
138 | | - RectorLaravel\Rector\MethodCall\RedirectBackToBackHelperRector::class, |
139 | | - RectorLaravel\Rector\MethodCall\RedirectRouteToToRouteHelperRector::class, |
140 | | - RectorLaravel\Rector\MethodCall\RefactorBlueprintGeometryColumnsRector::class, |
141 | | - // // RectorLaravel\Rector\MethodCall\ReplaceWithoutJobsEventsAndNotificationsWithFacadeFakeRector::class, |
142 | | - RectorLaravel\Rector\MethodCall\UseComponentPropertyWithinCommandsRector::class, |
143 | | - RectorLaravel\Rector\MethodCall\ValidationRuleArrayStringValueToArrayRector::class, |
144 | | - // // RectorLaravel\Rector\Namespace_\FactoryDefinitionRector::class, |
145 | | - RectorLaravel\Rector\New_\AddGuardToLoginEventRector::class, |
146 | | - RectorLaravel\Rector\PropertyFetch\ReplaceFakerInstanceWithHelperRector::class, |
147 | | - // RectorLaravel\Rector\StaticCall\DispatchToHelperFunctionsRector::class, |
148 | | - // RectorLaravel\Rector\StaticCall\MinutesToSecondsInCacheRector::class, |
149 | | - RectorLaravel\Rector\StaticCall\Redirect301ToPermanentRedirectRector::class, |
150 | | - // // RectorLaravel\Rector\StaticCall\ReplaceAssertTimesSendWithAssertSentTimesRector::class, |
151 | | - ]) |
152 | | - ->withRules([ |
153 | | - // // RectorLaravel\Rector\ClassMethod\AddArgumentDefaultValueRector::class, |
154 | | - // // RectorLaravel\Rector\FuncCall\ArgumentFuncCallToMethodCallRector::class, |
155 | | - // RectorLaravel\Rector\MethodCall\EloquentOrderByToLatestOrOldestRector::class, |
156 | | - // RectorLaravel\Rector\MethodCall\ReplaceServiceContainerCallArgRector::class, |
157 | | - // RectorLaravel\Rector\PropertyFetch\OptionalToNullsafeOperatorRector::class, |
158 | | - // // RectorLaravel\Rector\StaticCall\EloquentMagicMethodToQueryBuilderRector::class, |
159 | | - // RectorLaravel\Rector\StaticCall\RouteActionCallableRector::class, |
160 | | - ]) |
161 | | - ->withConfiguredRule(RectorLaravel\Rector\MethodCall\EloquentOrderByToLatestOrOldestRector::class, [ |
162 | | - ]) |
163 | | - ->withConfiguredRule(RectorLaravel\Rector\MethodCall\ReplaceServiceContainerCallArgRector::class, [ |
164 | | - ]) |
165 | | - ->withConfiguredRule(RectorLaravel\Rector\PropertyFetch\OptionalToNullsafeOperatorRector::class, [ |
166 | | - ]) |
167 | | - ->withConfiguredRule(RectorLaravel\Rector\StaticCall\RouteActionCallableRector::class, [ |
| 107 | + ...collect(spl_autoload_functions()) |
| 108 | + ->pipe(static fn (Collection $splAutoloadFunctions): Collection => collect( |
| 109 | + $splAutoloadFunctions |
| 110 | + ->firstOrFail( |
| 111 | + static fn (mixed $loader): bool => \is_array($loader) && $loader[0] instanceof ClassLoader |
| 112 | + )[0] |
| 113 | + ->getClassMap() |
| 114 | + )) |
| 115 | + ->keys() |
| 116 | + ->filter(static fn (string $class): bool => str_starts_with($class, 'RectorLaravel\Rector')) |
| 117 | + ->filter(static fn (string $class): bool => (new ReflectionClass($class))->isInstantiable()) |
| 118 | + // ->filter(static fn (string $class): bool => is_subclass_of($class, ConfigurableRectorInterface::class)) |
| 119 | + ->values() |
| 120 | + // ->dd() |
| 121 | + ->all(), |
168 | 122 | ]) |
169 | 123 | ->withConfiguredRule(RemoveAnnotationRector::class, [ |
170 | 124 | 'codeCoverageIgnore', |
|
181 | 135 | ->withConfiguredRule( |
182 | 136 | RenameFunctionRector::class, |
183 | 137 | [ |
184 | | - 'Pest\Faker\fake' => 'fake', |
185 | | - 'Pest\Faker\faker' => 'faker', |
186 | 138 | // 'faker' => 'fake', |
187 | 139 | 'Guanguans\Notify\Foundation\Support\rescue' => 'Guanguans\LaravelExceptionNotify\Support\rescue', |
| 140 | + 'Pest\Faker\fake' => 'fake', |
| 141 | + 'Pest\Faker\faker' => 'faker', |
188 | 142 | 'rescue' => 'Guanguans\LaravelExceptionNotify\Support\rescue', |
189 | 143 | 'test' => 'it', |
190 | 144 | ] + array_reduce( |
@@ -213,6 +167,13 @@ static function (array $carry, string $func): array { |
213 | 167 | ReturnBinaryOrToEarlyReturnRector::class, |
214 | 168 | WrapEncapsedVariableInCurlyBracesRector::class, |
215 | 169 | ]) |
| 170 | + ->withSkip([ |
| 171 | + DispatchToHelperFunctionsRector::class, |
| 172 | + EmptyToBlankAndFilledFuncRector::class, |
| 173 | + HelperFuncCallToFacadeClassRector::class, |
| 174 | + ModelCastsPropertyToCastsMethodRector::class, |
| 175 | + TypeHintTappableCallRector::class, |
| 176 | + ]) |
216 | 177 | ->withSkip([ |
217 | 178 | StaticArrowFunctionRector::class => $staticClosureSkipPaths = [ |
218 | 179 | __DIR__.'/tests', |
|
0 commit comments