X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=src%2Fpharext%2FCli%2FArgs.php;h=38cfaca80e862546f06f989e13d7c9844c6f46cb;hb=e990b6dabecbdaf98b8d8b2173b0d697f9b2b754;hp=f0b0498daf521a91dc83e36cb3fa7f20122b3705;hpb=4acccbbedeb300e70cc06d9253e95bafeb7a2859;p=pharext%2Fpharext diff --git a/src/pharext/Cli/Args.php b/src/pharext/Cli/Args.php index f0b0498..38cfaca 100644 --- a/src/pharext/Cli/Args.php +++ b/src/pharext/Cli/Args.php @@ -67,24 +67,27 @@ class Args implements \ArrayAccess /** * Compile the original spec - * @param array $spec + * @param array|Traversable $spec */ - public function __construct(array $spec = null) { - $this->compile($spec); + public function __construct($spec = null) { + if (is_array($spec) || $spec instanceof Traversable) { + $this->compile($spec); + } + } /** * Compile the original spec - * @param array $spec + * @param array|Traversable $spec * @return pharext\CliArgs self */ - public function compile(array $spec = null) { - $this->orig = array_merge($this->orig, (array) $spec); - foreach ((array) $spec as $arg) { + public function compile($spec) { + foreach ($spec as $arg) { if (isset($arg[0])) { $this->spec["-".$arg[0]] = $arg; } $this->spec["--".$arg[1]] = $arg; + $this->orig[] = $arg; } return $this; }