fix dumping number-like string parameters
This commit is contained in:
parent
3bd5faeaf6
commit
a1ce0ed086
@ -304,6 +304,11 @@ class XmlDumper extends Dumper
|
||||
if (\in_array($value, ['null', 'true', 'false'], true)) {
|
||||
$element->setAttribute('type', 'string');
|
||||
}
|
||||
|
||||
if (\is_string($value) && (is_numeric($value) || preg_match('/^0b[01]*$/', $value) || preg_match('/^0x[0-9a-f]++$/i', $value))) {
|
||||
$element->setAttribute('type', 'string');
|
||||
}
|
||||
|
||||
$text = $this->document->createTextNode(self::phpToXml($value));
|
||||
$element->appendChild($text);
|
||||
}
|
||||
|
@ -9,6 +9,17 @@ $container = new ContainerBuilder(new ParameterBag([
|
||||
'bar' => 'foo is %%foo bar',
|
||||
'escape' => '@escapeme',
|
||||
'values' => [true, false, null, 0, 1000.3, 'true', 'false', 'null'],
|
||||
'null string' => 'null',
|
||||
'string of digits' => '123',
|
||||
'string of digits prefixed with minus character' => '-123',
|
||||
'true string' => 'true',
|
||||
'false string' => 'false',
|
||||
'binary number string' => '0b0110',
|
||||
'numeric string' => '-1.2E2',
|
||||
'hexadecimal number string' => '0xFF',
|
||||
'float string' => '10100.1',
|
||||
'positive float string' => '+10100.1',
|
||||
'negative float string' => '-10100.1',
|
||||
]));
|
||||
|
||||
return $container;
|
||||
|
@ -151,6 +151,17 @@ class ProjectServiceContainer extends Container
|
||||
6 => 'false',
|
||||
7 => 'null',
|
||||
],
|
||||
'null string' => 'null',
|
||||
'string of digits' => '123',
|
||||
'string of digits prefixed with minus character' => '-123',
|
||||
'true string' => 'true',
|
||||
'false string' => 'false',
|
||||
'binary number string' => '0b0110',
|
||||
'numeric string' => '-1.2E2',
|
||||
'hexadecimal number string' => '0xFF',
|
||||
'float string' => '10100.1',
|
||||
'positive float string' => '+10100.1',
|
||||
'negative float string' => '-10100.1',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,17 @@
|
||||
<parameter type="string">false</parameter>
|
||||
<parameter type="string">null</parameter>
|
||||
</parameter>
|
||||
<parameter key="null string" type="string">null</parameter>
|
||||
<parameter key="string of digits" type="string">123</parameter>
|
||||
<parameter key="string of digits prefixed with minus character" type="string">-123</parameter>
|
||||
<parameter key="true string" type="string">true</parameter>
|
||||
<parameter key="false string" type="string">false</parameter>
|
||||
<parameter key="binary number string" type="string">0b0110</parameter>
|
||||
<parameter key="numeric string" type="string">-1.2E2</parameter>
|
||||
<parameter key="hexadecimal number string" type="string">0xFF</parameter>
|
||||
<parameter key="float string" type="string">10100.1</parameter>
|
||||
<parameter key="positive float string" type="string">+10100.1</parameter>
|
||||
<parameter key="negative float string" type="string">-10100.1</parameter>
|
||||
</parameters>
|
||||
<services>
|
||||
<service id="service_container" class="Symfony\Component\DependencyInjection\ContainerInterface" public="true" synthetic="true"/>
|
||||
|
@ -4,6 +4,17 @@ parameters:
|
||||
bar: 'foo is %%foo bar'
|
||||
escape: '@@escapeme'
|
||||
values: [true, false, null, 0, 1000.3, 'true', 'false', 'null']
|
||||
null string: 'null'
|
||||
string of digits: '123'
|
||||
string of digits prefixed with minus character: '-123'
|
||||
true string: 'true'
|
||||
false string: 'false'
|
||||
binary number string: '0b0110'
|
||||
numeric string: '-1.2E2'
|
||||
hexadecimal number string: '0xFF'
|
||||
float string: '10100.1'
|
||||
positive float string: '+10100.1'
|
||||
negative float string: '-10100.1'
|
||||
|
||||
services:
|
||||
service_container:
|
||||
|
Reference in New Issue
Block a user