function IOInterface::select
Asks the user to select a value.
@phpstan-return ($multiselect is true ? list<string> : string|int|bool)
Parameters
string $question The question to ask:
string[] $choices List of choices to pick from:
bool|string $default The default answer if the user enters nothing:
bool|int $attempts Max number of times to ask before giving up (false by default, which means infinite):
string $errorMessage Message which will be shown if invalid value from choice list would be picked:
bool $multiselect Select more than one value separated by comma:
Return value
int|string|list<string>|bool The selected value or values (the key of the choices array)
Throws
\InvalidArgumentException
2 methods override IOInterface::select()
- ConsoleIO::select in vendor/
composer/ composer/ src/ Composer/ IO/ ConsoleIO.php - @inheritDoc
- NullIO::select in vendor/
composer/ composer/ src/ Composer/ IO/ NullIO.php - @inheritDoc
File
-
vendor/
composer/ composer/ src/ Composer/ IO/ IOInterface.php, line 198
Class
- IOInterface
- The Input/Output helper interface.
Namespace
Composer\IOCode
public function select(string $question, array $choices, $default, $attempts = false, string $errorMessage = 'Value "%s" is invalid', bool $multiselect = false);