X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Fpsy%2Fpsysh%2Fsrc%2FPsy%2FInput%2FShellInput.php;fp=vendor%2Fpsy%2Fpsysh%2Fsrc%2FPsy%2FInput%2FShellInput.php;h=68a4252a2205dbef059293b19aee59ae0e5fe0be;hp=e25db4618f387daebd10be98bc796af6bbc58f18;hb=9917807b03b64faf00f6a1f29dcb6eafc454efa5;hpb=aea91e65e895364e460983b890e295aa5d5540a5 diff --git a/vendor/psy/psysh/src/Psy/Input/ShellInput.php b/vendor/psy/psysh/src/Psy/Input/ShellInput.php index e25db4618..68a4252a2 100644 --- a/vendor/psy/psysh/src/Psy/Input/ShellInput.php +++ b/vendor/psy/psysh/src/Psy/Input/ShellInput.php @@ -50,7 +50,7 @@ class ShellInput extends StringInput $hasCodeArgument = false; if ($definition->getArgumentCount() > 0) { - $args = $definition->getArguments(); + $args = $definition->getArguments(); $lastArg = array_pop($args); foreach ($args as $arg) { if ($arg instanceof CodeArgument) { @@ -165,20 +165,24 @@ class ShellInput extends StringInput $this->arguments[$arg->getName()] = $arg->isArray() ? array($token) : $token; } + return; + } + // if last argument isArray(), append token to last argument - } elseif ($this->definition->hasArgument($c - 1) && $this->definition->getArgument($c - 1)->isArray()) { + if ($this->definition->hasArgument($c - 1) && $this->definition->getArgument($c - 1)->isArray()) { $arg = $this->definition->getArgument($c - 1); $this->arguments[$arg->getName()][] = $token; - // unexpected argument - } else { - $all = $this->definition->getArguments(); - if (count($all)) { - throw new \RuntimeException(sprintf('Too many arguments, expected arguments "%s".', implode('" "', array_keys($all)))); - } + return; + } - throw new \RuntimeException(sprintf('No arguments expected, got "%s".', $token)); + // unexpected argument + $all = $this->definition->getArguments(); + if (count($all)) { + throw new \RuntimeException(sprintf('Too many arguments, expected arguments "%s".', implode('" "', array_keys($all)))); } + + throw new \RuntimeException(sprintf('No arguments expected, got "%s".', $token)); } // Everything below this is copypasta from ArgvInput private methods @@ -214,7 +218,7 @@ class ShellInput extends StringInput private function parseShortOptionSet($name) { $len = strlen($name); - for ($i = 0; $i < $len; ++$i) { + for ($i = 0; $i < $len; $i++) { if (!$this->definition->hasShortcut($name[$i])) { throw new \RuntimeException(sprintf('The "-%s" option does not exist.', $name[$i])); }