Skip to content

Commit 04b328c

Browse files
committed
Upgrade coding standard
1 parent b3ab8b0 commit 04b328c

File tree

4 files changed

+16
-15
lines changed

4 files changed

+16
-15
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
},
4040
"require-dev": {
4141
"ext-xdebug": "*",
42-
"aplus/coding-standard": "^2.1",
42+
"aplus/coding-standard": "^2.8",
4343
"ergebnis/composer-normalize": "^2.25",
4444
"jetbrains/phpstorm-attributes": "^1.0",
4545
"phpmd/phpmd": "^2.13",

src/CLI.php

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use Framework\CLI\Styles\ForegroundColor;
1414
use Framework\CLI\Styles\Format;
1515
use JetBrains\PhpStorm\Pure;
16+
use Stringable;
1617
use ValueError;
1718

1819
/**
@@ -64,7 +65,7 @@ public static function getWidth(int $default = 80) : int
6465
*
6566
* @return string Returns the wrapped text
6667
*/
67-
public static function wrap(string $text, int $width = null) : string
68+
public static function wrap(string $text, ?int $width = null) : string
6869
{
6970
$width ??= static::getWidth();
7071
return \wordwrap($text, $width, \PHP_EOL, true);
@@ -108,8 +109,8 @@ public static function strlen(string $text) : int
108109
*/
109110
public static function style(
110111
string $text,
111-
ForegroundColor | string $color = null,
112-
BackgroundColor | string $background = null,
112+
ForegroundColor | string | null $color = null,
113+
BackgroundColor | string | null $background = null,
113114
array $formats = []
114115
) : string {
115116
$string = '';
@@ -146,9 +147,9 @@ public static function style(
146147
*/
147148
public static function write(
148149
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
152153
) : void {
153154
if ($width !== null) {
154155
$text = static::wrap($text, $width);
@@ -310,7 +311,7 @@ public static function getInput(string $prepend = '') : string
310311
*
311312
* @return string The answer
312313
*/
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
314315
{
315316
if ($options !== null) {
316317
$options = \is_array($options)
@@ -356,8 +357,8 @@ public static function secret(string $question) : string
356357
/**
357358
* Creates a well formatted table.
358359
*
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
361362
*/
362363
public static function table(array $tbody, array $thead = []) : void
363364
{

src/Command.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ abstract class Command
5454
*
5555
* @param Console|null $console
5656
*/
57-
public function __construct(Console $console = null)
57+
public function __construct(?Console $console = null)
5858
{
5959
if ($console) {
6060
$this->console = $console;

src/Console.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ class Console
5656
*
5757
* @param Language|null $language
5858
*/
59-
public function __construct(Language $language = null)
59+
public function __construct(?Language $language = null)
6060
{
6161
if ($language) {
6262
$this->setLanguage($language);
@@ -136,7 +136,7 @@ public function getArgument(int $position) : ?string
136136
*
137137
* @return static
138138
*/
139-
public function setLanguage(Language $language = null) : static
139+
public function setLanguage(?Language $language = null) : static
140140
{
141141
$this->language = $language ?? new Language();
142142
$this->language->addDirectory(__DIR__ . '/Languages');
@@ -159,7 +159,7 @@ public function getLanguage() : Language
159159
/**
160160
* Add a command to the console.
161161
*
162-
* @param class-string<Command>|Command $command A Command instance or the class FQN
162+
* @param Command|class-string<Command> $command A Command instance or the class FQN
163163
*
164164
* @return static
165165
*/
@@ -176,7 +176,7 @@ public function addCommand(Command | string $command) : static
176176
/**
177177
* Add many commands to the console.
178178
*
179-
* @param array<class-string<Command>|Command> $commands A list of Command
179+
* @param array<Command|class-string<Command>> $commands A list of Command
180180
* instances or the classes FQN
181181
*
182182
* @return static

0 commit comments

Comments
 (0)