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 |968ffcfa65 (r41697638)
| License | MIT | Doc PR | see also https://wiki.php.net/rfc/saner-numeric-strings Commits -------7cd5106041
fix more numeric cases changing in PHP 8
This commit is contained in:
commit
b98f2afe5e
@ -210,7 +210,7 @@ class Inline
|
|||||||
return 'false';
|
return 'false';
|
||||||
case ctype_digit($value):
|
case ctype_digit($value):
|
||||||
return \is_string($value) ? "'$value'" : (int) $value;
|
return \is_string($value) ? "'$value'" : (int) $value;
|
||||||
case is_numeric($value) && false === strpos($value, "\n"):
|
case is_numeric($value) && false === strpos($value, "\f") && false === strpos($value, "\n") && false === strpos($value, "\r") && false === strpos($value, "\t") && false === strpos($value, "\v"):
|
||||||
$locale = setlocale(LC_NUMERIC, 0);
|
$locale = setlocale(LC_NUMERIC, 0);
|
||||||
if (false !== $locale) {
|
if (false !== $locale) {
|
||||||
setlocale(LC_NUMERIC, 'C');
|
setlocale(LC_NUMERIC, 'C');
|
||||||
|
@ -570,6 +570,14 @@ class InlineTest extends TestCase
|
|||||||
['[foo, \'@foo.baz\', { \'%foo%\': \'foo is %foo%\', bar: \'%foo%\' }, true, \'@service_container\']', ['foo', '@foo.baz', ['%foo%' => 'foo is %foo%', 'bar' => '%foo%'], true, '@service_container']],
|
['[foo, \'@foo.baz\', { \'%foo%\': \'foo is %foo%\', bar: \'%foo%\' }, true, \'@service_container\']', ['foo', '@foo.baz', ['%foo%' => 'foo is %foo%', 'bar' => '%foo%'], true, '@service_container']],
|
||||||
|
|
||||||
['{ foo: { bar: { 1: 2, baz: 3 } } }', ['foo' => ['bar' => [1 => 2, 'baz' => 3]]]],
|
['{ foo: { bar: { 1: 2, baz: 3 } } }', ['foo' => ['bar' => [1 => 2, 'baz' => 3]]]],
|
||||||
|
|
||||||
|
// numeric strings with trailing whitespaces
|
||||||
|
["'0123 '", '0123 '],
|
||||||
|
['"0123\f"', "0123\f"],
|
||||||
|
['"0123\n"', "0123\n"],
|
||||||
|
['"0123\r"', "0123\r"],
|
||||||
|
['"0123\t"', "0123\t"],
|
||||||
|
['"0123\v"', "0123\v"],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user