From 9c892f1016fc893a044e48231deec1e56382c153 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Pineau?= Date: Thu, 14 Aug 2014 01:29:31 +0200 Subject: [PATCH 1/2] [DIC] Use better variables name --- .../DependencyInjection/Loader/XmlFileLoader.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php b/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php index 90a94251abf32..86f72f12f50e9 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php +++ b/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php @@ -278,18 +278,18 @@ private function processAnonymousServices(\DOMDocument $xml, $file) // resolve definitions krsort($definitions); foreach ($definitions as $id => $def) { + list($domElement, $file, $wild) = $def; // anonymous services are always private - $def[0]->setAttribute('public', false); + $domElement->setAttribute('public', false); - $this->parseDefinition($id, $def[0], $def[1]); + $this->parseDefinition($id, $domElement, $file); - $oNode = $def[0]; - if (true === $def[2]) { - $nNode = new \DOMElement('_services', null, self::NS); - $oNode->parentNode->replaceChild($nNode, $oNode); - $nNode->setAttribute('id', $id); + if (true === $wild) { + $tmpDomElement = new \DOMElement('_services', null, self::NS); + $domElement->parentNode->replaceChild($tmpDomElement, $domElement); + $tmpDomElement->setAttribute('id', $id); } else { - $oNode->parentNode->removeChild($oNode); + $domElement->parentNode->removeChild($domElement); } } } From a2f81939a365da4a7eda47128a036dd85aeac532 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20Pineau?= Date: Thu, 14 Aug 2014 01:35:18 +0200 Subject: [PATCH 2/2] [DIC] Fixed: anonymous services are always private --- .../Component/DependencyInjection/Loader/XmlFileLoader.php | 4 +++- .../DependencyInjection/Tests/Loader/XmlFileLoaderTest.php | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php b/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php index 86f72f12f50e9..32d2bb19ba40e 100644 --- a/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php +++ b/src/Symfony/Component/DependencyInjection/Loader/XmlFileLoader.php @@ -279,8 +279,10 @@ private function processAnonymousServices(\DOMDocument $xml, $file) krsort($definitions); foreach ($definitions as $id => $def) { list($domElement, $file, $wild) = $def; + // anonymous services are always private - $domElement->setAttribute('public', false); + // we could not use the constant false here, because of XML parsing + $domElement->setAttribute('public', 'false'); $this->parseDefinition($id, $domElement, $file); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php b/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php index c9ad753c9bede..39c65a984f4da 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php @@ -184,6 +184,7 @@ public function testLoadAnonymousServices() $this->assertTrue(isset($services[(string) $args[0]]), '->load() makes a reference to the created ones'); $inner = $services[(string) $args[0]]; $this->assertEquals('BazClass', $inner->getClass(), '->load() uses the same configuration as for the anonymous ones'); + $this->assertFalse($inner->isPublic()); // anonymous service as a property $properties = $services['foo']->getProperties();