Skip to content

Commit c3fa63b

Browse files
committed
[DependencyInjection] Don't add the .container.known_envs parameter when empty
Other loaders does not create this parameter when there is no when@<env> key
1 parent 8d2c50c commit c3fa63b

File tree

2 files changed

+2
-5
lines changed

2 files changed

+2
-5
lines changed

src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,10 @@ public function load(mixed $resource, ?string $type = null): mixed
6363
$this->loadXml($xml, $path, $root);
6464
}
6565
}
66-
$knownEnvs = $this->container->hasParameter('.container.known_envs') ? array_flip($this->container->getParameter('.container.known_envs')) : [];
6766
foreach ($xpath->query('//container:when') ?: [] as $root) {
68-
$knownEnvs[$root->getAttribute('env')] = true;
67+
$knownEnvs = $this->container->hasParameter('.container.known_envs') ? array_flip($this->container->getParameter('.container.known_envs')) : [];
68+
$this->container->setParameter('.container.known_envs', array_keys($knownEnvs + [$root->getAttribute('env') => true]));
6969
}
70-
$this->container->setParameter('.container.known_envs', array_keys($knownEnvs));
7170

7271
return null;
7372
}

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,6 @@ public function testLoadParameters()
154154
],
155155
'mixedcase' => ['MixedCaseKey' => 'value'],
156156
'constant' => \PHP_EOL,
157-
'.container.known_envs' => [],
158157
];
159158

160159
$this->assertEquals($expected, $actual, '->load() converts XML values to PHP ones');
@@ -191,7 +190,6 @@ public function testLoadImports()
191190
],
192191
'mixedcase' => ['MixedCaseKey' => 'value'],
193192
'constant' => \PHP_EOL,
194-
'.container.known_envs' => [],
195193
'bar' => '%foo%',
196194
'imported_from_ini' => true,
197195
'imported_from_yaml' => true,

0 commit comments

Comments
 (0)