bug #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
-------

0ab87f44e6 [DI] align IniFileLoader to PHP bugfix #76965
This commit is contained in:
Nicolas Grekas 2018-11-10 16:14:41 +01:00
commit b6dac0f93a
3 changed files with 7 additions and 4 deletions

View File

@ -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) {

View File

@ -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

View File

@ -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),