Skip to content

Commit

Permalink
fix: CLI::prompt() may incorrectly return default value
Browse files Browse the repository at this point in the history
See CLITest::testPromptInputZero().
  • Loading branch information
kenjis committed May 8, 2024
1 parent aa1d6c6 commit ffbb4b7
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion system/CLI/CLI.php
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,8 @@ public static function prompt(string $field, $options = null, $validation = null
static::fwrite(STDOUT, $field . (trim($field) !== '' ? ' ' : '') . $extraOutput . ': ');

// Read the input from keyboard.
$input = trim(static::$io->input()) ?: (string) $default;
$input = trim(static::$io->input());
$input = ($input === '') ? (string) $default : $input;

if ($validation !== []) {
while (! static::validate('"' . trim($field) . '"', $input, $validation)) {
Expand Down

0 comments on commit ffbb4b7

Please sign in to comment.