[Console] Fixed argument parsing when a single dash is passed.
This commit is contained in:
parent
b591419631
commit
42019f6774
@ -84,7 +84,7 @@ class ArgvInput extends Input
|
|||||||
$parseOptions = false;
|
$parseOptions = false;
|
||||||
} elseif ($parseOptions && 0 === strpos($token, '--')) {
|
} elseif ($parseOptions && 0 === strpos($token, '--')) {
|
||||||
$this->parseLongOption($token);
|
$this->parseLongOption($token);
|
||||||
} elseif ($parseOptions && '-' === $token[0]) {
|
} elseif ($parseOptions && '-' === $token[0] && '-' !== $token) {
|
||||||
$this->parseShortOption($token);
|
$this->parseShortOption($token);
|
||||||
} else {
|
} else {
|
||||||
$this->parseArgument($token);
|
$this->parseArgument($token);
|
||||||
|
@ -254,4 +254,11 @@ class ArgvInputTest extends \PHPUnit_Framework_TestCase
|
|||||||
array(array('app/console', 'foo:bar', '--env=dev', '--en=1'), array('--en'), '1'),
|
array(array('app/console', 'foo:bar', '--env=dev', '--en=1'), array('--en'), '1'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testParseSingleDashAsArgument()
|
||||||
|
{
|
||||||
|
$input = new ArgvInput(array('cli.php', '-'));
|
||||||
|
$input->bind(new InputDefinition(array(new InputArgument('file'))));
|
||||||
|
$this->assertEquals(array('file' => '-'), $input->getArguments(), '->parse() parses single dash as an argument');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user