Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit c2248dc

Browse filesBrowse files
committed
[Yaml] Use more concise float representation in dump
1 parent bf8ecc4 commit c2248dc
Copy full SHA for c2248dc

File tree

2 files changed

+6
-2
lines changed
Filter options

2 files changed

+6
-2
lines changed

‎src/Symfony/Component/Yaml/Inline.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Yaml/Inline.php
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,9 @@ public static function dump($value, int $flags = 0): string
174174
$repr = str_ireplace('INF', '.Inf', $repr);
175175
} elseif (floor($value) == $value && $repr == $value) {
176176
// Preserve float data type since storing a whole number will result in integer value.
177-
$repr = '!!float '.$repr;
177+
if (false === strpos($repr, 'E')) {
178+
$repr = $repr.'.';
179+
}
178180
}
179181
} else {
180182
$repr = \is_string($value) ? "'$value'" : (string) $value;

‎src/Symfony/Component/Yaml/Tests/InlineTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Yaml/Tests/InlineTest.php
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,7 @@ public function getTestsForParse()
298298
['12_', 12],
299299
['"quoted string"', 'quoted string'],
300300
["'quoted string'", 'quoted string'],
301+
['1234.', 1234.],
301302
['12.30e+02', 12.30e+02],
302303
['123.45_67', 123.4567],
303304
['0x4D2', 0x4D2],
@@ -461,7 +462,8 @@ public function getTestsForDump()
461462
['_12', '_12'],
462463
["'12_'", '12_'],
463464
["'quoted string'", 'quoted string'],
464-
['!!float 1230', 12.30e+02],
465+
['1230.', 12.30e+02],
466+
['1.23E+45', 12.30e+44],
465467
['1234', 0x4D2],
466468
['1243', 02333],
467469
["'0x_4_D_2_'", '0x_4_D_2_'],

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.