Skip to content

Commit 24d17d5

Browse files
committed
chore: run php-cs-fixer for the ./
1 parent 8e36450 commit 24d17d5

Some content is hidden

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

41 files changed

+292
-55
lines changed

.php-cs-fixer.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
PhpCsFixer\Finder::create()
3939
->exclude('test')
4040
->exclude('runtime')
41+
->exclude('.github')
4142
->exclude('vendor')
4243
->in(__DIR__)
4344
)

example/cliapp.php

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
<?php
1+
<?php declare(strict_types=1);
2+
/**
3+
* This file is part of toolkit/pflag.
4+
*
5+
* @link https://github.com/php-toolkit
6+
* @author https://github.com/inhere
7+
* @license MIT
8+
*/
29

310
use Toolkit\Cli\Cli;
411
use Toolkit\PFlag\CliApp;
@@ -10,18 +17,19 @@
1017
// run demo:
1118
// php example/cliapp.php
1219

13-
$app = CliApp::newWith(function (CliApp $app) {
20+
$cli = CliApp::newWith(static function (CliApp $app): void {
1421
$app->setName('myApp');
22+
$app->setDesc('my cli application. v1.0.1');
1523
})
16-
->add('test1', fn(FlagsParser $fs) => vdump($fs->getOpts()), [
24+
->add('test1', fn (FlagsParser $fs) => vdump($fs->getOpts()), [
1725
'desc' => 'the test 1 command',
1826
'options' => [
1927
'opt1' => 'opt1 for command test1',
2028
'opt2' => 'int;opt2 for command test1',
2129
],
2230
]);
2331

24-
$app->add('test2', function (FlagsParser $fs) {
32+
$cli->add('test2', function (FlagsParser $fs): void {
2533
Cli::info('options:');
2634
vdump($fs->getOpts());
2735
Cli::info('arguments:');
@@ -37,9 +45,8 @@
3745
]
3846
]);
3947

40-
$app->add('show-err', fn() => throw new RuntimeException('test show exception'));
48+
$cli->add('show-err', fn () => throw new RuntimeException('test show exception'));
4149

42-
$app->addHandler(DemoCmdHandler::class);
43-
44-
$app->run();
50+
$cli->addHandler(DemoCmdHandler::class);
4551

52+
$cli->run();

example/clicmd.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
<?php
1+
<?php declare(strict_types=1);
2+
/**
3+
* This file is part of toolkit/pflag.
4+
*
5+
* @link https://github.com/php-toolkit
6+
* @author https://github.com/inhere
7+
* @license MIT
8+
*/
29

310
use Toolkit\Cli\Cli;
411
use Toolkit\PFlag\CliCmd;
@@ -11,7 +18,7 @@
1118
// php example/clicmd.php --name inhere value1
1219
// php example/clicmd.php --age 23 --name inhere value1
1320

14-
CliCmd::newWith(function (CliCmd $cmd) {
21+
CliCmd::newWith(static function (CliCmd $cmd): void {
1522
$cmd->name = 'demo';
1623
$cmd->desc = 'description for demo command';
1724

@@ -28,11 +35,10 @@
2835
->withArguments([
2936
'arg1' => 'this is arg1, is string'
3037
])
31-
->setHandler(function (FlagsParser $fs) {
38+
->setHandler(function (FlagsParser $fs): void {
3239
Cli::info('options:');
3340
vdump($fs->getOpts());
3441
Cli::info('arguments:');
3542
vdump($fs->getArgs());
3643
})
3744
->run();
38-

example/not-stop_on_first.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
1-
<?php
2-
// run: php example/not-stop_on_first.php
1+
<?php declare(strict_types=1);
2+
/**
3+
* This file is part of toolkit/pflag.
4+
*
5+
* @link https://github.com/php-toolkit
6+
* @author https://github.com/inhere
7+
* @license MIT
8+
*/
39

410
use Toolkit\PFlag\Flags;
511

example/refer.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
1-
<?php
1+
<?php declare(strict_types=1);
2+
/**
3+
* This file is part of toolkit/pflag.
4+
*
5+
* @link https://github.com/php-toolkit
6+
* @author https://github.com/inhere
7+
* @license MIT
8+
*/
29

310
$flags = ['--name', 'inhere', '--tags', 'php', '-t', 'go', '--tags', 'java', '-f', 'arg0'];
4-
echo "count: ", count($flags), "\n";
11+
echo 'count: ', count($flags), "\n";
512

613
$cur = current($flags);
714
$key = key($flags);

example/sflags-demo.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,4 +73,4 @@
7373
$fs->getArgs()
7474
);
7575

76-
// vdump($fs->getArg('arrArg'));
76+
// vdump($fs->getArg('arrArg'));

src/CliApp.php

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
<?php declare(strict_types=1);
2+
/**
3+
* This file is part of toolkit/pflag.
4+
*
5+
* @link https://github.com/php-toolkit
6+
* @author https://github.com/inhere
7+
* @license MIT
8+
*/
29

310
namespace Toolkit\PFlag;
411

@@ -660,14 +667,20 @@ public function setParams(array $params): void
660667

661668
/**
662669
* @param string $name
663-
*
664-
* @return void
665670
*/
666671
public function setName(string $name): void
667672
{
668673
$this->params['name'] = $name;
669674
}
670675

676+
/**
677+
* @param string $name
678+
*/
679+
public function setDesc(string $name): void
680+
{
681+
$this->params['name'] = $name;
682+
}
683+
671684
/**
672685
* @return FlagsParser
673686
*/

src/CliCmd.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
<?php declare(strict_types=1);
2+
/**
3+
* This file is part of toolkit/pflag.
4+
*
5+
* @link https://github.com/php-toolkit
6+
* @author https://github.com/inhere
7+
* @license MIT
8+
*/
29

310
namespace Toolkit\PFlag;
411

@@ -18,6 +25,7 @@ class CliCmd
1825
}
1926

2027
public string $name = '';
28+
2129
public string $desc = 'command description';
2230

2331
/**

src/Concern/HelperRenderTrait.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
<?php declare(strict_types=1);
2+
/**
3+
* This file is part of toolkit/pflag.
4+
*
5+
* @link https://github.com/php-toolkit
6+
* @author https://github.com/inhere
7+
* @license MIT
8+
*/
29

310
namespace Toolkit\PFlag\Concern;
411

src/Concern/RuleParserTrait.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
11
<?php declare(strict_types=1);
2+
/**
3+
* This file is part of toolkit/pflag.
4+
*
5+
* @link https://github.com/php-toolkit
6+
* @author https://github.com/inhere
7+
* @license MIT
8+
*/
29

310
namespace Toolkit\PFlag\Concern;
411

@@ -292,7 +299,7 @@ protected function parseRuleOptName(string $key): array
292299

293300
// max length string as option name.
294301
if (($kl = strlen($k)) > 1) {
295-
if (!$name ) {
302+
if (!$name) {
296303
$name = $k;
297304
} elseif ($kl > strlen($name)) {
298305
$aliases[] = $name;

0 commit comments

Comments
 (0)