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

Skip to content

Commit 6681df0

Browse files
committed
[Console] fixed StringInput binding
1 parent 6b98883 commit 6681df0

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/Symfony/Component/Console/Input/StringInput.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,13 @@ class StringInput extends ArgvInput
3737
*/
3838
public function __construct($input, InputDefinition $definition = null)
3939
{
40-
parent::__construct(array(), $definition);
40+
parent::__construct(array(), null);
4141

4242
$this->setTokens($this->tokenize($input));
43+
44+
if (null !== $definition) {
45+
$this->bind($definition);
46+
}
4347
}
4448

4549
/**

src/Symfony/Component/Console/Tests/Input/StringInputTest.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,14 @@ public function testInputOptionWithGivenString()
3535
array(new InputOption('foo', null, InputOption::VALUE_REQUIRED))
3636
);
3737

38+
// call to bind
3839
$input = new StringInput('--foo=bar');
3940
$input->bind($definition);
40-
$actual = $input->getOption('foo');
41+
$this->assertEquals('bar', $input->getOption('foo'));
4142

42-
$this->assertEquals('bar', $actual);
43+
// definition in constructor
44+
$input = new StringInput('--foo=bar', $definition);
45+
$this->assertEquals('bar', $input->getOption('foo'));
4346
}
4447

4548
public function getTokenizeData()

0 commit comments

Comments
 (0)