Skip to content

Commit 392a780

Browse files
committed
Merge branch '2.7' into 2.8
* 2.7: [HttpFoundation] Use the correct syntax for session gc based on Pdo driver Revert "bug #24987 [Console] Fix global console flag when used in chain (Simperfit)" Revert "bug #25487 [Console] Fix a bug when passing a letter that could be an alias (Simperfit)" Disable CSP header on exception pages only in debug Fixed submitting disabled buttons Fixed Button::setParent() when already submitted Improve assertions SCA: get rid of repetitive calls allow null values for root nodes in YAML configs [VarDumper] Fix docblock Improve phpdoc to make it more explicit
2 parents 41f53b3 + 82dcf06 commit 392a780

File tree

5 files changed

+26
-3
lines changed

5 files changed

+26
-3
lines changed

ContainerBuilder.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,12 +276,16 @@ public function addClassResource(\ReflectionClass $class)
276276
* @throws BadMethodCallException When this ContainerBuilder is frozen
277277
* @throws \LogicException if the container is frozen
278278
*/
279-
public function loadFromExtension($extension, array $values = array())
279+
public function loadFromExtension($extension, array $values = null)
280280
{
281281
if ($this->isFrozen()) {
282282
throw new BadMethodCallException('Cannot load from an extension on a frozen container.');
283283
}
284284

285+
if (func_num_args() < 2) {
286+
$values = array();
287+
}
288+
285289
$namespace = $this->getExtension($extension)->getAlias();
286290

287291
$this->extensionConfigs[$namespace][] = $values;

Loader/YamlFileLoader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ private function loadFromExtensions(array $content)
459459
continue;
460460
}
461461

462-
if (!is_array($values)) {
462+
if (!is_array($values) && null !== $values) {
463463
$values = array();
464464
}
465465

Tests/Fixtures/includes/ProjectExtension.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,14 @@ class ProjectExtension implements ExtensionInterface
88
{
99
public function load(array $configs, ContainerBuilder $configuration)
1010
{
11-
$config = call_user_func_array('array_merge', $configs);
11+
$configuration->setParameter('project.configs', $configs);
12+
$configs = array_filter($configs);
13+
14+
if ($configs) {
15+
$config = call_user_func_array('array_merge', $configs);
16+
} else {
17+
$config = array();
18+
}
1219

1320
$configuration->setDefinition('project.service.bar', new Definition('FooClass'));
1421
$configuration->setParameter('project.parameter.bar', isset($config['foo']) ? $config['foo'] : 'foobar');

Tests/Fixtures/yaml/null_config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
project: ~

Tests/Loader/YamlFileLoaderTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,17 @@ public function testExtensions()
209209
}
210210
}
211211

212+
public function testExtensionWithNullConfig()
213+
{
214+
$container = new ContainerBuilder();
215+
$container->registerExtension(new \ProjectExtension());
216+
$loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml'));
217+
$loader->load('null_config.yml');
218+
$container->compile();
219+
220+
$this->assertSame(array(null), $container->getParameter('project.configs'));
221+
}
222+
212223
public function testSupports()
213224
{
214225
$loader = new YamlFileLoader(new ContainerBuilder(), new FileLocator());

0 commit comments

Comments
 (0)