Skip to content

[console] Example by multiple InputOption triggers an Exception #4406

Closed
@gcKevinAnneix

Description

@gcKevinAnneix

Hi,

The following example in http://symfony.com/doc/current/components/console/introduction.html

->addOption(
    'iterations',
    null,
    InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY,
    'How many times should the message be printed?',
    1
);

triggers the following exceptions:

PHP Fatal error:  Uncaught exception 'LogicException' with message 'A default value for an array option must be an array.' in ..Console/vendor/symfony/console/Symfony/Component/Console/Input/InputOption.php:169

Stack trace: 
#0 Console/vendor/symfony/console/Symfony/Component/Console/Input/InputOption.php(89): Symfony\Component\Console\Input\InputOption->setDefault(1)
#1 Console/vendor/symfony/console/Symfony/Component/Console/Command/Command.php(395): Symfony\Component\Console\Input\InputOption->__construct('iterations', NULL, 10, 'How many times ...', 1)
#2 Console/Acme/Console/Command/GreetCommand.php(43): Symfony\Component\Console\Command\Command->addOption('iterations', NULL, 10, 'How many times ...', 1)
#3 Console/vendor/symfony/console/Symfony/Component/Console/Command/Command.php(6 in Console/vendor/symfony/console/Symfony/Component/Console/Input/InputOption.php on line 169

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions