[Console] Overcomplete argument exception message tweak.

This commit is contained in:
SpacePossum 2016-07-27 12:20:49 +02:00 committed by Fabien Potencier
parent 35c70be59f
commit 7af59cdf86
2 changed files with 17 additions and 2 deletions

View File

@ -174,7 +174,12 @@ class ArgvInput extends Input
// unexpected argument
} else {
throw new \RuntimeException('Too many arguments.');
$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));
}
}

View File

@ -183,7 +183,17 @@ class ArgvInputTest extends \PHPUnit_Framework_TestCase
array(
array('cli.php', 'foo', 'bar'),
new InputDefinition(),
'Too many arguments.',
'No arguments expected, got "foo".',
),
array(
array('cli.php', 'foo', 'bar'),
new InputDefinition(array(new InputArgument('number'))),
'Too many arguments, expected arguments "number".',
),
array(
array('cli.php', 'foo', 'bar', 'zzz'),
new InputDefinition(array(new InputArgument('number'), new InputArgument('county'))),
'Too many arguments, expected arguments "number" "county".',
),
array(
array('cli.php', '--foo'),