-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[console | in-code documentation] Parameters not documented. #16648
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Well, |
The IDE intellisense only show how parameter While I searching for documentation about how add option's name, I found https://symfony.com/doc/current/console/input.html#using-command-options where I could saw all the parameters. This fuzzed me... Then I go to the code and I see the problem, that parameters are not documented in annotation, and I created this issue. I'm sorry if I hurt feelings to any person with this, it was not my intention. |
@PSF1 no worries! Your proposal, as any other proposal, is very well received and we thank you for that. I think the problem here is that: (1) @xabbuh is right that from the point of view of code, these two arguments are obvious and that's why they don't need any explanation I think we should mention the arguments of input options and arguments the first time we mention them. E.g. instead of this: // ...
use Symfony\Component\Console\Input\InputOption;
$this
// ...
->addOption(
'iterations',
null,
InputOption::VALUE_REQUIRED,
'How many times should the message be printed?',
1
)
; Use something like: // ...
use Symfony\Component\Console\Input\InputOption;
$this
// ...
->addOption(
// this is the name that users must type to pass this option
'iterations',
// this is the shortcut, which is another way to pass this option and
// it's useful for common options or options with long names
null,
// this is the type of option (e.g. requires a value, can be passed more than once, etc.)
InputOption::VALUE_REQUIRED,
// the option description displayed in the command help
'How many times should the message be printed?',
// the default value of the option (for those which allow to pass values)
1
)
; What do you think? |
Thanks @javiereguiluz , I'm sorry for not replying before. I meant about the code: /**
* Adds an option.
*
* @param string|array|null $shortcut The shortcuts, can be null, a string of shortcuts delimited by | or an array of shortcuts
* @param int|null $mode The option mode: One of the InputOption::VALUE_* constants
* @param mixed $default The default value (must be null for InputOption::VALUE_NONE)
*
* @throws InvalidArgumentException If option mode is invalid or incompatible
*
* @return $this
*/
public function addOption(string $name, $shortcut = null, int $mode = null, string $description = '', $default = null)
{
$this->definition->addOption(new InputOption($name, $shortcut, $mode, $description, $default));
if (null !== $this->fullDefinition) {
$this->fullDefinition->addOption(new InputOption($name, $shortcut, $mode, $description, $default));
}
return $this;
} The code comment describes 3 parameters but the function has 5 parameters. That confuses some IDEs. |
Please report this to Intellisense instead. Not having a PHPdoc for all parameters is valid for most tools and with the introduction of strict typing in PHP, PHPdocs are less and less useful. |
Hi,
The parameters $name and $description, in Command::addOption, are not documented in code.
Please see: Source code
Thx :)
The text was updated successfully, but these errors were encountered: