11
0
Fork 0
mirror of https://github.com/n3w/helpers-cli-input.git synced 2025-12-19 12:43:23 +00:00

Fixed logic bug that prevented $index and $type from getting set when InputCollection::append() is called.

This commit is contained in:
Alannah Kearney 2019-05-27 00:22:01 +10:00
commit 866a2e1c9e

View file

@ -17,15 +17,12 @@ class InputCollection
{ {
$class = new \ReflectionClass($input); $class = new \ReflectionClass($input);
$index = null; if (null !== $this->find($input->name(), null, null, $type, $index) && !$replace) {
$type = null;
if (!$replace && null !== $this->find($input->name(), null, null, $index, $type)) {
throw new \Exception("{$class->getShortName()} '{$input->name()}' already exists in this collection"); throw new \Exception("{$class->getShortName()} '{$input->name()}' already exists in this collection");
} }
if (true == $replace && null !== $index) { if (true == $replace && null !== $index) {
$this->items[$class->getShortName()][$index] = $argument; $this->items[$class->getShortName()][$index] = $input;
} else { } else {
$this->items[$class->getShortName()][] = $input; $this->items[$class->getShortName()][] = $input;
} }