Skip to content

Commit b6dac0f

Browse files
bug symfony#29165 [DI] align IniFileLoader to PHP bugfix #76965 (nicolas-grekas)
This PR was merged into the 3.4 branch. Discussion ---------- [DI] align IniFileLoader to PHP bugfix #76965 | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | - | License | MIT | Doc PR | - Our CI is currently red because of the fix for https://bugs.php.net/76965 This fixes it by aligning the behavior to the fix in PHP core. Commits ------- 0ab87f4 [DI] align IniFileLoader to PHP bugfix #76965
2 parents 5916bbe + 0ab87f4 commit b6dac0f

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

src/Symfony/Component/DependencyInjection/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) {

src/Symfony/Component/DependencyInjection/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

src/Symfony/Component/DependencyInjection/Tests/Loader/IniFileLoaderTest.php

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

61-
$this->loader->load('types.ini');
6261
$expected = parse_ini_file(__DIR__.'/../Fixtures/ini/types.ini', true, INI_SCANNER_TYPED);
6362
$this->assertSame($value, $expected['parameters'][$key], '->load() converts values to PHP types');
6463
}
@@ -78,9 +77,10 @@ public function getTypeConversions()
7877
array('constant', PHP_VERSION, true),
7978
array('12', 12, true),
8079
array('12_string', '12', true),
80+
array('12_quoted_number', 12, false), // INI_SCANNER_RAW removes the double quotes
8181
array('12_comment', 12, true),
8282
array('12_string_comment', '12', true),
83-
array('12_string_comment_again', '12', true),
83+
array('12_quoted_number_comment', 12, false), // INI_SCANNER_RAW removes the double quotes
8484
array('-12', -12, true),
8585
array('1', 1, true),
8686
array('0', 0, true),

0 commit comments

Comments
 (0)