Skip to content

Commit 543782e

Browse files
committed
fix(option): default values for variadic options
1 parent 73adadc commit 543782e

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/Input/Parameter.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,10 @@ public function variadic(): bool
139139
*/
140140
public function default()
141141
{
142+
if ($this->variadic()) {
143+
return (array) $this->default;
144+
}
145+
142146
return $this->default;
143147
}
144148

src/Input/Parser.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ protected function setValue(Parameter $parameter, string $value = null): bool
169169
$name = $parameter->attributeName();
170170
$value = $this->_normalizer->normalizeValue($parameter, $value);
171171

172-
return $this->set($name, $value);
172+
return $this->set($name, $value, $parameter->variadic());
173173
}
174174

175175
/**
@@ -186,7 +186,7 @@ protected function set($key, $value, bool $variadic = false): bool
186186
if (null === $key) {
187187
$this->_values[] = $value;
188188
} elseif ($variadic) {
189-
$this->_values[$key][] = $value;
189+
$this->_values[$key] = \array_merge($this->_values[$key], $value);
190190
} else {
191191
$this->_values[$key] = $value;
192192
}

0 commit comments

Comments
 (0)