[Console] avoid warning parsing empty string argument
This commit is contained in:
parent
a7a696fc5a
commit
aac6ad8018
@ -78,7 +78,9 @@ class ArgvInput extends Input
|
||||
$parseOptions = true;
|
||||
$this->parsed = $this->tokens;
|
||||
while (null !== $token = array_shift($this->parsed)) {
|
||||
if ($parseOptions && '--' == $token) {
|
||||
if ($parseOptions && '' == $token) {
|
||||
$this->parseArgument($token);
|
||||
} elseif ($parseOptions && '--' == $token) {
|
||||
$parseOptions = false;
|
||||
} elseif ($parseOptions && 0 === strpos($token, '--')) {
|
||||
$this->parseLongOption($token);
|
||||
|
@ -169,6 +169,10 @@ class ArgvInputTest extends \PHPUnit_Framework_TestCase
|
||||
$input->bind(new InputDefinition(array(new InputArgument('number'), new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL))));
|
||||
$this->assertEquals(array('foo' => 'bar'), $input->getOptions(), '->parse() parses arguments with leading dashes as options before having encountered a double-dash sequence');
|
||||
$this->assertEquals(array('number' => '-1'), $input->getArguments(), '->parse() parses arguments with leading dashes as arguments after having encountered a double-dash sequence');
|
||||
|
||||
$input = new ArgvInput(array('cli.php', '-f', 'bar', ''));
|
||||
$input->bind(new InputDefinition(array(new InputArgument('empty'), new InputOption('foo', 'f', InputOption::VALUE_OPTIONAL))));
|
||||
$this->assertEquals(array('empty' => ''), $input->getArguments(), '->parse() parses empty string arguments');
|
||||
}
|
||||
|
||||
public function testGetFirstArgument()
|
||||
|
Reference in New Issue
Block a user