Skip to content

Commit 4ce2cf0

Browse files
committed
refactor(rector): apply rector
1 parent ba12a8e commit 4ce2cf0

File tree

7 files changed

+17
-18
lines changed

7 files changed

+17
-18
lines changed

app/Commands/BuildCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public function __destruct()
8282
* @noinspection PhpMissingReturnTypeInspection
8383
* @noinspection PhpMissingParentCallCommonInspection
8484
*/
85-
public function isEnabled()
85+
public function isEnabled(): bool
8686
{
8787
return ! $this->laravel->isProduction();
8888
}

app/Exceptions/Handler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function renderForConsole($output, \Throwable $e): void
3838
* @noinspection ReturnTypeCanBeDeclaredInspection
3939
* @noinspection PhpMissingReturnTypeInspection
4040
*/
41-
protected function shouldntReport(\Throwable $e)
41+
protected function shouldntReport(\Throwable $e): bool
4242
{
4343
if ($this->container->isProduction()) {
4444
return true;

app/GeneratorManager.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ final class GeneratorManager extends Manager
2828
use Conditionable;
2929
use Tappable;
3030

31-
public function getDefaultDriver()
31+
public function getDefaultDriver(): string
3232
{
3333
return $this->config->get('ai-commit.generator');
3434
}

app/Generators/ErnieBotGenerator.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@
2525
class ErnieBotGenerator implements GeneratorContract
2626
{
2727
/**
28-
* @var array
28+
* @var \App\Support\Ernie
2929
*/
30-
private $config = [];
30+
protected $ernie;
3131

3232
/**
33-
* @var \App\Support\Ernie
33+
* @var array
3434
*/
35-
protected $ernie;
35+
private $config = [];
3636

3737
/**
3838
* @var \Illuminate\Console\OutputStyle
@@ -71,19 +71,19 @@ public function generate(string $prompt): string
7171
}
7272

7373
/**
74-
* @param array|ArrayAccess $response
74+
* @throws RequestException
75+
* @throws BindingResolutionException
7576
*/
76-
private function getCompletionMessages($response): string
77+
protected function completion(array $parameters, ?callable $writer = null): Response
7778
{
78-
return Arr::get($response, 'result', '');
79+
return $this->ernie->ernieBot($parameters, $writer);
7980
}
8081

8182
/**
82-
* @throws RequestException
83-
* @throws BindingResolutionException
83+
* @param array|ArrayAccess $response
8484
*/
85-
private function completion(array $parameters, ?callable $writer = null): Response
85+
private function getCompletionMessages($response): string
8686
{
87-
return $this->ernie->ernieBot($parameters, $writer);
87+
return Arr::get($response, 'result', '');
8888
}
8989
}

app/Support/helpers.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public function __call($method, $parameters)
6565
return Str::$method(...$parameters);
6666
}
6767

68-
public function __toString()
68+
public function __toString(): string
6969
{
7070
return '';
7171
}

rector.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
use Rector\EarlyReturn\Rector\Return_\ReturnBinaryOrToEarlyReturnRector;
3434
use Rector\Naming\Rector\Assign\RenameVariableToMatchMethodCallReturnTypeRector;
3535
use Rector\Naming\Rector\ClassMethod\RenameParamToMatchTypeRector;
36-
use Rector\Php56\Rector\FunctionLike\AddDefaultValueForUndefinedVariableRector;
3736
use Rector\Php73\Rector\FuncCall\JsonThrowOnErrorRector;
3837
use Rector\PHPUnit\Set\PHPUnitLevelSetList;
3938
use Rector\PHPUnit\Set\PHPUnitSetList;
@@ -80,7 +79,6 @@
8079
$rectorConfig->skip([
8180
// rules
8281
// AddArrayDefaultToArrayPropertyRector::class,
83-
// AddDefaultValueForUndefinedVariableRector::class,
8482
// CallableThisArrayToAnonymousFunctionRector::class,
8583
// ChangeAndIfToEarlyReturnRector::class,
8684
// RemoveEmptyClassMethodRector::class,
@@ -111,6 +109,7 @@
111109
],
112110
FinalizeClassesWithoutChildrenRector::class => [
113111
__DIR__.'/app/Generators/OpenAIGenerator.php',
112+
__DIR__.'/app/Generators/ErnieBotGenerator.php',
114113
],
115114
JsonThrowOnErrorRector::class => [
116115
__DIR__.'/app/Generators/OpenAIGenerator.php',

tests/Pest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ function setup_http_fake(): void
8686
return array_flip(Response::$statusTexts)[$prompt] ?? 200;
8787
});
8888

89-
$text = transform($prompt, function ($prompt) {
89+
$text = transform($prompt, function ($prompt): string {
9090
switch ($prompt) {
9191
case 'empty':
9292
$text = '';

0 commit comments

Comments
 (0)