Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. IOInterface.php

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\IO

Code

public function select(string $question, array $choices, $default, $attempts = false, string $errorMessage = 'Value "%s" is invalid', bool $multiselect = false);

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal