Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Console] Error calling Input::getArguments()/getOptions() on empty input #5935

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

Closed
alwynn opened this issue Nov 8, 2012 · 0 comments
Closed
Labels

Comments

@alwynn
Copy link

alwynn commented Nov 8, 2012

Problem

When trying to retrieve arguments and/or options of the input in overloaded Symfony\Component\Console\Application::doRun() an error occurs as follows:

  1. Getting arguments
public function doRun(InputInterface $input, OutputInterface $output)
{
    $arguments = $input->getArguments();
    // ...
    return parent::doRun($input, $output);
}
  1. Getting options
public function doRun(InputInterface $input, OutputInterface $output)
{
    $options = $input->getOptions();
    // ...
    return parent::doRun($input, $output);
}

Both result in ErrorException being thrown after calling the console script (no matter the arguments and options list):

[ErrorException]                            
array_merge(): Argument #2 is not an array 

This behaviour is a direct result of properties Symfony\Component\Console\Input\Input::$options and Symfony\Component\Console\Input\Input::$attributes being set to null and not an empty array.

Proposed solution

Set default value of $options and $attributes properties to empty array.

abstract class Input implements InputInterface
{
    protected $definition;
    protected $options = array();
    protected $arguments = array();
    // ...
}

Symfony console installed as a composer asset in version v2.1.3 (as composer.lock file states).

fabpot added a commit to fabpot/symfony that referenced this issue Dec 30, 2012
@fabpot fabpot closed this as completed Jan 2, 2013
fabpot added a commit that referenced this issue Jan 4, 2013
* 2.0:
  updated license year
  Update src/Symfony/Component/HttpFoundation/Response.php
  [Console] fixed unitialized properties (closes #5935)
  [Bundle] [FrameworkBundle] fixed typo in phpdoc of the SessionListener.
  bumped Symfony version to 2.0.21-DEV
  updated VERSION for 2.0.21
  updated CHANGELOG for 2.0.21

Conflicts:
	src/Symfony/Bundle/SwiftmailerBundle/LICENSE
	src/Symfony/Component/Filesystem/LICENSE
	src/Symfony/Component/HttpFoundation/Response.php
	src/Symfony/Component/HttpKernel/Kernel.php
fabpot added a commit that referenced this issue Jan 4, 2013
* 2.1: (24 commits)
  updated license year
  Update src/Symfony/Component/HttpFoundation/Response.php
  [Form] Fixed inheritance of "error_bubbling" in RepeatedType
  [Form] Fixed DateType when used with the intl extension disabled.
  [HttpFoundation] fix return types and handling of zero in Response
  [HttpFoundation] better fix for non-parseable Expires header date
  Fixed missing plural message in portuguese validator
  Fix Expires when the header is -1
  [DoctrineBridge] Allowing memcache port to be 0 to support memcache unix domain sockets.
  [Console] fixed unitialized properties (closes #5935)
  [Process] Prevented test from failing when pcntl extension is not enabled.
  Revert "[DoctrineBridge] Improved performance of the EntityType when used with the "query_builder" option"
  [Form] Fixed failing tests for DateTimeToStringTransformer.
  [Locale] Fixed the StubLocaleTest for ICU versions lower than 4.8.
  [Bundle] [FrameworkBundle] fixed typo in phpdoc of the SessionListener.
  [Form] Fixed test regression introduced in #6440
  [Tests] Fix namespaces
  Fixed php doc of GenericEvent::__construct
  HttpUtils must handle RequestMatcher too
  use preferred_choices in favor of preferred_query
  ...

Conflicts:
	src/Symfony/Bridge/Propel1/Form/ChoiceList/ModelChoiceList.php
ostrolucky pushed a commit to ostrolucky/symfony that referenced this issue Mar 25, 2018
* 2.0:
  updated license year
  Update src/Symfony/Component/HttpFoundation/Response.php
  [Console] fixed unitialized properties (closes symfony#5935)
  [Bundle] [FrameworkBundle] fixed typo in phpdoc of the SessionListener.
  bumped Symfony version to 2.0.21-DEV
  updated VERSION for 2.0.21
  updated CHANGELOG for 2.0.21

Conflicts:
	src/Symfony/Bundle/SwiftmailerBundle/LICENSE
	src/Symfony/Component/Filesystem/LICENSE
	src/Symfony/Component/HttpFoundation/Response.php
	src/Symfony/Component/HttpKernel/Kernel.php
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants