[Console] Fix a bug when passing a letter that could be an alias

This commit is contained in:
Amrouche Hamza 2017-12-13 19:55:05 +01:00
parent e77545ab8d
commit a8871de263
No known key found for this signature in database
GPG Key ID: 6968F2785ED4F012
2 changed files with 5 additions and 0 deletions

View File

@ -284,6 +284,8 @@ class ArgvInput extends Input
}
if (0 === strpos($token, '-') && 0 !== strpos($token, '--')) {
$noValue = explode('=', $token);
$token = $noValue[0];
$searchableToken = str_replace('-', '', $token);
$searchableValue = str_replace('-', '', $value);
if ('' !== $searchableToken && '' !== $searchableValue && false !== strpos($searchableToken, $searchableValue)) {

View File

@ -299,6 +299,9 @@ class ArgvInputTest extends TestCase
$input = new ArgvInput(array('cli.php', '-fh'));
$this->assertTrue($input->hasParameterOption('-fh'), '->hasParameterOption() returns true if the given short option is in the raw input');
$input = new ArgvInput(array('cli.php', '-e=test'));
$this->assertFalse($input->hasParameterOption('-s'), '->hasParameterOption() returns true if the given short option is in the raw input');
$input = new ArgvInput(array('cli.php', '--foo', 'foo'));
$this->assertTrue($input->hasParameterOption('--foo'), '->hasParameterOption() returns true if the given short option is in the raw input');