Skip to content

Commit 437b628

Browse files
MatTheCatfabpot
authored andcommitted
Handle INI arrays
1 parent 191f236 commit 437b628

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

Loader/IniFileLoader.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,11 @@ public function load(mixed $resource, string $type = null): mixed
3838

3939
if (isset($result['parameters']) && \is_array($result['parameters'])) {
4040
foreach ($result['parameters'] as $key => $value) {
41-
$this->container->setParameter($key, $this->phpize($value));
41+
if (\is_array($value)) {
42+
$this->container->setParameter($key, array_map([$this, 'phpize'], $value));
43+
} else {
44+
$this->container->setParameter($key, $this->phpize($value));
45+
}
4246
}
4347
}
4448

Tests/Fixtures/ini/types.ini

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,7 @@
2626
-120.0 = -1.2E2
2727
-10100.1 = -10100.1
2828
-10,100.1 = -10,100.1
29+
list[] = 1
30+
list[] = 2
31+
map[one] = 1
32+
map[two] = 2

Tests/Loader/IniFileLoaderTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ public function getTypeConversions()
8888
['-120.0', -1.2E2, false], // not supported by INI_SCANNER_TYPED
8989
['-10100.1', -10100.1, false], // not supported by INI_SCANNER_TYPED
9090
['-10,100.1', '-10,100.1', true],
91+
['list', [1, 2], true],
92+
['map', ['one' => 1, 'two' => 2], true],
9193
];
9294
}
9395

0 commit comments

Comments
 (0)