1717use Ergebnis \Rector \Rules \Arrays \SortAssociativeArrayByKeyRector ;
1818use Guanguans \Notify \Foundation \Concerns \AsJson ;
1919use Guanguans \Notify \Foundation \Concerns \AsPost ;
20- use Guanguans \Notify \Foundation \Concerns \HasOptions ;
21- use Guanguans \Notify \Foundation \Method ;
2220use Guanguans \Notify \Foundation \Rectors \AddSensitiveParameterAttributeRector ;
2321use Guanguans \Notify \Foundation \Rectors \HasHttpClientDocCommentRector ;
2422use Guanguans \Notify \Foundation \Rectors \MessageRector ;
25- use Guanguans \Notify \Foundation \Response ;
2623use Guanguans \RectorRules \Rector \File \AddNoinspectionDocblockToFileFirstStmtRector ;
27- use Guanguans \RectorRules \Rector \FunctionLike \RenameGarbageParamNameRector ;
2824use Guanguans \RectorRules \Rector \Name \RenameToConventionalCaseNameRector ;
2925use Guanguans \RectorRules \Set \SetList ;
30- use GuzzleHttp \RequestOptions ;
31- use PhpParser \Node \Expr \ClassConstFetch ;
32- use PhpParser \Node \Identifier ;
33- use PhpParser \Node \Name \FullyQualified ;
34- use PhpParser \Node \Scalar \Int_ ;
3526use PhpParser \NodeVisitor \ParentConnectingVisitor ;
36- use Rector \CodeQuality \Rector \Class_ \ConvertStaticToSelfRector ;
3727use Rector \CodeQuality \Rector \If_ \ExplicitBoolCompareRector ;
3828use Rector \CodeQuality \Rector \LogicalAnd \LogicalToBooleanRector ;
3929use Rector \CodingStyle \Rector \ArrowFunction \ArrowFunctionDelegatingCallToFirstClassCallableRector ;
4232use Rector \CodingStyle \Rector \Closure \StaticClosureRector ;
4333use Rector \CodingStyle \Rector \Encapsed \EncapsedStringsToSprintfRector ;
4434use Rector \CodingStyle \Rector \Encapsed \WrapEncapsedVariableInCurlyBracesRector ;
35+ use Rector \CodingStyle \Rector \Enum_ \EnumCaseToPascalCaseRector ;
4536use Rector \CodingStyle \Rector \FuncCall \ArraySpreadInsteadOfArrayMergeRector ;
46- use Rector \CodingStyle \Rector \Stmt \NewlineAfterStatementRector ;
4737use Rector \Config \RectorConfig ;
48- use Rector \DeadCode \Rector \ClassLike \RemoveAnnotationRector ;
4938use Rector \DeadCode \Rector \ClassMethod \RemoveParentDelegatingConstructorRector ;
5039use Rector \EarlyReturn \Rector \If_ \ChangeOrIfContinueToMultiContinueRector ;
5140use Rector \EarlyReturn \Rector \Return_ \ReturnBinaryOrToEarlyReturnRector ;
5241use Rector \Naming \Rector \Assign \RenameVariableToMatchMethodCallReturnTypeRector ;
5342use Rector \Naming \Rector \ClassMethod \RenameParamToMatchTypeRector ;
5443use Rector \Php73 \Rector \FuncCall \JsonThrowOnErrorRector ;
55- use Rector \Php81 \Rector \Array_ \ArrayToFirstClassCallableRector ;
5644use Rector \Removing \Rector \Class_ \RemoveTraitUseRector ;
5745use Rector \Renaming \Rector \FuncCall \RenameFunctionRector ;
5846use Rector \Strict \Rector \Empty_ \DisallowedEmptyRuleFixerRector ;
59- use Rector \Transform \Rector \ClassMethod \ReturnTypeWillChangeRector ;
60- use Rector \Transform \Rector \Scalar \ScalarValueToConstFetchRector ;
6147use Rector \Transform \Rector \String_ \StringToClassConstantRector ;
62- use Rector \Transform \ValueObject \ClassMethodReference ;
63- use Rector \Transform \ValueObject \ScalarValueToConstFetch ;
64- use Rector \Transform \ValueObject \StringToClassConstant ;
6548use Rector \TypeDeclaration \Rector \StmtsAwareInterface \SafeDeclareStrictTypesRector ;
6649use Rector \ValueObject \PhpVersion ;
6750
6851return RectorConfig::configure ()
69- ->withPaths ([
70- __DIR__ .'/benchmarks/ ' ,
71- __DIR__ .'/src/ ' ,
72- __DIR__ .'/tests/ ' ,
73- __DIR__ .'/composer-bump ' ,
74- ])
52+ ->withPaths ([__DIR__ .'/benchmarks/ ' , __DIR__ .'/src/ ' , __DIR__ .'/tests/ ' , __DIR__ .'/composer-bump ' ])
7553 ->withRootFiles ()
76- ->withSkip ([
77- '*/Fixtures/* ' ,
78- __DIR__ .'/tests.php ' ,
79- ])
54+ ->withSkip (['*/Fixtures/* ' , __DIR__ .'/tests.php ' ])
8055 ->withCache (__DIR__ .'/.build/rector/ ' )
8156 // ->withoutParallel()
8257 ->withParallel ()
10075 naming: true ,
10176 instanceOf: true ,
10277 earlyReturn: true ,
78+ // strictBooleans: true,
10379 // carbon: true,
80+ rectorPreset: true ,
81+ phpunitCodeQuality: true ,
10482 )
10583 ->withSets ([
10684 SetList::ALL ,
11189 MessageRector::class,
11290
11391 ArraySpreadInsteadOfArrayMergeRector::class,
92+ EnumCaseToPascalCaseRector::class,
11493 JsonThrowOnErrorRector::class,
11594 SafeDeclareStrictTypesRector::class,
11695 SortAssociativeArrayByKeyRector::class,
126105 'PhpUndefinedClassInspection ' ,
127106 'PhpUnhandledExceptionInspection ' ,
128107 'PhpVoidFunctionResultUsedInspection ' ,
129- // 'SqlResolve',
130108 'StaticClosureCanBeUsedInspection ' ,
131109 ],
132110 ])
133111 ->registerDecoratingNodeVisitor (ParentConnectingVisitor::class)
134- ->withConfiguredRule (RenameToConventionalCaseNameRector::class, [
135- 'beforeEach ' ,
136- 'MIT ' ,
137- 'PDO ' ,
138- ])
139- ->withConfiguredRule (RemoveAnnotationRector::class, [
140- 'codeCoverageIgnore ' ,
141- 'inheritDoc ' ,
142- 'phpstan-ignore ' ,
143- 'phpstan-ignore-next-line ' ,
144- 'psalm-suppress ' ,
145- ])
146- ->withConfiguredRule (RemoveTraitUseRector::class, [
147- AsJson::class,
148- AsPost::class,
149- ])
150- // ->withConfiguredRule(ReturnTypeWillChangeRector::class, [
151- // new ClassMethodReference(ArrayAccess::class, 'offsetGet'),
152- // new ClassMethodReference(HasOptions::class, 'offsetGet'),
153- // new ClassMethodReference(Response::class, 'offsetGet'),
154- // ])
155-
156- ->withConfiguredRule (RenameFunctionRector::class, array_reduce (
157- [
158- 'base64_encode_file ' ,
159- 'tap ' ,
160- 'value ' ,
161- ],
162- static function (array $ carry , string $ func ): array {
163- /** @see https://github.com/laravel/framework/blob/11.x/src/Illuminate/Support/functions.php */
164- $ carry [$ func ] = "Guanguans \\Notify \\Foundation \\Support \\$ func " ;
165-
166- return $ carry ;
167- },
168- []
169- ))
170- ->withConfiguredRule (StringToClassConstantRector::class, array_reduce (
171- [
172- // Method::class,
173- RequestOptions::class,
174- ],
175- static fn (array $ carry , string $ class ): array => [...$ carry , ...array_map (
176- static fn (string $ string , string $ constant ): StringToClassConstant => new StringToClassConstant (
177- $ string ,
178- $ class ,
179- $ constant ,
180- ),
181- $ constants = (new ReflectionClass ($ class ))->getConstants (),
182- array_keys ($ constants ),
183- )],
184- [],
185- ))
186- ->withConfiguredRule (ScalarValueToConstFetchRector::class, array_map (
187- static fn (int $ value , string $ constant ): ScalarValueToConstFetch => new ScalarValueToConstFetch (
188- new Int_ ($ value ),
189- new ClassConstFetch (new FullyQualified (Response::class), new Identifier ($ constant ))
190- ),
191- $ constants = array_filter (
192- (new ReflectionClass (Response::class))->getConstants (),
193- \is_int (...),
194- ),
195- array_keys ($ constants )
196- ))
112+ ->withConfiguredRule (RenameToConventionalCaseNameRector::class, ['beforeEach ' , 'MIT ' , 'PDO ' ])
113+ ->withConfiguredRule (RemoveTraitUseRector::class, [AsJson::class, AsPost::class])
114+ ->withConfiguredRule (
115+ RenameFunctionRector::class,
116+ collect (['base64_encode_file ' , 'tap ' , 'value ' ])
117+ ->mapWithKeys (static fn (string $ func ): array => [$ func => "Guanguans \\Notify \\Foundation \\Support \\$ func " ])
118+ ->all ()
119+ )
197120 ->withSkip ([
198- // ArrayToFirstClassCallableRector::class,
199- // ArrowFunctionDelegatingCallToFirstClassCallableRector::class,
200- RenameGarbageParamNameRector::class,
201- ScalarValueToConstFetchRector::class,
202-
203121 ChangeOrIfContinueToMultiContinueRector::class,
204122 DisallowedEmptyRuleFixerRector::class,
205123 EncapsedStringsToSprintfRector::class,
206124 ExplicitBoolCompareRector::class,
207125 LogicalToBooleanRector::class,
208- NewlineAfterStatementRector::class,
209126 NewlineBetweenClassLikeStmtsRector::class,
210127 ReturnBinaryOrToEarlyReturnRector::class,
211128 WrapEncapsedVariableInCurlyBracesRector::class,
@@ -214,13 +131,6 @@ static function (array $carry, string $func): array {
214131 ArrowFunctionDelegatingCallToFirstClassCallableRector::class => [
215132 __DIR__ .'/tests/Foundation/MessageTest.php ' ,
216133 ],
217- ConvertStaticToSelfRector::class => [
218- __DIR__ .'/src/Foundation/Support/Arr.php ' ,
219- __DIR__ .'/src/Foundation/Support/Str.php ' ,
220- ],
221- RemoveAnnotationRector::class => [
222- __DIR__ .'/src/Foundation/Concerns/Dumpable.php ' ,
223- ],
224134 RemoveParentDelegatingConstructorRector::class => [
225135 __DIR__ .'/src/Zulip/Authenticator.php ' ,
226136 ],
@@ -229,7 +139,6 @@ static function (array $carry, string $func): array {
229139 ],
230140 RenameParamToMatchTypeRector::class => [
231141 __DIR__ .'/src/Foundation/Rectors/ ' ,
232- __DIR__ .'/src/Foundation/Authenticators/AggregateAuthenticator.php ' ,
233142 __DIR__ .'/src/Foundation/Exceptions/RequestException.php ' ,
234143 ],
235144 RenameVariableToMatchMethodCallReturnTypeRector::class => [
@@ -241,14 +150,13 @@ static function (array $carry, string $func): array {
241150 __DIR__ .'/tests/ ' ,
242151 ],
243152 StaticArrowFunctionRector::class => $ staticClosureSkipPaths = [
244- __DIR__ .'/tests/ ' ,
153+ __DIR__ .'/tests/*Test.php ' ,
154+ __DIR__ .'/tests/Pest.php ' ,
245155 ],
246156 StaticClosureRector::class => $ staticClosureSkipPaths ,
247157 StringToClassConstantRector::class => [
248158 __DIR__ .'/benchmarks/ ' ,
249159 __DIR__ .'/src/*/Messages/*.php ' ,
250- __DIR__ .'/src/Foundation/Response.php ' ,
251- __DIR__ .'/src/Foundation/Rfc/ ' ,
252160 __DIR__ .'/src/Foundation/Support/Utils.php ' ,
253161 __DIR__ .'/tests/ ' ,
254162 __DIR__ .'/composer-bump ' ,
0 commit comments