Skip to content

Fix default values not being passed #174

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 30, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions src/helpers.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}

Expand All @@ -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();
}
}

Expand All @@ -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();
}
}

Expand All @@ -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();
}
}

Expand All @@ -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();
}
}

Expand All @@ -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();
}
}

Expand All @@ -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();
}
}

Expand All @@ -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();
}
}

Expand All @@ -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();
}
}

Expand All @@ -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();
}
}

Expand Down