Skip to content

Commit

Permalink
[Console] Fix a bug when passing a letter that could be an alias
Browse files Browse the repository at this point in the history
  • Loading branch information
Amrouche Hamza committed Dec 13, 2017
1 parent e77545a commit a8871de
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Symfony/Component/Console/Input/ArgvInput.php
Expand Up @@ -284,6 +284,8 @@ public function hasParameterOption($values)
}

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)) {
Expand Down
3 changes: 3 additions & 0 deletions src/Symfony/Component/Console/Tests/Input/ArgvInputTest.php
Expand Up @@ -299,6 +299,9 @@ public function testHasParameterOption()
$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');

Expand Down

0 comments on commit a8871de

Please sign in to comment.