Description
Symfony version(s) affected: 5.1.8 (and earlier)
Description
Whenever a Symfony Console command is called with too many arguments, a "Too many arguments" error is shown on the CLI. This message also states which arguments are expected. But this message always contains "command"
as an extra argument. This can be confusing for the user, as the reported number of arguments is one off with what it should be.
How to reproduce
Install the Symfony skeleton and run the following command:
bin/console secrets:list foo
It shows the following message:
Too many arguments, expected arguments "command".
This is incorrect, as the command itself expects no arguments at all.
Similarly, the command
bin/console secrets:set foo bar baz
shows the message:
Too many arguments, expected arguments "command" "name" "file".
Here I would have expected a message stating that that "name"
and "file"
are the expected arguments, but not "command"
.
Possible Solution
The message is thrown on line 139 of src/Symfony/Component/Console/Input/ArgvInput.php.
Here it can be seen that keys of the $this->definition->getArguments()
array are printed.
The simplest solution to fix this seems to remove the first key of the array when creating the exception message.