Skip to content

Commit 24482ff

Browse files
committed
chore: update some method comments
1 parent 74efe71 commit 24482ff

File tree

3 files changed

+17
-45
lines changed

3 files changed

+17
-45
lines changed

Diff for: .php_cs renamed to .php-cs-fixer.php

+8-3
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,21 @@
33
$header = <<<'EOF'
44
This file is part of toolkit/cli-utils.
55
6-
@homepage https://github.com/php-toolkit/cli-utils
6+
@link https://github.com/php-toolkit/cli-utils
77
@author https://github.com/inhere
88
@license MIT
99
EOF;
1010

11-
return (new PhpCsFixer\Config)
11+
return (new PhpCsFixer\Config())
1212
->setRiskyAllowed(true)
1313
->setRules([
1414
'@PSR2' => true,
1515
'array_syntax' => [
1616
'syntax' => 'short'
1717
],
18+
'list_syntax' => [
19+
'syntax' => 'short'
20+
],
1821
'class_attributes_separation' => true,
1922
'declare_strict_types' => true,
2023
'global_namespace_import' => [
@@ -29,11 +32,13 @@
2932
'no_unused_imports' => true,
3033
'single_quote' => true,
3134
'standardize_not_equals' => true,
35+
'void_return' => true, // add :void for method
3236
])
3337
->setFinder(
3438
PhpCsFixer\Finder::create()
35-
// ->exclude('test')
39+
->exclude('test')
3640
->exclude('runtime')
41+
->exclude('.github')
3742
->exclude('vendor')
3843
->in(__DIR__)
3944
)

Diff for: src/Cli.php

+9-5
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public static function __callStatic(string $method, array $args)
9494
*/
9595
public static function colored(array|string $message, array|string $style = 'info'): void
9696
{
97-
$str = is_array($message) ? implode(' ', $message) : (string)$message;
97+
$str = is_array($message) ? implode(' ', $message) : $message;
9898

9999
echo Color::render($str, $style) . PHP_EOL;
100100
}
@@ -134,16 +134,20 @@ public static function color(string $text, array|string $style = null): string
134134
/**
135135
* print log to console
136136
*
137-
* @param string $msg
138-
* @param array $data
139-
* @param string $type
140-
* @param array{writeOpts:array} $labels
137+
* ```php
141138
* [
142139
* '_category' => 'application',
143140
* 'process' => 'work',
144141
* 'pid' => 234,
145142
* 'coId' => 12,
146143
* ]
144+
* ```
145+
*
146+
* @param string $msg
147+
* @param array $data
148+
* @param string $type
149+
* @param array{writeOpts:array} $labels
150+
* @deprecated please use Clog::info();
147151
*/
148152
public static function clog(string $msg, array $data = [], string $type = 'info', array $labels = []): void
149153
{

Diff for: src/Helper/CliHelper.php

-37
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace Toolkit\Cli\Helper;
44

55
use function escapeshellarg;
6-
use function explode;
76
use function is_bool;
87
use function is_numeric;
98
use function preg_match;
@@ -64,42 +63,6 @@ public static function filterBool(mixed $val): mixed
6463
return $val;
6564
}
6665

67-
/**
68-
* check input is valid option value
69-
*
70-
* @param mixed $val
71-
*
72-
* @return bool
73-
*/
74-
public static function isOptionValue(mixed $val): bool
75-
{
76-
if ($val === false) {
77-
return false;
78-
}
79-
80-
// if is: '', 0
81-
if (!$val) {
82-
return true;
83-
}
84-
85-
// is not option name.
86-
if ($val[0] !== '-') {
87-
// ensure is option value.
88-
if (!str_contains($val, '=')) {
89-
return true;
90-
}
91-
92-
// is string value, but contains '='
93-
[$name,] = explode('=', $val, 2);
94-
95-
// named argument OR invalid: 'some = string'
96-
return false === self::isValidName($name);
97-
}
98-
99-
// is option name.
100-
return false;
101-
}
102-
10366
/**
10467
* @param string $name
10568
*

0 commit comments

Comments
 (0)