diff --git a/src/Symfony/Component/DependencyInjection/Compiler/PassConfig.php b/src/Symfony/Component/DependencyInjection/Compiler/PassConfig.php
index 7fb47f82b3..a28262ec4b 100644
--- a/src/Symfony/Component/DependencyInjection/Compiler/PassConfig.php
+++ b/src/Symfony/Component/DependencyInjection/Compiler/PassConfig.php
@@ -59,8 +59,8 @@ class PassConfig
$this->removingPasses = array(
new RemovePrivateAliasesPass(),
- new RemoveAbstractDefinitionsPass(),
new ReplaceAliasByActualDefinitionPass(),
+ new RemoveAbstractDefinitionsPass(),
new RepeatedPass(array(
new AnalyzeServiceReferencesPass(),
new InlineServiceDefinitionsPass(),
@@ -103,8 +103,7 @@ class PassConfig
throw new InvalidArgumentException(sprintf('Invalid type "%s".', $type));
}
- $passes = &$this->$property;
- $passes[] = $pass;
+ $this->{$property}[] = $pass;
}
/**
diff --git a/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php b/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php
index 5719dc68ea..6d3360f0dd 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php
+++ b/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php
@@ -707,6 +707,21 @@ class ContainerBuilderTest extends \PHPUnit_Framework_TestCase
$this->assertEquals(array($second, $first), $configs);
}
+ public function testAbstractAlias()
+ {
+ $container = new ContainerBuilder();
+
+ $abstract = new Definition('AbstractClass');
+ $abstract->setAbstract(true);
+
+ $container->setDefinition('abstract_service', $abstract);
+ $container->setAlias('abstract_alias', 'abstract_service');
+
+ $container->compile();
+
+ $this->assertSame('abstract_service', (string) $container->getAlias('abstract_alias'));
+ }
+
public function testLazyLoadedService()
{
$loader = new ClosureLoader($container = new ContainerBuilder());
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services5.xml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services5.xml
index acb93e748e..347df977dd 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services5.xml
+++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services5.xml
@@ -14,8 +14,12 @@
-
+
+
+
+
+
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php b/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php
index e5dfa2a13e..38ee13d5ff 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php
+++ b/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php
@@ -121,7 +121,7 @@ class XmlFileLoaderTest extends \PHPUnit_Framework_TestCase
$loader = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml'));
$loader->load('services5.xml');
$services = $container->getDefinitions();
- $this->assertCount(4, $services, '->load() attributes unique ids to anonymous services');
+ $this->assertCount(6, $services, '->load() attributes unique ids to anonymous services');
// anonymous service as an argument
$args = $services['foo']->getArguments();
@@ -130,6 +130,7 @@ class XmlFileLoaderTest extends \PHPUnit_Framework_TestCase
$this->assertTrue(isset($services[(string) $args[0]]), '->load() makes a reference to the created ones');
$inner = $services[(string) $args[0]];
$this->assertEquals('BarClass', $inner->getClass(), '->load() uses the same configuration as for the anonymous ones');
+ $this->assertFalse($inner->isPublic());
// inner anonymous services
$args = $inner->getArguments();
@@ -138,6 +139,7 @@ class XmlFileLoaderTest extends \PHPUnit_Framework_TestCase
$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();
@@ -145,7 +147,25 @@ class XmlFileLoaderTest extends \PHPUnit_Framework_TestCase
$this->assertInstanceOf('Symfony\\Component\\DependencyInjection\\Reference', $property, '->load() converts anonymous services to references to "normal" services');
$this->assertTrue(isset($services[(string) $property]), '->load() makes a reference to the created ones');
$inner = $services[(string) $property];
- $this->assertEquals('BazClass', $inner->getClass(), '->load() uses the same configuration as for the anonymous ones');
+ $this->assertEquals('BuzClass', $inner->getClass(), '->load() uses the same configuration as for the anonymous ones');
+ $this->assertFalse($inner->isPublic());
+
+ // "wild" service
+ $service = $container->findTaggedServiceIds('biz_tag');
+ $this->assertCount(1, $service);
+
+ foreach ($service as $id => $tag) {
+ $service = $container->getDefinition($id);
+ }
+ $this->assertEquals('BizClass', $service->getClass(), '->load() uses the same configuration as for the anonymous ones');
+ $this->assertFalse($service->isPublic());
+
+ // anonymous services are shared when using decoration definitions
+ $container->compile();
+ $services = $container->getDefinitions();
+ $fooArgs = $services['foo']->getArguments();
+ $barArgs = $services['bar']->getArguments();
+ $this->assertSame($fooArgs[0], $barArgs[0]);
}
public function testLoadServices()