8000 [Console] Fix global console flag when used in chain · symfony/symfony@6938a0a · GitHub
[go: up one dir, main page]

Skip to content

Commit 6938a0a

Browse files
author
Amrouche Hamza
committed
[Console] Fix global console flag when used in chain
1 parent 73ef74a commit 6938a0a

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/Symfony/Component/Console/Input/ArgvInput.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,12 +175,12 @@ private function parseArgument($token)
175175
$arg = $this->definition->getArgument($c);
176176
$this->arguments[$arg->getName()] = $arg->isArray() ? array($token) : $token;
177177

178-
// if last argument isArray(), append token to last argument
178+
// if last argument isArray(), append token to last argument
179179
} elseif ($this->definition->hasArgument($c - 1) && $this->definition->getArgument($c - 1)->isArray()) {
180180
$arg = $this->definition->getArgument($c - 1);
181181
$this->arguments[$arg->getName()][] = $token;
182182

183-
// unexpected argument
183+
// unexpected argument
184184
} else {
185185
$all = $this->definition->getArguments();
186186
if (count($all)) {
@@ -285,6 +285,14 @@ public function hasParameterOption($values, $onlyParams = false)
285285
if ($token === $value || 0 === strpos($token, $value.'=')) {
286286
return true;
287287
}
288+
289+
if (0 === strpos($token, '-') && 0 !== strpos($token, '--')) {
290+
$searchableToken = str_replace('-', '', $token);
291+
$searchableValue = str_replace('-', '', $value);
292+
if ('' !== $searchableToken && '' !== $searchableValue && false !== strpos($searchableToken, $searchableValue)) {
293+
return true;
294+
}
295+
}
288296
}
289297
}
290298

src/Symfony/Component/Console/Tests/Input/ArgvInputTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,9 @@ public function testHasParameterOption()
314314
$input = new ArgvInput(array('cli.php', '-f', 'foo'));
315315
$this->assertTrue($input->hasParameterOption('-f'), '->hasParameterOption() returns true if the given short option is in the raw input');
316316

317+
$input = new ArgvInput(array('cli.php', '-fh'));
318+
$this->assertTrue($input->hasParameterOption('-fh'), '->hasParameterOption() returns true if the given short option is in the raw input');
319+
317320
$input = new ArgvInput(array('cli.php', '--foo', 'foo'));
318321
$this->assertTrue($input->hasParameterOption('--foo'), '->hasParameterOption() returns true if the given short option is in the raw input');
319322

0 commit comments

Comments
 (0)
0