diff --git a/src/Symfony/Component/Console/Input/ArgvInput.php b/src/Symfony/Component/Console/Input/ArgvInput.php index 2618c0691a..9addf1483d 100644 --- a/src/Symfony/Component/Console/Input/ArgvInput.php +++ b/src/Symfony/Component/Console/Input/ArgvInput.php @@ -68,7 +68,6 @@ class ArgvInput extends Input protected function setTokens(array $tokens) { $this->tokens = $tokens; - $this->parse(); } /** diff --git a/src/Symfony/Component/Console/Input/StringInput.php b/src/Symfony/Component/Console/Input/StringInput.php index 93b1b83bb1..1bf1dc9c8e 100644 --- a/src/Symfony/Component/Console/Input/StringInput.php +++ b/src/Symfony/Component/Console/Input/StringInput.php @@ -37,9 +37,13 @@ class StringInput extends ArgvInput */ public function __construct($input, InputDefinition $definition = null) { - parent::__construct(array(), $definition); + parent::__construct(array(), null); $this->setTokens($this->tokenize($input)); + + if (null !== $definition) { + $this->bind($definition); + } } /** diff --git a/src/Symfony/Component/Console/Tests/Input/StringInputTest.php b/src/Symfony/Component/Console/Tests/Input/StringInputTest.php index 4a165d4a30..1ce5fe6274 100644 --- a/src/Symfony/Component/Console/Tests/Input/StringInputTest.php +++ b/src/Symfony/Component/Console/Tests/Input/StringInputTest.php @@ -11,9 +11,9 @@ namespace Symfony\Component\Console\Tests\Input; -use Symfony\Component\Console\Input\StringInput; use Symfony\Component\Console\Input\InputDefinition; use Symfony\Component\Console\Input\InputOption; +use Symfony\Component\Console\Input\StringInput; class StringInputTest extends \PHPUnit_Framework_TestCase { @@ -35,10 +35,14 @@ class StringInputTest extends \PHPUnit_Framework_TestCase array(new InputOption('foo', null, InputOption::VALUE_REQUIRED)) ); - $input = new StringInput('--foo=bar', $definition); - $actual = $input->getOption('foo'); + // call to bind + $input = new StringInput('--foo=bar'); + $input->bind($definition); + $this->assertEquals('bar', $input->getOption('foo')); - $this->assertEquals('bar', $actual); + // definition in constructor + $input = new StringInput('--foo=bar', $definition); + $this->assertEquals('bar', $input->getOption('foo')); } public function getTokenizeData()