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 0454484

Browse filesBrowse files
committed
feature #42668 [Yaml] Use more concise float representation in dump (dev97)
This PR was merged into the 5.4 branch. Discussion ---------- [Yaml] Use more concise float representation in dump | Q | A | ------------- | --- | Branch? | 5.4 | Bug fix? | no | New feature? | yes | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | License | MIT <!-- Replace this notice by a short README for your feature/bugfix. This will help people understand your PR and can be used as a start for the documentation. Additionally (see https://symfony.com/releases): - Always add tests and ensure they pass. - Never break backward compatibility (see https://symfony.com/bc). - Bug fixes must be submitted against the lowest maintained branch where they apply (lowest branches are regularly merged to upper ones so they get the fixes too.) - Features and deprecations must be submitted against branch 5.x. - Changelog entry should follow https://symfony.com/doc/current/contributing/code/conventions.html#writing-a-changelog-entry --> Commits ------- c2248dc [Yaml] Use more concise float representation in dump
2 parents b641fdd + c2248dc commit 0454484
Copy full SHA for 0454484

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.