Fixing problem where _defaults set to null was seen as a service
This commit is contained in:
parent
9d9f628d92
commit
4b7e148a9b
@ -205,7 +205,7 @@ class YamlFileLoader extends FileLoader
|
||||
throw new InvalidArgumentException(sprintf('The "services" key should contain an array in %s. Check your YAML syntax.', $file));
|
||||
}
|
||||
|
||||
if (isset($content['services']['_instanceof'])) {
|
||||
if (array_key_exists('_instanceof', $content['services'])) {
|
||||
$instanceof = $content['services']['_instanceof'];
|
||||
unset($content['services']['_instanceof']);
|
||||
|
||||
@ -242,7 +242,7 @@ class YamlFileLoader extends FileLoader
|
||||
*/
|
||||
private function parseDefaults(array &$content, $file)
|
||||
{
|
||||
if (!isset($content['services']['_defaults'])) {
|
||||
if (!array_key_exists('_defaults', $content['services'])) {
|
||||
return array();
|
||||
}
|
||||
$defaults = $content['services']['_defaults'];
|
||||
|
@ -0,0 +1,2 @@
|
||||
services:
|
||||
_defaults:
|
@ -0,0 +1,2 @@
|
||||
services:
|
||||
_instanceof:
|
@ -577,6 +577,28 @@ class YamlFileLoaderTest extends TestCase
|
||||
$this->assertTrue($container->getDefinition('use_defaults_settings')->isAutoconfigured());
|
||||
$this->assertFalse($container->getDefinition('override_defaults_settings_to_false')->isAutoconfigured());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException
|
||||
* @expectedExceptionMessage Service "_defaults" key must be an array, "NULL" given in "bad_empty_defaults.yml".
|
||||
*/
|
||||
public function testEmptyDefaultsThrowsClearException()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml'));
|
||||
$loader->load('bad_empty_defaults.yml');
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException
|
||||
* @expectedExceptionMessage Service "_instanceof" key must be an array, "NULL" given in "bad_empty_instanceof.yml".
|
||||
*/
|
||||
public function testEmptyInstanceofThrowsClearException()
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml'));
|
||||
$loader->load('bad_empty_instanceof.yml');
|
||||
}
|
||||
}
|
||||
|
||||
interface FooInterface
|
||||
|
Reference in New Issue
Block a user