From 0ab87f44e6dbae6f0e9ebd6f14dc305b63037eee Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Sat, 10 Nov 2018 16:03:16 +0100 Subject: [PATCH] [DI] align IniFileLoader to PHP bugfix #76965 --- .../Component/DependencyInjection/Loader/IniFileLoader.php | 4 +++- .../DependencyInjection/Tests/Fixtures/ini/types.ini | 3 ++- .../DependencyInjection/Tests/Loader/IniFileLoaderTest.php | 4 ++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Symfony/Component/DependencyInjection/Loader/IniFileLoader.php b/src/Symfony/Component/DependencyInjection/Loader/IniFileLoader.php index ed3709104a..2ee9ea8ffc 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/IniFileLoader.php +++ b/src/Symfony/Component/DependencyInjection/Loader/IniFileLoader.php @@ -70,7 +70,9 @@ class IniFileLoader extends FileLoader private function phpize($value) { // trim on the right as comments removal keep whitespaces - $value = rtrim($value); + if ($value !== $v = rtrim($value)) { + $value = '""' === substr_replace($v, '', 1, -1) ? substr($v, 1, -1) : $v; + } $lowercaseValue = strtolower($value); switch (true) { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/ini/types.ini b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/ini/types.ini index 19cc5b3b31..75840907d2 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/ini/types.ini +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/ini/types.ini @@ -11,9 +11,10 @@ constant = PHP_VERSION 12 = 12 12_string = '12' + 12_quoted_number = "12" 12_comment = 12 ; comment 12_string_comment = '12' ; comment - 12_string_comment_again = "12" ; comment + 12_quoted_number_comment = "12" ; comment -12 = -12 0 = 0 1 = 1 diff --git a/src/Symfony/Component/DependencyInjection/Tests/Loader/IniFileLoaderTest.php b/src/Symfony/Component/DependencyInjection/Tests/Loader/IniFileLoaderTest.php index 65b5db93c5..c2332f8222 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Loader/IniFileLoaderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Loader/IniFileLoaderTest.php @@ -58,7 +58,6 @@ class IniFileLoaderTest extends TestCase $this->markTestSkipped(sprintf('Converting the value "%s" to "%s" is not supported by the IniFileLoader.', $key, $value)); } - $this->loader->load('types.ini'); $expected = parse_ini_file(__DIR__.'/../Fixtures/ini/types.ini', true, INI_SCANNER_TYPED); $this->assertSame($value, $expected['parameters'][$key], '->load() converts values to PHP types'); } @@ -78,9 +77,10 @@ class IniFileLoaderTest extends TestCase array('constant', PHP_VERSION, true), array('12', 12, true), array('12_string', '12', true), + array('12_quoted_number', 12, false), // INI_SCANNER_RAW removes the double quotes array('12_comment', 12, true), array('12_string_comment', '12', true), - array('12_string_comment_again', '12', true), + array('12_quoted_number_comment', 12, false), // INI_SCANNER_RAW removes the double quotes array('-12', -12, true), array('1', 1, true), array('0', 0, true),