Skip to content

Commit 26b4f1b

Browse files
fix arguments resolver
1 parent 2b181a6 commit 26b4f1b

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

src/CommandRunner.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,14 +140,14 @@ private function execute(CommandInterface $command, CommandParser $commandParser
140140

141141
$arguments = $command->getArguments();
142142
foreach ($arguments as $key => $argument) {
143-
$key = $argument->getName();
143+
$keyArg = $argument->getName();
144144
if ($argument->isRequired() && (!$commandParser->hasArgument($key) || empty($commandParser->getArgumentValue($key)))) {
145145
throw new InvalidArgumentException(sprintf('Argument "%s" is required for command "%s".', $argument->getName(), $command->getName()));
146146
}
147147
if ($commandParser->hasArgument($key)) {
148-
$argv["--{$key}"] = $commandParser->getArgumentValue($key);
148+
$argv["--{$keyArg}"] = $commandParser->getArgumentValue($key);
149149
}else {
150-
$argv["--{$key}"] = $argument->getDefaultValue();
150+
$argv["--{$keyArg}"] = $argument->getDefaultValue();
151151
}
152152
}
153153

tests/InputTest.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,7 @@ public function testGetOptionValue()
6464
$input = new Input('test', ['--option' => 'value'], []);
6565
$this->assertEquals('value', $input->getOptionValue('option'));
6666
$this->assertEquals('value', $input->getOptionValue('--option'));
67-
$this->expectException(\InvalidArgumentException::class, function () use ($input) {
68-
$input->getOptionValue('invalid');
69-
});
67+
$this->assertEquals(null, $input->getOptionValue('invalid'));
7068
}
7169

7270
public function testGetArgumentValue()

0 commit comments

Comments
 (0)