Skip to content

Commit 3498fbc

Browse files
author
ityaozm@gmail.com
committed
style: apply php-cs-fixer
1 parent 90e66a5 commit 3498fbc

52 files changed

Lines changed: 650 additions & 927 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.php-cs-fixer.php

Lines changed: 262 additions & 350 deletions
Large diffs are not rendered by default.

LICENSE

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,16 @@
1-
MIT License
1+
The MIT License (MIT)
22

3-
Copyright (c) 2020 guanguans
3+
Copyright (c) 2023-2025 guanguans<ityaozm@gmail.com>
44

5-
Permission is hereby granted, free of charge, to any person obtaining a copy
6-
of this software and associated documentation files (the "Software"), to deal
7-
in the Software without restriction, including without limitation the rights
8-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9-
copies of the Software, and to permit persons to whom the Software is
10-
furnished to do so, subject to the following conditions:
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
6+
documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
7+
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
8+
persons to whom the Software is furnished to do so, subject to the following conditions:
119

12-
The above copyright notice and this permission notice shall be included in all
13-
copies or substantial portions of the Software.
10+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
11+
Software.
1412

15-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21-
SOFTWARE.
13+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
14+
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
15+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
16+
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

ai-commit

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
#!/usr/bin/env php
22
<?php
33

4+
declare(strict_types=1);
5+
46
/**
5-
* This file is part of the guanguans/ai-commit.
7+
* Copyright (c) 2023-2025 guanguans<ityaozm@gmail.com>
68
*
7-
* (c) guanguans <ityaozm@gmail.com>
9+
* For the full copyright and license information, please view
10+
* the LICENSE file that was distributed with this source code.
811
*
9-
* This source file is subject to the MIT license that is bundled.
12+
* @see https://github.com/guanguans/ai-commit
1013
*/
1114

12-
define('LARAVEL_START', microtime(true));
15+
\define('LARAVEL_START', microtime(true));
1316

1417
/*
1518
|--------------------------------------------------------------------------
@@ -41,8 +44,8 @@ $app = require_once __DIR__.'/bootstrap/app.php';
4144
$kernel = $app->make(Illuminate\Contracts\Console\Kernel::class);
4245

4346
$status = $kernel->handle(
44-
$input = new Symfony\Component\Console\Input\ArgvInput(),
45-
new Symfony\Component\Console\Output\ConsoleOutput()
47+
$input = new Symfony\Component\Console\Input\ArgvInput,
48+
new Symfony\Component\Console\Output\ConsoleOutput
4649
);
4750

4851
/*

app/Commands/BuildCommand.php

Lines changed: 30 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -29,46 +29,30 @@
2929
*/
3030
final class BuildCommand extends Command
3131
{
32-
/**
33-
* {@inheritDoc}
34-
*/
35-
protected $signature = 'app:build
36-
{name? : The build name}
37-
{--build-version= : The build version, if not provided it will be asked}
38-
{--timeout=300 : The timeout in seconds or 0 to disable}
39-
';
32+
/** {@inheritDoc} */
33+
protected $signature = <<<'EOD'
34+
app:build
35+
{name? : The build name}
36+
{--build-version= : The build version, if not provided it will be asked}
37+
{--timeout=300 : The timeout in seconds or 0 to disable}
4038

41-
/**
42-
* {@inheritDoc}
43-
*/
39+
EOD;
40+
41+
/** {@inheritDoc} */
4442
protected $description = 'Build a single file executable.';
4543

46-
/**
47-
* Holds the configuration on is original state.
48-
*
49-
* @var null|string
50-
*/
51-
private static $config;
44+
/** Holds the configuration on is original state. */
45+
private static ?string $config = null;
5246

53-
/**
54-
* Holds the box.json on is original state.
55-
*
56-
* @var null|string
57-
*/
58-
private static $box;
47+
/** Holds the box.json on is original state. */
48+
private static ?string $box;
5949

60-
/**
61-
* Holds the command original output.
62-
*
63-
* @var null|\Symfony\Component\Console\Output\OutputInterface
64-
*/
65-
private $originalOutput;
50+
/** Holds the command original output. */
51+
private ?OutputInterface $originalOutput;
6652

6753
/**
6854
* Makes sure that the `clear` is performed even
6955
* if the command fails.
70-
*
71-
* @return void
7256
*/
7357
public function __destruct()
7458
{
@@ -78,12 +62,13 @@ public function __destruct()
7862
}
7963

8064
/**
81-
* @psalm-suppress UndefinedInterfaceMethod
8265
* @noinspection PhpMissingParentCallCommonInspection
66+
*
67+
* @psalm-suppress UndefinedInterfaceMethod
8368
*/
8469
public function isEnabled(): bool
8570
{
86-
return ! $this->laravel->isProduction();
71+
return !$this->laravel->isProduction();
8772
}
8873

8974
/**
@@ -125,21 +110,21 @@ private function build(string $name): self
125110
->clear();
126111

127112
$this->output->writeln(
128-
sprintf(' Compiled successfully: <fg=green>%s</>', $this->app->buildsPath($name))
113+
\sprintf(' Compiled successfully: <fg=green>%s</>', $this->app->buildsPath($name))
129114
);
130115

131116
return $this;
132117
}
133118

134119
/**
135-
* @psalm-suppress UndefinedInterfaceMethod
136-
*
137120
* @noinspection PhpVoidFunctionResultUsedInspection
138121
* @noinspection DisconnectedForeachInstructionInspection
122+
*
123+
* @psalm-suppress UndefinedInterfaceMethod
139124
*/
140125
private function compile(string $name): self
141126
{
142-
if (! File::exists($this->app->buildsPath())) {
127+
if (!File::exists($this->app->buildsPath())) {
143128
File::makeDirectory($this->app->buildsPath());
144129
}
145130

@@ -158,7 +143,7 @@ private function compile(string $name): self
158143

159144
$progressBar = tap(
160145
new ProgressBar(
161-
$this->output->getVerbosity() > OutputInterface::VERBOSITY_NORMAL ? new NullOutput() : $section,
146+
$this->output->getVerbosity() > OutputInterface::VERBOSITY_NORMAL ? new NullOutput : $section,
162147
25
163148
)
164149
)->setProgressCharacter("\xF0\x9F\x8D\xBA");
@@ -206,11 +191,11 @@ private function prepare(): self
206191
$this->task(
207192
' 1. Moving application to <fg=yellow>production mode</>',
208193
static function () use ($configFile, $config): void {
209-
File::put($configFile, '<?php return '.var_export($config, true).';'.PHP_EOL);
194+
File::put($configFile, '<?php return '.var_export($config, true).';'.\PHP_EOL);
210195
}
211196
);
212197

213-
$boxContents = json_decode(self::$box, true, 512, JSON_THROW_ON_ERROR);
198+
$boxContents = json_decode(self::$box, true, 512, \JSON_THROW_ON_ERROR);
214199
$boxContents['main'] = $this->getBinary();
215200

216201
// Exclude Box binaries in output Phar
@@ -220,9 +205,9 @@ static function () use ($configFile, $config): void {
220205
$boxContents['blacklist'][] = 'vendor/laravel-zero/framework/bin/box73';
221206
$boxContents['blacklist'][] = 'vendor/laravel-zero/framework/bin/box73.bat';
222207

223-
File::put($boxFile, json_encode($boxContents, JSON_THROW_ON_ERROR));
208+
File::put($boxFile, json_encode($boxContents, \JSON_THROW_ON_ERROR));
224209

225-
File::put($configFile, '<?php return '.var_export($config, true).';'.PHP_EOL);
210+
File::put($configFile, '<?php return '.var_export($config, true).';'.\PHP_EOL);
226211

227212
return $this;
228213
}
@@ -256,13 +241,13 @@ private function getBinary(): string
256241
*/
257242
private function getTimeout(): ?float
258243
{
259-
if (! is_numeric($this->option('timeout'))) {
244+
if (!is_numeric($this->option('timeout'))) {
260245
throw new InvalidArgumentException('The timeout value must be a number.');
261246
}
262247

263248
$timeout = (float) $this->option('timeout');
264249

265-
return $timeout > 0 ? $timeout : null;
250+
return 0 < $timeout ? $timeout : null;
266251
}
267252

268253
/**
@@ -274,7 +259,7 @@ private function listenForSignals(): void
274259
{
275260
pcntl_async_signals(true);
276261

277-
pcntl_signal(SIGINT, function (): void {
262+
pcntl_signal(\SIGINT, function (): void {
278263
if (null !== self::$config) {
279264
$this->clear();
280265
}

0 commit comments

Comments
 (0)