Skip to content

Commit b98f2af

Browse files
committed
bug #37949 [Yaml] fix more numeric cases changing in PHP 8 (xabbuh)
This PR was submitted for the master branch but it was merged into the 3.4 branch instead. Discussion ---------- [Yaml] fix more numeric cases changing in PHP 8 | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | symfony/yaml@968ffcf#r41697638 | License | MIT | Doc PR | see also https://wiki.php.net/rfc/saner-numeric-strings Commits ------- 7cd5106 fix more numeric cases changing in PHP 8
2 parents 4b3d5b6 + 7cd5106 commit b98f2af

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/Symfony/Component/Yaml/Inline.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ public static function dump($value, $flags = 0)
210210
return 'false';
211211
case ctype_digit($value):
212212
return \is_string($value) ? "'$value'" : (int) $value;
213-
case is_numeric($value) && false === strpos($value, "\n"):
213+
case is_numeric($value) && false === strpos($value, "\f") && false === strpos($value, "\n") && false === strpos($value, "\r") && false === strpos($value, "\t") && false === strpos($value, "\v"):
214214
$locale = setlocale(LC_NUMERIC, 0);
215215
if (false !== $locale) {
216216
setlocale(LC_NUMERIC, 'C');

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -570,6 +570,14 @@ public function getTestsForDump()
570570
['[foo, \'@foo.baz\', { \'%foo%\': \'foo is %foo%\', bar: \'%foo%\' }, true, \'@service_container\']', ['foo', '@foo.baz', ['%foo%' => 'foo is %foo%', 'bar' => '%foo%'], true, '@service_container']],
571571

572572
['{ foo: { bar: { 1: 2, baz: 3 } } }', ['foo' => ['bar' => [1 => 2, 'baz' => 3]]]],
573+
574+
// numeric strings with trailing whitespaces
575+
["'0123 '", '0123 '],
576+
['"0123\f"', "0123\f"],
577+
['"0123\n"', "0123\n"],
578+
['"0123\r"', "0123\r"],
579+
['"0123\t"', "0123\t"],
580+
['"0123\v"', "0123\v"],
573581
];
574582
}
575583

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy