Skip to content

Commit 9279614

Browse files
Merge branch '3.4' into 4.1
* 3.4: [DI] align IniFileLoader to PHP bugfix #76965
2 parents e0bd358 + dbefbc2 commit 9279614

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

Loader/IniFileLoader.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,9 @@ public function supports($resource, $type = null)
7070
private function phpize($value)
7171
{
7272
// trim on the right as comments removal keep whitespaces
73-
$value = rtrim($value);
73+
if ($value !== $v = rtrim($value)) {
74+
$value = '""' === substr_replace($v, '', 1, -1) ? substr($v, 1, -1) : $v;
75+
}
7476
$lowercaseValue = strtolower($value);
7577

7678
switch (true) {

Tests/Fixtures/ini/types.ini

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@
1111
constant = PHP_VERSION
1212
12 = 12
1313
12_string = '12'
14+
12_quoted_number = "12"
1415
12_comment = 12 ; comment
1516
12_string_comment = '12' ; comment
16-
12_string_comment_again = "12" ; comment
17+
12_quoted_number_comment = "12" ; comment
1718
-12 = -12
1819
0 = 0
1920
1 = 1

Tests/Loader/IniFileLoaderTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ public function testTypeConversionsWithNativePhp($key, $value, $supported)
5353
$this->markTestSkipped(sprintf('Converting the value "%s" to "%s" is not supported by the IniFileLoader.', $key, $value));
5454
}
5555

56-
$this->loader->load('types.ini');
5756
$expected = parse_ini_file(__DIR__.'/../Fixtures/ini/types.ini', true, INI_SCANNER_TYPED);
5857
$this->assertSame($value, $expected['parameters'][$key], '->load() converts values to PHP types');
5958
}
@@ -73,9 +72,10 @@ public function getTypeConversions()
7372
array('constant', PHP_VERSION, true),
7473
array('12', 12, true),
7574
array('12_string', '12', true),
75+
array('12_quoted_number', 12, false), // INI_SCANNER_RAW removes the double quotes
7676
array('12_comment', 12, true),
7777
array('12_string_comment', '12', true),
78-
array('12_string_comment_again', '12', true),
78+
array('12_quoted_number_comment', 12, false), // INI_SCANNER_RAW removes the double quotes
7979
array('-12', -12, true),
8080
array('1', 1, true),
8181
array('0', 0, true),

0 commit comments

Comments
 (0)