From ea57a2261093986721d4a5f4f9524d76f21f9fa0 Mon Sep 17 00:00:00 2001 From: Jess Archer Date: Tue, 1 Oct 2024 00:27:51 +1000 Subject: [PATCH] Fix default values not being passed (#174) --- src/helpers.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/helpers.php b/src/helpers.php index 8965cb8..e5386c4 100644 --- a/src/helpers.php +++ b/src/helpers.php @@ -11,7 +11,7 @@ */ function text(string $label, string $placeholder = '', string $default = '', bool|string $required = false, mixed $validate = null, string $hint = '', ?Closure $transform = null): string { - return (new TextPrompt(...func_get_args()))->prompt(); + return (new TextPrompt(...get_defined_vars()))->prompt(); } } @@ -21,7 +21,7 @@ function text(string $label, string $placeholder = '', string $default = '', boo */ function textarea(string $label, string $placeholder = '', string $default = '', bool|string $required = false, mixed $validate = null, string $hint = '', int $rows = 5, ?Closure $transform = null): string { - return (new TextareaPrompt(...func_get_args()))->prompt(); + return (new TextareaPrompt(...get_defined_vars()))->prompt(); } } @@ -31,7 +31,7 @@ function textarea(string $label, string $placeholder = '', string $default = '', */ function password(string $label, string $placeholder = '', bool|string $required = false, mixed $validate = null, string $hint = '', ?Closure $transform = null): string { - return (new PasswordPrompt(...func_get_args()))->prompt(); + return (new PasswordPrompt(...get_defined_vars()))->prompt(); } } @@ -44,7 +44,7 @@ function password(string $label, string $placeholder = '', bool|string $required */ function select(string $label, array|Collection $options, int|string|null $default = null, int $scroll = 5, mixed $validate = null, string $hint = '', bool|string $required = true, ?Closure $transform = null): int|string { - return (new SelectPrompt(...func_get_args()))->prompt(); + return (new SelectPrompt(...get_defined_vars()))->prompt(); } } @@ -58,7 +58,7 @@ function select(string $label, array|Collection $options, int|string|null $defau */ function multiselect(string $label, array|Collection $options, array|Collection $default = [], int $scroll = 5, bool|string $required = false, mixed $validate = null, string $hint = 'Use the space bar to select options.', ?Closure $transform = null): array { - return (new MultiSelectPrompt(...func_get_args()))->prompt(); + return (new MultiSelectPrompt(...get_defined_vars()))->prompt(); } } @@ -68,7 +68,7 @@ function multiselect(string $label, array|Collection $options, array|Collection */ function confirm(string $label, bool $default = true, string $yes = 'Yes', string $no = 'No', bool|string $required = false, mixed $validate = null, string $hint = '', ?Closure $transform = null): bool { - return (new ConfirmPrompt(...func_get_args()))->prompt(); + return (new ConfirmPrompt(...get_defined_vars()))->prompt(); } } @@ -78,7 +78,7 @@ function confirm(string $label, bool $default = true, string $yes = 'Yes', strin */ function pause(string $message = 'Press enter to continue...'): bool { - return (new PausePrompt(...func_get_args()))->prompt(); + return (new PausePrompt(...get_defined_vars()))->prompt(); } } @@ -100,7 +100,7 @@ function clear(): void */ function suggest(string $label, array|Collection|Closure $options, string $placeholder = '', string $default = '', int $scroll = 5, bool|string $required = false, mixed $validate = null, string $hint = '', ?Closure $transform = null): string { - return (new SuggestPrompt(...func_get_args()))->prompt(); + return (new SuggestPrompt(...get_defined_vars()))->prompt(); } } @@ -113,7 +113,7 @@ function suggest(string $label, array|Collection|Closure $options, string $place */ function search(string $label, Closure $options, string $placeholder = '', int $scroll = 5, mixed $validate = null, string $hint = '', bool|string $required = true, ?Closure $transform = null): int|string { - return (new SearchPrompt(...func_get_args()))->prompt(); + return (new SearchPrompt(...get_defined_vars()))->prompt(); } } @@ -126,7 +126,7 @@ function search(string $label, Closure $options, string $placeholder = '', int $ */ function multisearch(string $label, Closure $options, string $placeholder = '', int $scroll = 5, bool|string $required = false, mixed $validate = null, string $hint = 'Use the space bar to select options.', ?Closure $transform = null): array { - return (new MultiSearchPrompt(...func_get_args()))->prompt(); + return (new MultiSearchPrompt(...get_defined_vars()))->prompt(); } }