From 4152e36b0f305c2a57aa0233dee56ec27bca4f06 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Wed, 26 Aug 2020 08:25:12 +0200 Subject: [PATCH] fix more numeric cases changing in PHP 8 --- Inline.php | 2 +- Tests/InlineTest.php | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Inline.php b/Inline.php index 11efebca..a0c804d1 100644 --- a/Inline.php +++ b/Inline.php @@ -210,7 +210,7 @@ public static function dump($value, $flags = 0) return 'false'; case ctype_digit($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); if (false !== $locale) { setlocale(LC_NUMERIC, 'C'); diff --git a/Tests/InlineTest.php b/Tests/InlineTest.php index 362421ff..69b8033a 100644 --- a/Tests/InlineTest.php +++ b/Tests/InlineTest.php @@ -570,6 +570,14 @@ public function getTestsForDump() ['[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]]]], + + // 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"], ]; }