bug #24987 [Console] Fix global console flag when used in chain (Simperfit)

This PR was merged into the 2.7 branch.

Discussion
----------

[Console] Fix global console flag when used in chain

| Q             | A
| ------------- | ---
| Branch?       | 2.7
| Bug fix?      | yes
| New feature?  | no <!-- don't forget to update src/**/CHANGELOG.md files -->
| BC breaks?    | no
| Deprecations? | no <!-- don't forget to update UPGRADE-*.md files -->
| Tests pass?   | yes
| Fixed tickets | #23876
| License       | MIT
| Doc PR        |

Because SymfonyCon is great we can create pull request in it ! (this was preparer in the plane and I can push it just right now ;))

Finished in the #SymfonyConHackday2017

Commits
-------

1f8db73 [Console] Fix global console flag when used in chain
This commit is contained in:
Robin Chalas 2017-11-26 02:04:32 +01:00
commit 9107fb0afd
2 changed files with 11 additions and 0 deletions

View File

@ -282,6 +282,14 @@ class ArgvInput extends Input
if ($token === $value || 0 === strpos($token, $value.'=')) {
return true;
}
if (0 === strpos($token, '-') && 0 !== strpos($token, '--')) {
$searchableToken = str_replace('-', '', $token);
$searchableValue = str_replace('-', '', $value);
if ('' !== $searchableToken && '' !== $searchableValue && false !== strpos($searchableToken, $searchableValue)) {
return true;
}
}
}
}

View File

@ -296,6 +296,9 @@ class ArgvInputTest extends TestCase
$input = new ArgvInput(array('cli.php', '-f', 'foo'));
$this->assertTrue($input->hasParameterOption('-f'), '->hasParameterOption() returns true if the given short option is in the raw input');
$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', '--foo', 'foo'));
$this->assertTrue($input->hasParameterOption('--foo'), '->hasParameterOption() returns true if the given short option is in the raw input');