From 90eaad948195b57eabfa034c204e47307ff9e4c6 Mon Sep 17 00:00:00 2001 From: jessarcher Date: Wed, 27 Dec 2023 04:14:29 +0000 Subject: [PATCH] Fix code styling --- src/Concerns/Scrolling.php | 2 +- src/Concerns/Themes.php | 2 +- src/Concerns/TypedValue.php | 2 +- src/Table.php | 2 +- src/Themes/Default/Renderer.php | 2 +- src/helpers.php | 22 +++++++++++----------- 6 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/Concerns/Scrolling.php b/src/Concerns/Scrolling.php index 04185766..f62be7c4 100644 --- a/src/Concerns/Scrolling.php +++ b/src/Concerns/Scrolling.php @@ -24,7 +24,7 @@ trait Scrolling /** * Initialize scrolling. */ - protected function initializeScrolling(int $highlighted = null): void + protected function initializeScrolling(?int $highlighted = null): void { $this->highlighted = $highlighted; diff --git a/src/Concerns/Themes.php b/src/Concerns/Themes.php index 58de8c0a..62e61142 100644 --- a/src/Concerns/Themes.php +++ b/src/Concerns/Themes.php @@ -62,7 +62,7 @@ trait Themes * * @throws \InvalidArgumentException */ - public static function theme(string $name = null): string + public static function theme(?string $name = null): string { if ($name === null) { return static::$theme; diff --git a/src/Concerns/TypedValue.php b/src/Concerns/TypedValue.php index afde293a..343e77b8 100644 --- a/src/Concerns/TypedValue.php +++ b/src/Concerns/TypedValue.php @@ -19,7 +19,7 @@ trait TypedValue /** * Track the value as the user types. */ - protected function trackTypedValue(string $default = '', bool $submit = true, callable $ignore = null): void + protected function trackTypedValue(string $default = '', bool $submit = true, ?callable $ignore = null): void { $this->typedValue = $default; diff --git a/src/Table.php b/src/Table.php index 79eff029..a7de3700 100644 --- a/src/Table.php +++ b/src/Table.php @@ -28,7 +28,7 @@ class Table extends Prompt * * @phpstan-param ($rows is null ? list>|Collection> : list>|Collection>) $headers */ - public function __construct(array|Collection $headers = [], array|Collection $rows = null) + public function __construct(array|Collection $headers = [], array|Collection|null $rows = null) { if ($rows === null) { $rows = $headers; diff --git a/src/Themes/Default/Renderer.php b/src/Themes/Default/Renderer.php index a2f2581c..61f40afa 100644 --- a/src/Themes/Default/Renderer.php +++ b/src/Themes/Default/Renderer.php @@ -80,7 +80,7 @@ protected function hint(string $message): self * * @return $this */ - protected function when(mixed $value, callable $callback, callable $default = null): self + protected function when(mixed $value, callable $callback, ?callable $default = null): self { if ($value) { $callback($this); diff --git a/src/helpers.php b/src/helpers.php index 178cb22f..b28d8840 100644 --- a/src/helpers.php +++ b/src/helpers.php @@ -8,7 +8,7 @@ /** * Prompt the user for text input. */ -function text(string $label, string $placeholder = '', string $default = '', bool|string $required = false, Closure $validate = null, string $hint = ''): string +function text(string $label, string $placeholder = '', string $default = '', bool|string $required = false, ?Closure $validate = null, string $hint = ''): string { return (new TextPrompt($label, $placeholder, $default, $required, $validate, $hint))->prompt(); } @@ -16,7 +16,7 @@ function text(string $label, string $placeholder = '', string $default = '', boo /** * Prompt the user for input, hiding the value. */ -function password(string $label, string $placeholder = '', bool|string $required = false, Closure $validate = null, string $hint = ''): string +function password(string $label, string $placeholder = '', bool|string $required = false, ?Closure $validate = null, string $hint = ''): string { return (new PasswordPrompt($label, $placeholder, $required, $validate, $hint))->prompt(); } @@ -27,7 +27,7 @@ function password(string $label, string $placeholder = '', bool|string $required * @param array|Collection $options * @param true|string $required */ -function select(string $label, array|Collection $options, int|string $default = null, int $scroll = 5, Closure $validate = null, string $hint = '', bool|string $required = true): int|string +function select(string $label, array|Collection $options, int|string|null $default = null, int $scroll = 5, ?Closure $validate = null, string $hint = '', bool|string $required = true): int|string { return (new SelectPrompt($label, $options, $default, $scroll, $validate, $hint, $required))->prompt(); } @@ -39,7 +39,7 @@ function select(string $label, array|Collection $options, int|string $default = * @param array|Collection $default * @return array */ -function multiselect(string $label, array|Collection $options, array|Collection $default = [], int $scroll = 5, bool|string $required = false, Closure $validate = null, string $hint = 'Use the space bar to select options.'): array +function multiselect(string $label, array|Collection $options, array|Collection $default = [], int $scroll = 5, bool|string $required = false, ?Closure $validate = null, string $hint = 'Use the space bar to select options.'): array { return (new MultiSelectPrompt($label, $options, $default, $scroll, $required, $validate, $hint))->prompt(); } @@ -47,7 +47,7 @@ function multiselect(string $label, array|Collection $options, array|Collection /** * Prompt the user to confirm an action. */ -function confirm(string $label, bool $default = true, string $yes = 'Yes', string $no = 'No', bool|string $required = false, Closure $validate = null, string $hint = ''): bool +function confirm(string $label, bool $default = true, string $yes = 'Yes', string $no = 'No', bool|string $required = false, ?Closure $validate = null, string $hint = ''): bool { return (new ConfirmPrompt($label, $default, $yes, $no, $required, $validate, $hint))->prompt(); } @@ -57,7 +57,7 @@ function confirm(string $label, bool $default = true, string $yes = 'Yes', strin * * @param array|Collection|Closure(string): array $options */ -function suggest(string $label, array|Collection|Closure $options, string $placeholder = '', string $default = '', int $scroll = 5, bool|string $required = false, Closure $validate = null, string $hint = ''): string +function suggest(string $label, array|Collection|Closure $options, string $placeholder = '', string $default = '', int $scroll = 5, bool|string $required = false, ?Closure $validate = null, string $hint = ''): string { return (new SuggestPrompt($label, $options, $placeholder, $default, $scroll, $required, $validate, $hint))->prompt(); } @@ -68,7 +68,7 @@ function suggest(string $label, array|Collection|Closure $options, string $place * @param Closure(string): array $options * @param true|string $required */ -function search(string $label, Closure $options, string $placeholder = '', int $scroll = 5, Closure $validate = null, string $hint = '', bool|string $required = true): int|string +function search(string $label, Closure $options, string $placeholder = '', int $scroll = 5, ?Closure $validate = null, string $hint = '', bool|string $required = true): int|string { return (new SearchPrompt($label, $options, $placeholder, $scroll, $validate, $hint, $required))->prompt(); } @@ -79,7 +79,7 @@ function search(string $label, Closure $options, string $placeholder = '', int $ * @param Closure(string): array $options * @return array */ -function multisearch(string $label, Closure $options, string $placeholder = '', int $scroll = 5, bool|string $required = false, Closure $validate = null, string $hint = 'Use the space bar to select options.'): array +function multisearch(string $label, Closure $options, string $placeholder = '', int $scroll = 5, bool|string $required = false, ?Closure $validate = null, string $hint = 'Use the space bar to select options.'): array { return (new MultiSearchPrompt($label, $options, $placeholder, $scroll, $required, $validate, $hint))->prompt(); } @@ -100,7 +100,7 @@ function spin(Closure $callback, string $message = ''): mixed /** * Display a note. */ -function note(string $message, string $type = null): void +function note(string $message, ?string $type = null): void { (new Note($message, $type))->display(); } @@ -159,7 +159,7 @@ function outro(string $message): void * @param array>|Collection> $headers * @param array>|Collection> $rows */ -function table(array|Collection $headers = [], array|Collection $rows = null): void +function table(array|Collection $headers = [], array|Collection|null $rows = null): void { (new Table($headers, $rows))->display(); } @@ -174,7 +174,7 @@ function table(array|Collection $headers = [], array|Collection $rows = null): v * @param ?Closure((TSteps is int ? int : value-of), Progress): TReturn $callback * @return ($callback is null ? Progress : array) */ -function progress(string $label, iterable|int $steps, Closure $callback = null, string $hint = ''): array|Progress +function progress(string $label, iterable|int $steps, ?Closure $callback = null, string $hint = ''): array|Progress { $progress = new Progress($label, $steps, $hint);