Merge branch '2.7' into 2.8

* 2.7:
  top-level anonymous services must be public
This commit is contained in:
Nicolas Grekas 2016-05-06 11:32:10 +02:00
commit 8ca614dbc9
2 changed files with 5 additions and 4 deletions

View File

@ -315,6 +315,10 @@ class XmlFileLoader extends FileLoader
if ($services = $this->getChildren($node, 'service')) {
$definitions[$id] = array($services[0], $file, false);
$services[0]->setAttribute('id', $id);
// anonymous services are always private
// we could not use the constant false here, because of XML parsing
$services[0]->setAttribute('public', 'false');
}
}
}
@ -334,9 +338,6 @@ class XmlFileLoader extends FileLoader
foreach ($definitions as $id => $def) {
list($domElement, $file, $wild) = $def;
// anonymous services are always private
// we could not use the constant false here, because of XML parsing
$domElement->setAttribute('public', 'false');
if (null !== $definition = $this->parseDefinition($domElement, $file)) {
$this->container->setDefinition($id, $definition);

View File

@ -200,7 +200,7 @@ class XmlFileLoaderTest extends \PHPUnit_Framework_TestCase
$service = $container->getDefinition($id);
}
$this->assertEquals('BizClass', $service->getClass(), '->load() uses the same configuration as for the anonymous ones');
$this->assertFalse($service->isPublic());
$this->assertTrue($service->isPublic());
// anonymous services are shared when using decoration definitions
$container->compile();