bug #23345 [Console] fix description of INF default values (xabbuh)
This PR was merged into the 2.7 branch.
Discussion
----------
[Console] fix description of INF default values
| Q | A
| ------------- | ---
| Branch? | 2.7
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | #23267
| License | MIT
| Doc PR |
Commits
-------
d8ba440def
[Console] fix description of INF default values
This commit is contained in:
commit
cd8d4e68d4
@ -103,7 +103,7 @@ class JsonDescriptor extends Descriptor
|
||||
'is_required' => $argument->isRequired(),
|
||||
'is_array' => $argument->isArray(),
|
||||
'description' => preg_replace('/\s*[\r\n]\s*/', ' ', $argument->getDescription()),
|
||||
'default' => $argument->getDefault(),
|
||||
'default' => INF === $argument->getDefault() ? 'INF' : $argument->getDefault(),
|
||||
);
|
||||
}
|
||||
|
||||
@ -121,7 +121,7 @@ class JsonDescriptor extends Descriptor
|
||||
'is_value_required' => $option->isValueRequired(),
|
||||
'is_multiple' => $option->isArray(),
|
||||
'description' => preg_replace('/\s*[\r\n]\s*/', ' ', $option->getDescription()),
|
||||
'default' => $option->getDefault(),
|
||||
'default' => INF === $option->getDefault() ? 'INF' : $option->getDefault(),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -237,6 +237,10 @@ class TextDescriptor extends Descriptor
|
||||
*/
|
||||
private function formatDefaultValue($default)
|
||||
{
|
||||
if (INF === $default) {
|
||||
return 'INF';
|
||||
}
|
||||
|
||||
if (is_string($default)) {
|
||||
$default = OutputFormatter::escape($default);
|
||||
} elseif (is_array($default)) {
|
||||
|
@ -32,6 +32,7 @@ class ObjectsProvider
|
||||
'input_argument_3' => new InputArgument('argument_name', InputArgument::OPTIONAL, 'argument description', 'default_value'),
|
||||
'input_argument_4' => new InputArgument('argument_name', InputArgument::REQUIRED, "multiline\nargument description"),
|
||||
'input_argument_with_style' => new InputArgument('argument_name', InputArgument::OPTIONAL, 'argument description', '<comment>style</>'),
|
||||
'input_argument_with_default_inf_value' => new InputArgument('argument_name', InputArgument::OPTIONAL, 'argument description', INF),
|
||||
);
|
||||
}
|
||||
|
||||
@ -46,6 +47,7 @@ class ObjectsProvider
|
||||
'input_option_6' => new InputOption('option_name', array('o', 'O'), InputOption::VALUE_REQUIRED, 'option with multiple shortcuts'),
|
||||
'input_option_with_style' => new InputOption('option_name', 'o', InputOption::VALUE_REQUIRED, 'option description', '<comment>style</>'),
|
||||
'input_option_with_style_array' => new InputOption('option_name', 'o', InputOption::VALUE_IS_ARRAY | InputOption::VALUE_REQUIRED, 'option description', array('<comment>Hello</comment>', '<info>world</info>')),
|
||||
'input_option_with_default_inf_value' => new InputOption('option_name', 'o', InputOption::VALUE_OPTIONAL, 'option description', INF),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,7 @@
|
||||
{
|
||||
"name": "argument_name",
|
||||
"is_required": false,
|
||||
"is_array": false,
|
||||
"description": "argument description",
|
||||
"default": "INF"
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
**argument_name:**
|
||||
|
||||
* Name: argument_name
|
||||
* Is required: no
|
||||
* Is array: no
|
||||
* Description: argument description
|
||||
* Default: `INF`
|
@ -0,0 +1 @@
|
||||
<info>argument_name</info> argument description<comment> [default: INF]</comment>
|
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<argument name="argument_name" is_required="0" is_array="0">
|
||||
<description>argument description</description>
|
||||
<defaults>
|
||||
<default>INF</default>
|
||||
</defaults>
|
||||
</argument>
|
@ -0,0 +1,9 @@
|
||||
{
|
||||
"name": "--option_name",
|
||||
"shortcut": "-o",
|
||||
"accept_value": true,
|
||||
"is_value_required": false,
|
||||
"is_multiple": false,
|
||||
"description": "option description",
|
||||
"default": "INF"
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
**option_name:**
|
||||
|
||||
* Name: `--option_name`
|
||||
* Shortcut: `-o`
|
||||
* Accept value: yes
|
||||
* Is value required: no
|
||||
* Is multiple: no
|
||||
* Description: option description
|
||||
* Default: `INF`
|
@ -0,0 +1 @@
|
||||
<info>-o, --option_name[=OPTION_NAME]</info> option description<comment> [default: INF]</comment>
|
@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<option name="--option_name" shortcut="-o" accept_value="1" is_value_required="0" is_multiple="0">
|
||||
<description>option description</description>
|
||||
<defaults>
|
||||
<default>INF</default>
|
||||
</defaults>
|
||||
</option>
|
Reference in New Issue
Block a user