8000 merged branch jakzal/console-single-dash-argument (PR #9014) · symfony/symfony@7d7b583 · GitHub
[go: up one dir, main page]

8000
Skip to content

Commit 7d7b583

Browse files
committed
merged branch jakzal/console-single-dash-argument (PR #9014)
This PR was merged into the 2.2 branch. Discussion ---------- [Console] Fixed argument parsing when a single dash is passed. | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #8986 | License | MIT | Doc PR | Commits ------- 42019f6 [Console] Fixed argument parsing when a single dash is passed.
2 parents 2742310 + 42019f6 commit 7d7b583

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ protected function parse()
8484
$parseOptions = false;
8585
} elseif ($parseOptions && 0 === strpos($token, '--')) {
8686
$this->parseLongOption($token);
87-
} elseif ($parseOptions && '-' === $token[0]) {
87+
} elseif ($parseOptions && '-' === $token[0] && '-' !== $token) {
8888
$this->parseShortOption($token);
8989
} else {
9090
$this->parseArgument($token);

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,4 +254,11 @@ public function provideGetParameterOptionValues()
254254
array(array('app/console', 'foo:bar', '--env=dev', '--en=1'), array('--en'), '1'),
255255
);
256256
}
257+
258+
public function testParseSingleDashAsArgument()
259+
{
260+
$input = new ArgvInput(array('cli.php', '-'));
261+
$input->bind(new InputDefinition(array(new InputArgument('file'))));
262+
$this->assertEquals(array('file' => '-'), $input->getArguments(), '->parse() parses single dash as an argument');
263+
}
257264
}

0 commit comments

Comments
 (0)
0