Skip to content

Commit ebffe25

Browse files
author
ityaozm@gmail.com
committed
refactor(http): Improve option handling and add new rector rules
- Refactor the way HTTP options are retrieved by using the array spread operator. - Add new rector rules to enhance code quality and maintainability. - Remove deprecated rector rules to streamline the configuration.
1 parent 3f87ada commit ebffe25

File tree

4 files changed

+7
-4
lines changed

4 files changed

+7
-4
lines changed

app/Clients/AbstractClient.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ private function defaultPendingRequest(): PendingRequest
204204
string $userAgent
205205
) => $pendingRequest->withUserAgent($userAgent)
206206
)
207-
->withOptions((array) config('ai-commit.http_options'))
207+
->withOptions(config()->array('ai-commit.http_options'))
208208
->withOptions($this->configRepository->get('http_options'))
209209
->retry(
210210
times: $this->configRepository->get('retry.times'),

app/Generators/AbstractGenerator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ protected function runningCallback(): callable
8888

8989
protected function ensureWithOptions(array $command): array
9090
{
91-
return array_merge($command, $this->hydratedOptions());
91+
return [...$command, ...$this->hydratedOptions()];
9292
}
9393

9494
/**

rector.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@
3131
use Rector\CodingStyle\Rector\Encapsed\EncapsedStringsToSprintfRector;
3232
use Rector\CodingStyle\Rector\Encapsed\WrapEncapsedVariableInCurlyBracesRector;
3333
use Rector\CodingStyle\Rector\FuncCall\ArraySpreadInsteadOfArrayMergeRector;
34+
use Rector\CodingStyle\Rector\FunctionLike\FunctionLikeToFirstClassCallableRector;
3435
use Rector\CodingStyle\Rector\Stmt\NewlineAfterStatementRector;
3536
use Rector\CodingStyle\Rector\String_\SymplifyQuoteEscapeRector;
3637
use Rector\Config\RectorConfig;
3738
use Rector\DeadCode\Rector\ClassLike\RemoveAnnotationRector;
38-
use Rector\DowngradePhp81\Rector\Array_\DowngradeArraySpreadStringKeyRector;
3939
use Rector\EarlyReturn\Rector\Return_\ReturnBinaryOrToEarlyReturnRector;
4040
use Rector\Naming\Rector\Foreach_\RenameForeachValueVariableToMatchExprVariableRector;
4141
use Rector\Php73\Rector\FuncCall\JsonThrowOnErrorRector;
@@ -52,6 +52,7 @@
5252
use Rector\ValueObject\Visibility;
5353
use Rector\Visibility\Rector\ClassMethod\ChangeMethodVisibilityRector;
5454
use Rector\Visibility\ValueObject\ChangeMethodVisibility;
55+
use RectorLaravel\Rector\ArrayDimFetch\ArrayToArrGetRector;
5556
use RectorLaravel\Rector\ArrayDimFetch\ServerVariableToRequestFacadeRector;
5657
use RectorLaravel\Rector\Class_\ModelCastsPropertyToCastsMethodRector;
5758
use RectorLaravel\Rector\Class_\RemoveModelPropertyFromFactoriesRector;
@@ -228,9 +229,9 @@ static function (array $carry, string $func): array {
228229
)
229230
->withSkip([
230231
DisallowedEmptyRuleFixerRector::class,
232+
FunctionLikeToFirstClassCallableRector::class,
231233
RenameForeachValueVariableToMatchExprVariableRector::class,
232234

233-
DowngradeArraySpreadStringKeyRector::class,
234235
EncapsedStringsToSprintfRector::class,
235236
ExplicitBoolCompareRector::class,
236237
LogicalToBooleanRector::class,
@@ -244,6 +245,7 @@ static function (array $carry, string $func): array {
244245
ThrowIfRector::class,
245246
UseComponentPropertyWithinCommandsRector::class,
246247

248+
ArrayToArrGetRector::class,
247249
DispatchToHelperFunctionsRector::class,
248250
EmptyToBlankAndFilledFuncRector::class,
249251
HelperFuncCallToFacadeClassRector::class,

tests/Feature/CommitCommandTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@
9595

9696
afterAll(static function (): void {
9797
// 清理 playground 仓库
98+
Process::fromShellCommandline('git clean -df', repository_path())->run();
9899
Process::fromShellCommandline('git reset $(git rev-list --max-parents=0 HEAD)', repository_path())->run();
99100
// Process::fromShellCommandline('git checkout -- .', repository_path())->run();
100101
Process::fromShellCommandline('git checkout HEAD -- .', repository_path())->run();

0 commit comments

Comments
 (0)