minor #19446 [Console] Overcomplete argument exception message tweak. (SpacePossum)
This PR was squashed before being merged into the 2.7 branch (closes #19446).
Discussion
----------
[Console] Overcomplete argument exception message tweak.
| Q | A
| ------------- | ---
| Branch? | 2.7
| Bug fix? | no
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| License | MIT
Updates the exception message when to many arguments are passed.
From;
```php
'Too many arguments.'
```
To:
```php
'No argument expected, got "foo".'
// or
'Too many arguments, expected arguments "foo".'
// or
'Too many arguments, expected arguments "foo, bar".'
// ... turtles all the way down
```
Commits
-------
7af59cd
[Console] Overcomplete argument exception message tweak.
This commit is contained in:
commit
bdfc2aa652
@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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'),
|
||||
|
Reference in New Issue
Block a user