more refactoring; now the package hook starts to make sense
[pharext/pharext] / src / pharext / Cli / Args.php
index f0b0498daf521a91dc83e36cb3fa7f20122b3705..38cfaca80e862546f06f989e13d7c9844c6f46cb 100644 (file)
@@ -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;
        }