$hasCodeArgument = false;
if ($definition->getArgumentCount() > 0) {
- $args = $definition->getArguments();
+ $args = $definition->getArguments();
$lastArg = array_pop($args);
foreach ($args as $arg) {
if ($arg instanceof CodeArgument) {
$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
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]));
}