8000 minor #17707 Remove InputOption::VALUE_REQUIRED mode from $default pa… · symfony/symfony@f6e401a · GitHub
[go: up one dir, main page]

Skip to content

Commit f6e401a

Browse files
committed
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
2 parents d4ac467 + 3c06151 commit f6e401a

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/Symfony/Component/Console/Command/Command.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ public function addArgument($name, $mode = null, $description = '', $default = n
370370
* @param string $shortcut The shortcut (can be null)
371371
* @param int $mode The option mode: One of the InputOption::VALUE_* constants
372372
* @param string $description A description text
373-
* @param mixed $default The default value (must be null for InputOption::VALUE_REQUIRED or InputOption::VALUE_NONE)
373+
* @param mixed $default The default value (must be null for InputOption::VALUE_NONE)
374374
*
375375
* @return Command The current instance
376376
*/

src/Symfony/Component/Console/Input/InputOption.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class InputOption
3636
* @param string|array $shortcut The shortcuts, can be null, a string of shortcuts delimited by | or an array of shortcuts
3737
* @param int $mode The option mode: One of the VALUE_* constants
3838
* @param string $description A description text
39-
* @param mixed $default The default value (must be null for self::VALUE_REQUIRED or self::VALUE_NONE)
39+
* @param mixed $default The default value (must be null for self::VALUE_NONE)
4040
*
4141
* @throws \InvalidArgumentException If option mode is invalid or incompatible
4242
*/

0 commit comments

Comments
 (0)
0