|
13 | 13 | use Framework\CLI\Styles\ForegroundColor; |
14 | 14 | use Framework\CLI\Styles\Format; |
15 | 15 | use JetBrains\PhpStorm\Pure; |
| 16 | +use Stringable; |
16 | 17 | use ValueError; |
17 | 18 |
|
18 | 19 | /** |
@@ -64,7 +65,7 @@ public static function getWidth(int $default = 80) : int |
64 | 65 | * |
65 | 66 | * @return string Returns the wrapped text |
66 | 67 | */ |
67 | | - public static function wrap(string $text, int $width = null) : string |
| 68 | + public static function wrap(string $text, ?int $width = null) : string |
68 | 69 | { |
69 | 70 | $width ??= static::getWidth(); |
70 | 71 | return \wordwrap($text, $width, \PHP_EOL, true); |
@@ -108,8 +109,8 @@ public static function strlen(string $text) : int |
108 | 109 | */ |
109 | 110 | public static function style( |
110 | 111 | string $text, |
111 | | - ForegroundColor | string $color = null, |
112 | | - BackgroundColor | string $background = null, |
| 112 | + ForegroundColor | string | null $color = null, |
| 113 | + BackgroundColor | string | null $background = null, |
113 | 114 | array $formats = [] |
114 | 115 | ) : string { |
115 | 116 | $string = ''; |
@@ -146,9 +147,9 @@ public static function style( |
146 | 147 | */ |
147 | 148 | public static function write( |
148 | 149 | string $text, |
149 | | - ForegroundColor | string $color = null, |
150 | | - BackgroundColor | string $background = null, |
151 | | - int $width = null |
| 150 | + ForegroundColor | string | null $color = null, |
| 151 | + BackgroundColor | string | null $background = null, |
| 152 | + ?int $width = null |
152 | 153 | ) : void { |
153 | 154 | if ($width !== null) { |
154 | 155 | $text = static::wrap($text, $width); |
@@ -310,7 +311,7 @@ public static function getInput(string $prepend = '') : string |
310 | 311 | * |
311 | 312 | * @return string The answer |
312 | 313 | */ |
313 | | - public static function prompt(string $question, array | string $options = null) : string |
| 314 | + public static function prompt(string $question, array | string | null $options = null) : string |
314 | 315 | { |
315 | 316 | if ($options !== null) { |
316 | 317 | $options = \is_array($options) |
@@ -356,8 +357,8 @@ public static function secret(string $question) : string |
356 | 357 | /** |
357 | 358 | * Creates a well formatted table. |
358 | 359 | * |
359 | | - * @param array<array<scalar|\Stringable>> $tbody Table body rows |
360 | | - * @param array<scalar|\Stringable> $thead Table head fields |
| 360 | + * @param array<array<Stringable|scalar>> $tbody Table body rows |
| 361 | + * @param array<Stringable|scalar> $thead Table head fields |
361 | 362 | */ |
362 | 363 | public static function table(array $tbody, array $thead = []) : void |
363 | 364 | { |
|
0 commit comments