Skip to content

Commit d8be9b3

Browse files
committed
style: fix Choose.php code sytle in php8.4
1 parent 4c38dfa commit d8be9b3

File tree

4 files changed

+13
-12
lines changed

4 files changed

+13
-12
lines changed

src/Component/Formatter/Padding.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public static function show(array $data, string $title = '', array $opts = []):
5353
], $opts);
5454

5555
$keyMaxLen = ArrayHelper::getKeyMaxWidth($data);
56-
$paddingLen = $keyMaxLen > $opts['padding'] ? $keyMaxLen : $opts['padding'];
56+
$paddingLen = max($keyMaxLen, $opts['padding']);
5757

5858
foreach ($data as $label => $value) {
5959
$value = ColorTag::wrap((string)$value, $opts['valueStyle']);

src/Component/Interact/Choose.php

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,23 +29,24 @@ class Choose extends SingleSelect
2929
/**
3030
* Choose one of several options
3131
*
32-
* @param string $description
32+
* Options:
33+
* e.g: [
34+
* // option => value
35+
* '1' => 'chengdu',
36+
* '2' => 'beijing'
37+
* ]
38+
*
39+
* @param string $description
3340
* @param array|string $options Option data
34-
* e.g
35-
* [
36-
* // option => value
37-
* '1' => 'chengdu',
38-
* '2' => 'beijing'
39-
* ]
4041
* @param int|string|null $default Default option
4142
* @param bool $allowExit
4243
* @param array $opts
4344
*
44-
* @psalm-param array{returnVal: bool, retFilter: callable} $opts
45+
* @psalm-param array{returnVal: bool, retFilter: callable} $opts
4546
*
4647
* @return string
4748
*/
48-
public static function one(string $description, array|string $options, int|string $default = null, bool $allowExit = true, array $opts = []): string
49+
public static function one(string $description, array|string $options, int|string|null $default = null, bool $allowExit = true, array $opts = []): string
4950
{
5051
if (!$description = trim($description)) {
5152
Show::error('Please provide a description text!', 1);

src/Component/Interact/LimitedAsk.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public static function ask(
115115
return $default;
116116
}
117117

118-
Console::write("\n You've entered incorrectly <danger>$back</danger> times in a row. exit!", true, 1);
118+
Console::write("\n You've entered incorrectly <danger>$back</danger> times in a row. exit!", true, true);
119119
return '';
120120
}
121121
}

src/Contract/ApplicationInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public function command(string $name, string|Closure|CommandInterface|null $hand
8282
/**
8383
* @return void
8484
*/
85-
public function showCommandList();
85+
public function showCommandList(): void;
8686

8787
/**
8888
* @return string

0 commit comments

Comments
 (0)