minor #17707 Remove InputOption::VALUE_REQUIRED mode from $default parameter description (tomasliubinas)

This PR was submitted for the master branch but it was merged into the 2.3 branch instead (closes #17707).

Discussion
----------

Remove InputOption::VALUE_REQUIRED mode from $default parameter description

Reopening previous PR, providing more information

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

Remove InputOption::VALUE_REQUIRED mode from $default parameter description as InputOption::setDefault() throws an exception only when called with InputOption::VALUE_NONE mode.
In practice the $default not null value could be still used in VALUE_REQUIRED mode in case InputOption was never set but accessed from InputDefinition::getOption() method.

There is an important difference between 2 concepts. Not required Option AND not required option Value. When the not required Option is not provided the default value still could be taken from required option Value instance.

Relevant (correct) test case:
https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Console/Tests/Input/InputOptionTest.php#L136

Commits
-------

3c06151 Remove InputOption::VALUE_REQUIRED mode from $default parameter description as InputOption::setDefault() throws an exception only when called in InputOption::VALUE_NONE mode. In practice the $default value could still be accessed in InputOption::VALUE_REQUIRED mode in case InputOption was never set but accessed from InputDefinition::getOption() method
This commit is contained in:
Fabien Potencier 2016-02-15 20:17:39 +01:00
commit f6e401a973
2 changed files with 2 additions and 2 deletions

View File

@ -370,7 +370,7 @@ class Command
* @param string $shortcut The shortcut (can be null)
* @param int $mode The option mode: One of the InputOption::VALUE_* constants
* @param string $description A description text
* @param mixed $default The default value (must be null for InputOption::VALUE_REQUIRED or InputOption::VALUE_NONE)
* @param mixed $default The default value (must be null for InputOption::VALUE_NONE)
*
* @return Command The current instance
*/

View File

@ -36,7 +36,7 @@ class InputOption
* @param string|array $shortcut The shortcuts, can be null, a string of shortcuts delimited by | or an array of shortcuts
* @param int $mode The option mode: One of the VALUE_* constants
* @param string $description A description text
* @param mixed $default The default value (must be null for self::VALUE_REQUIRED or self::VALUE_NONE)
* @param mixed $default The default value (must be null for self::VALUE_NONE)
*
* @throws \InvalidArgumentException If option mode is invalid or incompatible
*/