<p dir="auto">Try to use ChoiceQuestion. Failure in any case<br>
State:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="&gt; php --version
&gt; PHP 5.5.9-1ubuntu4.11 (cli) (built: Jul  2 2015 15:23:08) "><pre class="notranslate"><code class="notranslate">&gt; php --version
&gt; PHP 5.5.9-1ubuntu4.11 (cli) (built: Jul  2 2015 15:23:08) 
</code></pre></div>
<p dir="auto">How to reproduce:<br>
create directory<br>
<code class="notranslate">mkdir /tmp/cons &amp;&amp; cd  /tmp/cons</code><br>
install console component<br>
<code class="notranslate">composer require "symfony/console:^2.7" </code><br>
create <code class="notranslate">test.php</code></p>
<div class="highlight highlight-text-html-php notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="&lt;?php
  require_once 'vendor/autoload.php';

  use Symfony\Component\Console\Application;
  use Symfony\Component\Console\Command\Command;
  use Symfony\Component\Console\Input\InputInterface;
  use Symfony\Component\Console\Output\OutputInterface;
  use Symfony\Component\Console\Question\ChoiceQuestion;

  class ColorCommand extends Command {

    protected function configure() {
      $this-&gt;setName('color');

    }

    protected function execute(InputInterface $input, OutputInterface $output) {
      $helper = $this-&gt;getHelper('question');
      $question = new ChoiceQuestion(
        'Please select your favorite color (defaults to red)',
        array('red', 'blue', 'yellow')
      );
      $question-&gt;setMultiselect(true);
      $question-&gt;setErrorMessage('Color %s is invalid.');

      $color = $helper-&gt;ask($input, $output, $question);
      $output-&gt;writeln('You have just selected: ' . $color);

    }
  }


  $application = new Application();
  $application-&gt;add(new ColorCommand());
  $application-&gt;run();"><pre class="notranslate"><span class="pl-ent">&lt;?php</span>
  <span class="pl-k">require_once</span> <span class="pl-s">'vendor/autoload.php'</span>;

  <span class="pl-k">use</span> <span class="pl-v">Symfony</span>\<span class="pl-v">Component</span>\<span class="pl-v">Console</span>\<span class="pl-v">Application</span>;
  <span class="pl-k">use</span> <span class="pl-v">Symfony</span>\<span class="pl-v">Component</span>\<span class="pl-v">Console</span>\<span class="pl-v">Command</span>\<span class="pl-v">Command</span>;
  <span class="pl-k">use</span> <span class="pl-v">Symfony</span>\<span class="pl-v">Component</span>\<span class="pl-v">Console</span>\<span class="pl-v">Input</span>\<span class="pl-v">InputInterface</span>;
  <span class="pl-k">use</span> <span class="pl-v">Symfony</span>\<span class="pl-v">Component</span>\<span class="pl-v">Console</span>\<span class="pl-v">Output</span>\<span class="pl-v">OutputInterface</span>;
  <span class="pl-k">use</span> <span class="pl-v">Symfony</span>\<span class="pl-v">Component</span>\<span class="pl-v">Console</span>\<span class="pl-v">Question</span>\<span class="pl-v">ChoiceQuestion</span>;

  <span class="pl-k">class</span> <span class="pl-v">ColorCommand</span> <span class="pl-k">extends</span> <span class="pl-v">Command</span> {

    <span class="pl-k">protected</span> <span class="pl-k">function</span> <span class="pl-en">configure</span>() {
      <span class="pl-s1"><span class="pl-c1">$</span><span class="pl-smi">this</span></span>-&gt;<span class="pl-en">setName</span>(<span class="pl-s">'color'</span>);

    }

    <span class="pl-k">protected</span> <span class="pl-k">function</span> <span class="pl-en">execute</span>(<span class="pl-smi"><span class="pl-smi">InputInterface</span></span> <span class="pl-s1"><span class="pl-c1">$</span>input</span>, <span class="pl-smi"><span class="pl-smi">OutputInterface</span></span> <span class="pl-s1"><span class="pl-c1">$</span>output</span>) {
      <span class="pl-s1"><span class="pl-c1">$</span>helper</span> = <span class="pl-s1"><span class="pl-c1">$</span><span class="pl-smi">this</span></span>-&gt;<span class="pl-en">getHelper</span>(<span class="pl-s">'question'</span>);
      <span class="pl-s1"><span class="pl-c1">$</span>question</span> = <span class="pl-k">new</span> <span class="pl-v">ChoiceQuestion</span>(
        <span class="pl-s">'Please select your favorite color (defaults to red)'</span>,
        <span class="pl-en">array</span>(<span class="pl-s">'red'</span>, <span class="pl-s">'blue'</span>, <span class="pl-s">'yellow'</span>)
      );
      <span class="pl-s1"><span class="pl-c1">$</span>question</span>-&gt;<span class="pl-en">setMultiselect</span>(<span class="pl-c1">true</span>);
      <span class="pl-s1"><span class="pl-c1">$</span>question</span>-&gt;<span class="pl-en">setErrorMessage</span>(<span class="pl-s">'Color %s is invalid.'</span>);

      <span class="pl-s1"><span class="pl-c1">$</span>color</span> = <span class="pl-s1"><span class="pl-c1">$</span>helper</span>-&gt;<span class="pl-en">ask</span>(<span class="pl-s1"><span class="pl-c1">$</span>input</span>, <span class="pl-s1"><span class="pl-c1">$</span>output</span>, <span class="pl-s1"><span class="pl-c1">$</span>question</span>);
      <span class="pl-s1"><span class="pl-c1">$</span>output</span>-&gt;<span class="pl-en">writeln</span>(<span class="pl-s">'You have just selected: '</span> . <span class="pl-s1"><span class="pl-c1">$</span>color</span>);

    }
  }


  <span class="pl-s1"><span class="pl-c1">$</span>application</span> = <span class="pl-k">new</span> <span class="pl-v">Application</span>();
  <span class="pl-s1"><span class="pl-c1">$</span>application</span>-&gt;<span class="pl-en">add</span>(<span class="pl-k">new</span> <span class="pl-v">ColorCommand</span>());
  <span class="pl-s1"><span class="pl-c1">$</span>application</span>-&gt;<span class="pl-en">run</span>();</pre></div>
<p dir="auto">Run <code class="notranslate">php test.php color</code><br>
Select any color.</p>
<p dir="auto">My result:<br>
<code class="notranslate">Notice: Undefined index: yellow in /tmp/cons/vendor/symfony/console/Question/ChoiceQuestion.php on line 165</code><br>
More backtrace:<br>
<a href="http://i.imgur.com/8hsLIwe.png" rel="nofollow">http://i.imgur.com/8hsLIwe.png</a><br>
<a href="http://i.imgur.com/UDyRsS4.png" rel="nofollow">http://i.imgur.com/UDyRsS4.png</a></p>
<p dir="auto"><a href="http://symfony.com/doc/current/components/console/helpers/questionhelper.html#let-the-user-choose-from-a-list-of-answers" rel="nofollow">The code sample</a> from the documentation produces the following errror.<br>
<code class="notranslate">PHP Notice:  Undefined index: blue in vendor/symfony/console/Question/ChoiceQuestion.php on line 165</code></p>
<p dir="auto">This error does not appear on 2.6 version.</p>