Skip to content

Commit

Permalink
Upgrade coding standard
Browse files Browse the repository at this point in the history
  • Loading branch information
natanfelles committed Aug 23, 2024
1 parent b3ab8b0 commit 04b328c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 15 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
},
"require-dev": {
"ext-xdebug": "*",
"aplus/coding-standard": "^2.1",
"aplus/coding-standard": "^2.8",
"ergebnis/composer-normalize": "^2.25",
"jetbrains/phpstorm-attributes": "^1.0",
"phpmd/phpmd": "^2.13",
Expand Down
19 changes: 10 additions & 9 deletions src/CLI.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Framework\CLI\Styles\ForegroundColor;
use Framework\CLI\Styles\Format;
use JetBrains\PhpStorm\Pure;
use Stringable;
use ValueError;

/**
Expand Down Expand Up @@ -64,7 +65,7 @@ public static function getWidth(int $default = 80) : int
*
* @return string Returns the wrapped text
*/
public static function wrap(string $text, int $width = null) : string
public static function wrap(string $text, ?int $width = null) : string
{
$width ??= static::getWidth();
return \wordwrap($text, $width, \PHP_EOL, true);
Expand Down Expand Up @@ -108,8 +109,8 @@ public static function strlen(string $text) : int
*/
public static function style(
string $text,
ForegroundColor | string $color = null,
BackgroundColor | string $background = null,
ForegroundColor | string | null $color = null,
BackgroundColor | string | null $background = null,
array $formats = []
) : string {
$string = '';
Expand Down Expand Up @@ -146,9 +147,9 @@ public static function style(
*/
public static function write(
string $text,
ForegroundColor | string $color = null,
BackgroundColor | string $background = null,
int $width = null
ForegroundColor | string | null $color = null,
BackgroundColor | string | null $background = null,
?int $width = null
) : void {
if ($width !== null) {
$text = static::wrap($text, $width);
Expand Down Expand Up @@ -310,7 +311,7 @@ public static function getInput(string $prepend = '') : string
*
* @return string The answer
*/
public static function prompt(string $question, array | string $options = null) : string
public static function prompt(string $question, array | string | null $options = null) : string
{
if ($options !== null) {
$options = \is_array($options)
Expand Down Expand Up @@ -356,8 +357,8 @@ public static function secret(string $question) : string
/**
* Creates a well formatted table.
*
* @param array<array<scalar|\Stringable>> $tbody Table body rows
* @param array<scalar|\Stringable> $thead Table head fields
* @param array<array<Stringable|scalar>> $tbody Table body rows
* @param array<Stringable|scalar> $thead Table head fields
*/
public static function table(array $tbody, array $thead = []) : void
{
Expand Down
2 changes: 1 addition & 1 deletion src/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ abstract class Command
*
* @param Console|null $console
*/
public function __construct(Console $console = null)
public function __construct(?Console $console = null)
{
if ($console) {
$this->console = $console;
Expand Down
8 changes: 4 additions & 4 deletions src/Console.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class Console
*
* @param Language|null $language
*/
public function __construct(Language $language = null)
public function __construct(?Language $language = null)
{
if ($language) {
$this->setLanguage($language);
Expand Down Expand Up @@ -136,7 +136,7 @@ public function getArgument(int $position) : ?string
*
* @return static
*/
public function setLanguage(Language $language = null) : static
public function setLanguage(?Language $language = null) : static
{
$this->language = $language ?? new Language();
$this->language->addDirectory(__DIR__ . '/Languages');
Expand All @@ -159,7 +159,7 @@ public function getLanguage() : Language
/**
* Add a command to the console.
*
* @param class-string<Command>|Command $command A Command instance or the class FQN
* @param Command|class-string<Command> $command A Command instance or the class FQN
*
* @return static
*/
Expand All @@ -176,7 +176,7 @@ public function addCommand(Command | string $command) : static
/**
* Add many commands to the console.
*
* @param array<class-string<Command>|Command> $commands A list of Command
* @param array<Command|class-string<Command>> $commands A list of Command
* instances or the classes FQN
*
* @return static
Expand Down

0 comments on commit 04b328c

Please sign in to comment.