Laravel Version
13.x (2c41056)
PHP Version
8.5.9
Database Driver & Version
No response
Description
Laravel\Prompts\NumberPrompt is the only prompt type that has no fallback registered in Illuminate\Console\Concerns\ConfiguresPrompts. Every other prompt (text, textarea, password, pause, confirm, select, multiselect, suggest, search, multisearch) registers one via fallbackUsing().
Prompts fall back to plain Symfony console questions whenever Prompt::fallbackWhen(windows_os() || $this->laravel->runningUnitTests()) is true — i.e. on Windows, in non-TTY/non-interactive contexts, and in tests. In all of those cases number() throws instead of degrading gracefully:
RuntimeException: No fallback implementation registered for [Laravel\Prompts\NumberPrompt]
(vendor/laravel/prompts/src/Concerns/Fallback.php:56)
This contradicts the documentation, which states that "fallbacks for each prompt have been configured for you." In practice it means a command using number() cannot run on Windows and cannot be tested with expectsQuestion().
Steps To Reproduce
Given a command that uses number():
public function handle()
{
$count = number('How many people?');
$this->line("There are {$count} people.");
}
Test it (or simply run it on Windows / a non-interactive shell):
$this->artisan('your:command')
->expectsQuestion('How many people?', 5)
->expectsOutput('There are 5 people.');
Expected: the fallback asks the question and returns the number, like every other prompt type.
Actual: it errors with RuntimeException: No fallback implementation registered for [Laravel\Prompts\NumberPrompt].
Laravel Version
13.x (2c41056)
PHP Version
8.5.9
Database Driver & Version
No response
Description
Laravel\Prompts\NumberPromptis the only prompt type that has no fallback registered inIlluminate\Console\Concerns\ConfiguresPrompts. Every other prompt (text,textarea,password,pause,confirm,select,multiselect,suggest,search,multisearch) registers one viafallbackUsing().Prompts fall back to plain Symfony console questions whenever
Prompt::fallbackWhen(windows_os() || $this->laravel->runningUnitTests())is true — i.e. on Windows, in non-TTY/non-interactive contexts, and in tests. In all of those casesnumber()throws instead of degrading gracefully:This contradicts the documentation, which states that "fallbacks for each prompt have been configured for you." In practice it means a command using
number()cannot run on Windows and cannot be tested withexpectsQuestion().Steps To Reproduce
Given a command that uses
number():Test it (or simply run it on Windows / a non-interactive shell):
Expected: the fallback asks the question and returns the number, like every other prompt type.
Actual: it errors with
RuntimeException: No fallback implementation registered for [Laravel\Prompts\NumberPrompt].