Skip to content

Commit a0e0325

Browse files
committed
feature #47367 [DependencyInjection] Handle INI arrays (MatTheCat)
This PR was submitted for the 4.4 branch but it was merged into the 6.2 branch instead. Discussion ---------- [DependencyInjection] Handle INI arrays | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #47357 | License | MIT | Doc PR | N/A Commits ------- f90525c Handle INI arrays
2 parents 6903807 + f90525c commit a0e0325

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

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

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

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