8000 [Console] replaced var_export with json_encode for default values whe… · defrag/symfony@7a18100 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7a18100

Browse files
committed
[Console] replaced var_export with json_encode for default values when exported as text/xml to make them more readable (closes symfony#4193)
1 parent 5487a1f commit 7a18100

File tree

3 files changed

+6
-10
lines changed

3 files changed

+6
-10
lines changed

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -526,10 +526,6 @@ public function asXml($asDom = false)
526526

527527
private function formatDefaultValue($default)
528528
{
529-
if (is_array($default) && $default === array_values($default)) {
530-
return sprintf("array('%s')", implode("', '", $default));
531-
}
532-
533-
return str_replace("\n", '', var_export($default, true));
529+
return json_encode($default);
534530
}
535531
}

src/Symfony/Component/Console/Tests/Fixtures/application_run2.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Usage:
33

44
Arguments:
55
command The command to execute
6-
command_name The command name (default: 'help')
6+
command_name The command name (default: "help")
77

88
Options:
99
--xml To output help as XML
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<comment>Arguments:</comment>
22
<info>foo </info> The foo argument
33
<info>baz </info> The baz argument<comment> (default: true)</comment>
4-
<info>bar </info> The bar argument<comment> (default: array('bar'))</comment>
4+
<info>bar </info> The bar argument<comment> (default: ["bar"])</comment>
55

66
<comment>Options:</comment>
77
<info>--foo</info> (-f) The foo option
88
<info>--baz</info> The baz option<comment> (default: false)</comment>
9-
<info>--bar</info> (-b) The bar option<comment> (default: 'bar')</comment>
10-
<info>--qux</info> The qux option<comment> (default: array('foo', 'bar'))</comment><comment> (multiple values allowed)</comment>
11-
<info>--qux2</info> The qux2 option<comment> (default: array ( 'foo' => 'bar',))</comment><comment> (multiple values allowed)</comment>
9+
<info>--bar</info> (-b) The bar option<comment> (default: "bar")</comment>
10+
<info>--qux</info> The qux option<comment> (default: ["foo","bar"])</comment><comment> (multiple values allowed)</comment>
11+
<info>--qux2</info> The qux2 option<comment> (default: {"foo":"bar"})</comment><comment> (multiple values allowed)</comment>

0 commit comments

Comments
 (0)
0