Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
gcKevinAnneix opened this issue Nov 1, 2014 · 1 comment
Closed

Comments

@gcKevinAnneix
Copy link

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
@xabbuh
Copy link
Member

xabbuh commented Nov 1, 2014

Thank you for reporting this @kevinAnneix. This should be fixed with #4407.

wouterj added a commit that referenced this issue Nov 8, 2014
…es (xabbuh)

This PR was merged into the 2.3 branch.

Discussion
----------

[Components][Console] array options need array default values

| Q             | A
| ------------- | ---
| Doc fix?      | yes
| New docs?     | no
| Applies to    | all
| Fixed tickets | #4406

Commits
-------

74b9555 array options need array default values
@wouterj wouterj closed this as completed Nov 8, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants