diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/services.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/services.xml index 8bcaecf703..cec7ed976c 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/services.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/services.xml @@ -40,10 +40,6 @@ - - - - diff --git a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php index 8c3b3e6b32..074f942a75 100644 --- a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php +++ b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php @@ -11,6 +11,7 @@ namespace Symfony\Component\DependencyInjection; +use Psr\Container\ContainerInterface as PsrContainerInterface; use Symfony\Component\DependencyInjection\Argument\ClosureProxyArgument; use Symfony\Component\DependencyInjection\Argument\IteratorArgument; use Symfony\Component\DependencyInjection\Argument\RewindableGenerator; @@ -38,6 +39,7 @@ use Symfony\Component\DependencyInjection\LazyProxy\Instantiator\InstantiatorInt use Symfony\Component\DependencyInjection\LazyProxy\Instantiator\RealServiceInstantiator; use Symfony\Component\DependencyInjection\LazyProxy\InheritanceProxyHelper; use Symfony\Component\DependencyInjection\LazyProxy\InheritanceProxyInterface; +use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface; use Symfony\Component\ExpressionLanguage\Expression; use Symfony\Component\ExpressionLanguage\ExpressionFunctionProviderInterface; @@ -117,6 +119,16 @@ class ContainerBuilder extends Container implements TaggedContainerInterface */ private $vendors; + public function __construct(ParameterBagInterface $parameterBag = null) + { + parent::__construct($parameterBag); + + $this->setDefinition('service_container', (new Definition(ContainerInterface::class))->setSynthetic(true)); + $this->setAlias(PsrContainerInterface::class, new Alias('service_container', false)); + $this->setAlias(ContainerInterface::class, new Alias('service_container', false)); + $this->setAlias(Container::class, new Alias('service_container', false)); + } + /** * @var \ReflectionClass[] a list of class reflectors */ diff --git a/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php b/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php index 8452f3a032..e5405389c5 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php @@ -15,6 +15,7 @@ require_once __DIR__.'/Fixtures/includes/classes.php'; require_once __DIR__.'/Fixtures/includes/ProjectExtension.php'; use PHPUnit\Framework\TestCase; +use Psr\Container\ContainerInterface as PsrContainerInterface; use Symfony\Component\Config\Resource\ComposerResource; use Symfony\Component\Config\Resource\ResourceInterface; use Symfony\Component\Config\Resource\DirectoryResource; @@ -25,6 +26,7 @@ use Symfony\Component\DependencyInjection\Argument\RewindableGenerator; use Symfony\Component\DependencyInjection\Argument\ServiceLocatorArgument; use Symfony\Component\DependencyInjection\ChildDefinition; use Symfony\Component\DependencyInjection\Compiler\PassConfig; +use Symfony\Component\DependencyInjection\Container; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\Definition; @@ -42,6 +44,22 @@ use Symfony\Component\ExpressionLanguage\Expression; class ContainerBuilderTest extends TestCase { + public function testDefaultRegisteredDefinitions() + { + $builder = new ContainerBuilder(); + + $this->assertCount(1, $builder->getDefinitions()); + $this->assertTrue($builder->hasDefinition('service_container')); + + $definition = $builder->getDefinition('service_container'); + $this->assertInstanceOf(Definition::class, $definition); + $this->assertTrue($definition->isSynthetic()); + $this->assertSame(ContainerInterface::class, $definition->getClass()); + $this->assertTrue($builder->hasAlias(PsrContainerInterface::class)); + $this->assertTrue($builder->hasAlias(ContainerInterface::class)); + $this->assertTrue($builder->hasAlias(Container::class)); + } + public function testDefinitions() { $builder = new ContainerBuilder(); @@ -203,7 +221,18 @@ class ContainerBuilderTest extends TestCase $builder->register('foo', 'stdClass'); $builder->bar = $bar = new \stdClass(); $builder->register('bar', 'stdClass'); - $this->assertEquals(array('foo', 'bar', 'service_container'), $builder->getServiceIds(), '->getServiceIds() returns all defined service ids'); + $this->assertEquals( + array( + 'service_container', + 'foo', + 'bar', + 'Psr\Container\ContainerInterface', + 'Symfony\Component\DependencyInjection\ContainerInterface', + 'Symfony\Component\DependencyInjection\Container', + ), + $builder->getServiceIds(), + '->getServiceIds() returns all defined service ids' + ); } public function testAliases() @@ -251,7 +280,7 @@ class ContainerBuilderTest extends TestCase $builder->set('foobar', 'stdClass'); $builder->set('moo', 'stdClass'); - $this->assertCount(0, $builder->getAliases(), '->getAliases() does not return aliased services that have been overridden'); + $this->assertCount(3, $builder->getAliases(), '->getAliases() does not return aliased services that have been overridden'); } public function testSetAliases() @@ -538,7 +567,7 @@ class ContainerBuilderTest extends TestCase $config->setDefinition('baz', new Definition('BazClass')); $config->setAlias('alias_for_foo', 'foo'); $container->merge($config); - $this->assertEquals(array('foo', 'bar', 'baz'), array_keys($container->getDefinitions()), '->merge() merges definitions already defined ones'); + $this->assertEquals(array('service_container', 'foo', 'bar', 'baz'), array_keys($container->getDefinitions()), '->merge() merges definitions already defined ones'); $aliases = $container->getAliases(); $this->assertTrue(isset($aliases['alias_for_foo'])); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Dumper/XmlDumperTest.php b/src/Symfony/Component/DependencyInjection/Tests/Dumper/XmlDumperTest.php index 924f2d99dd..50ea8c384c 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Dumper/XmlDumperTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Dumper/XmlDumperTest.php @@ -70,6 +70,7 @@ class XmlDumperTest extends TestCase $this->assertEquals(' + @@ -79,6 +80,9 @@ class XmlDumperTest extends TestCase + + + ', $dumper->dump()); @@ -91,10 +95,14 @@ class XmlDumperTest extends TestCase $this->assertEquals(" + foo<>&bar + + + ", $dumper->dump()); @@ -117,14 +125,22 @@ class XmlDumperTest extends TestCase array(" + + + + ", include $fixturesPath.'/containers/container15.php'), array(" + + + + ", include $fixturesPath.'/containers/container16.php'), diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/graphviz/services1.dot b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/graphviz/services1.dot index 1bb7c30b8c..b7fe815b79 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/graphviz/services1.dot +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/graphviz/services1.dot @@ -3,5 +3,5 @@ digraph sc { node [fontsize="11" fontname="Arial" shape="record"]; edge [fontsize="9" fontname="Arial" color="grey" arrowhead="open" arrowsize="0.5"]; - node_service_container [label="service_container\nSymfony\\Component\\DependencyInjection\\ContainerBuilder\n", shape=record, fillcolor="#9999ff", style="filled"]; + node_service_container [label="service_container (Psr\Container\ContainerInterface, Symfony\Component\DependencyInjection\ContainerInterface, Symfony\Component\DependencyInjection\Container)\nSymfony\\Component\\DependencyInjection\\ContainerInterface\n", shape=record, fillcolor="#eeeeee", style="filled"]; } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/graphviz/services10-1.dot b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/graphviz/services10-1.dot index 0e578b161b..d748265cc3 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/graphviz/services10-1.dot +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/graphviz/services10-1.dot @@ -3,8 +3,8 @@ digraph sc { node [fontsize="13" fontname="Verdana" shape="square"]; edge [fontsize="12" fontname="Verdana" color="white" arrowhead="closed" arrowsize="1"]; + node_service_container [label="service_container (Psr\Container\ContainerInterface, Symfony\Component\DependencyInjection\ContainerInterface, Symfony\Component\DependencyInjection\Container)\nSymfony\\Component\\DependencyInjection\\ContainerInterface\n", shape=square, fillcolor="grey", style="filled"]; node_foo [label="foo\nFooClass\n", shape=square, fillcolor="grey", style="filled"]; - node_service_container [label="service_container\nSymfony\\Component\\DependencyInjection\\ContainerBuilder\n", shape=square, fillcolor="green", style="empty"]; node_bar [label="bar\n\n", shape=square, fillcolor="red", style="empty"]; node_foo -> node_bar [label="" style="filled"]; } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/graphviz/services10.dot b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/graphviz/services10.dot index f17857fe42..0320d7da83 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/graphviz/services10.dot +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/graphviz/services10.dot @@ -3,8 +3,8 @@ digraph sc { node [fontsize="11" fontname="Arial" shape="record"]; edge [fontsize="9" fontname="Arial" color="grey" arrowhead="open" arrowsize="0.5"]; + node_service_container [label="service_container (Psr\Container\ContainerInterface, Symfony\Component\DependencyInjection\ContainerInterface, Symfony\Component\DependencyInjection\Container)\nSymfony\\Component\\DependencyInjection\\ContainerInterface\n", shape=record, fillcolor="#eeeeee", style="filled"]; node_foo [label="foo\nFooClass\n", shape=record, fillcolor="#eeeeee", style="filled"]; - node_service_container [label="service_container\nSymfony\\Component\\DependencyInjection\\ContainerBuilder\n", shape=record, fillcolor="#9999ff", style="filled"]; node_bar [label="bar\n\n", shape=record, fillcolor="#ff9999", style="filled"]; node_foo -> node_bar [label="" style="filled"]; } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/graphviz/services13.dot b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/graphviz/services13.dot index bc7f81317e..fffe8f1b54 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/graphviz/services13.dot +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/graphviz/services13.dot @@ -3,8 +3,8 @@ digraph sc { node [fontsize="11" fontname="Arial" shape="record"]; edge [fontsize="9" fontname="Arial" color="grey" arrowhead="open" arrowsize="0.5"]; + node_service_container [label="service_container\nSymfony\\Component\\DependencyInjection\\ContainerInterface\n", shape=record, fillcolor="#eeeeee", style="filled"]; node_foo [label="foo\nFooClass\n", shape=record, fillcolor="#eeeeee", style="filled"]; node_bar [label="bar\nBarClass\n", shape=record, fillcolor="#eeeeee", style="filled"]; - node_service_container [label="service_container\nSymfony\\Component\\DependencyInjection\\ContainerBuilder\n", shape=record, fillcolor="#9999ff", style="filled"]; node_foo -> node_bar [label="" style="filled"]; } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/graphviz/services14.dot b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/graphviz/services14.dot index d07dc389e0..b7fe815b79 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/graphviz/services14.dot +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/graphviz/services14.dot @@ -3,5 +3,5 @@ digraph sc { node [fontsize="11" fontname="Arial" shape="record"]; edge [fontsize="9" fontname="Arial" color="grey" arrowhead="open" arrowsize="0.5"]; - node_service_container [label="service_container\nContainer14\\ProjectServiceContainer\n", shape=record, fillcolor="#9999ff", style="filled"]; + node_service_container [label="service_container (Psr\Container\ContainerInterface, Symfony\Component\DependencyInjection\ContainerInterface, Symfony\Component\DependencyInjection\Container)\nSymfony\\Component\\DependencyInjection\\ContainerInterface\n", shape=record, fillcolor="#eeeeee", style="filled"]; } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/graphviz/services17.dot b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/graphviz/services17.dot index a6d04bf5a0..aade43a799 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/graphviz/services17.dot +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/graphviz/services17.dot @@ -3,6 +3,6 @@ digraph sc { node [fontsize="11" fontname="Arial" shape="record"]; edge [fontsize="9" fontname="Arial" color="grey" arrowhead="open" arrowsize="0.5"]; + node_service_container [label="service_container (Psr\Container\ContainerInterface, Symfony\Component\DependencyInjection\ContainerInterface, Symfony\Component\DependencyInjection\Container)\nSymfony\\Component\\DependencyInjection\\ContainerInterface\n", shape=record, fillcolor="#eeeeee", style="filled"]; node_foo [label="foo\n%foo.class%\n", shape=record, fillcolor="#eeeeee", style="filled"]; - node_service_container [label="service_container\nSymfony\\Component\\DependencyInjection\\ContainerBuilder\n", shape=record, fillcolor="#9999ff", style="filled"]; } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/graphviz/services9.dot b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/graphviz/services9.dot index f62f7a2312..2c84476b7b 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/graphviz/services9.dot +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/graphviz/services9.dot @@ -3,6 +3,7 @@ digraph sc { node [fontsize="11" fontname="Arial" shape="record"]; edge [fontsize="9" fontname="Arial" color="grey" arrowhead="open" arrowsize="0.5"]; + node_service_container [label="service_container (Psr\Container\ContainerInterface, Symfony\Component\DependencyInjection\ContainerInterface, Symfony\Component\DependencyInjection\Container)\nSymfony\\Component\\DependencyInjection\\ContainerInterface\n", shape=record, fillcolor="#eeeeee", style="filled"]; node_foo [label="foo (alias_for_foo)\nBar\\FooClass\n", shape=record, fillcolor="#eeeeee", style="filled"]; node_foo_baz [label="foo.baz\nBazClass\n", shape=record, fillcolor="#eeeeee", style="filled"]; node_bar [label="bar\nBar\\FooClass\n", shape=record, fillcolor="#eeeeee", style="filled"]; @@ -30,7 +31,6 @@ digraph sc { node_lazy_context_ignore_invalid_ref [label="lazy_context_ignore_invalid_ref\nLazyContext\n", shape=record, fillcolor="#eeeeee", style="filled"]; node_closure_proxy [label="closure_proxy\nBarClass\n", shape=record, fillcolor="#eeeeee", style="filled"]; node_service_locator [label="service_locator\nBar\n", shape=record, fillcolor="#eeeeee", style="filled"]; - node_service_container [label="service_container\nSymfony\\Component\\DependencyInjection\\ContainerBuilder\n", shape=record, fillcolor="#9999ff", style="filled"]; node_foo2 [label="foo2\n\n", shape=record, fillcolor="#ff9999", style="filled"]; node_foo3 [label="foo3\n\n", shape=record, fillcolor="#ff9999", style="filled"]; node_foobaz [label="foobaz\n\n", shape=record, fillcolor="#ff9999", style="filled"]; diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1-1.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1-1.php index fbaff884fa..2c6e65b3e7 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1-1.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1-1.php @@ -29,6 +29,11 @@ class Container extends AbstractContainer public function __construct() { $this->services = array(); + $this->normalizedIds = array( + 'psr\\container\\containerinterface' => 'Psr\\Container\\ContainerInterface', + 'symfony\\component\\dependencyinjection\\container' => 'Symfony\\Component\\DependencyInjection\\Container', + 'symfony\\component\\dependencyinjection\\containerinterface' => 'Symfony\\Component\\DependencyInjection\\ContainerInterface', + ); $this->aliases = array(); } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1.php index 644350a059..d85d8936db 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1.php @@ -28,6 +28,11 @@ class ProjectServiceContainer extends Container public function __construct() { $this->services = array(); + $this->normalizedIds = array( + 'psr\\container\\containerinterface' => 'Psr\\Container\\ContainerInterface', + 'symfony\\component\\dependencyinjection\\container' => 'Symfony\\Component\\DependencyInjection\\Container', + 'symfony\\component\\dependencyinjection\\containerinterface' => 'Symfony\\Component\\DependencyInjection\\ContainerInterface', + ); $this->aliases = array(); } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services10.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services10.php index d6b4074667..b6118a84a3 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services10.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services10.php @@ -30,6 +30,11 @@ class ProjectServiceContainer extends Container $this->parameters = $this->getDefaultParameters(); $this->services = array(); + $this->normalizedIds = array( + 'psr\\container\\containerinterface' => 'Psr\\Container\\ContainerInterface', + 'symfony\\component\\dependencyinjection\\container' => 'Symfony\\Component\\DependencyInjection\\Container', + 'symfony\\component\\dependencyinjection\\containerinterface' => 'Symfony\\Component\\DependencyInjection\\ContainerInterface', + ); $this->methodMap = array( 'test' => 'getTestService', ); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services12.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services12.php index 0d1c526a79..973f8cd54a 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services12.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services12.php @@ -34,6 +34,11 @@ class ProjectServiceContainer extends Container $this->parameters = $this->getDefaultParameters(); $this->services = array(); + $this->normalizedIds = array( + 'psr\\container\\containerinterface' => 'Psr\\Container\\ContainerInterface', + 'symfony\\component\\dependencyinjection\\container' => 'Symfony\\Component\\DependencyInjection\\Container', + 'symfony\\component\\dependencyinjection\\containerinterface' => 'Symfony\\Component\\DependencyInjection\\ContainerInterface', + ); $this->methodMap = array( 'test' => 'getTestService', ); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services13.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services13.php index c72e62e022..2710f9b12d 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services13.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services13.php @@ -28,6 +28,11 @@ class ProjectServiceContainer extends Container public function __construct() { $this->services = array(); + $this->normalizedIds = array( + 'psr\\container\\containerinterface' => 'Psr\\Container\\ContainerInterface', + 'symfony\\component\\dependencyinjection\\container' => 'Symfony\\Component\\DependencyInjection\\Container', + 'symfony\\component\\dependencyinjection\\containerinterface' => 'Symfony\\Component\\DependencyInjection\\ContainerInterface', + ); $this->methodMap = array( 'bar' => 'getBarService', ); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services19.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services19.php index b906f3c9f2..9e5ff19633 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services19.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services19.php @@ -28,6 +28,11 @@ class ProjectServiceContainer extends Container public function __construct() { $this->services = array(); + $this->normalizedIds = array( + 'psr\\container\\containerinterface' => 'Psr\\Container\\ContainerInterface', + 'symfony\\component\\dependencyinjection\\container' => 'Symfony\\Component\\DependencyInjection\\Container', + 'symfony\\component\\dependencyinjection\\containerinterface' => 'Symfony\\Component\\DependencyInjection\\ContainerInterface', + ); $this->methodMap = array( 'service_from_anonymous_factory' => 'getServiceFromAnonymousFactoryService', 'service_with_method_call_and_factory' => 'getServiceWithMethodCallAndFactoryService', diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services24.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services24.php index cefb180b9a..db4b6defb3 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services24.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services24.php @@ -28,6 +28,11 @@ class ProjectServiceContainer extends Container public function __construct() { $this->services = array(); + $this->normalizedIds = array( + 'psr\\container\\containerinterface' => 'Psr\\Container\\ContainerInterface', + 'symfony\\component\\dependencyinjection\\container' => 'Symfony\\Component\\DependencyInjection\\Container', + 'symfony\\component\\dependencyinjection\\containerinterface' => 'Symfony\\Component\\DependencyInjection\\ContainerInterface', + ); $this->methodMap = array( 'foo' => 'getFooService', ); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services26.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services26.php index 02c0257e51..dc46680572 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services26.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services26.php @@ -30,6 +30,11 @@ class ProjectServiceContainer extends Container $this->parameters = $this->getDefaultParameters(); $this->services = array(); + $this->normalizedIds = array( + 'psr\\container\\containerinterface' => 'Psr\\Container\\ContainerInterface', + 'symfony\\component\\dependencyinjection\\container' => 'Symfony\\Component\\DependencyInjection\\Container', + 'symfony\\component\\dependencyinjection\\containerinterface' => 'Symfony\\Component\\DependencyInjection\\ContainerInterface', + ); $this->methodMap = array( 'test' => 'getTestService', ); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services29.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services29.php index bc2b2e302b..cc4dccff8f 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services29.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services29.php @@ -28,6 +28,11 @@ class Symfony_DI_PhpDumper_Test_Overriden_Getters extends Container public function __construct() { $this->services = array(); + $this->normalizedIds = array( + 'psr\\container\\containerinterface' => 'Psr\\Container\\ContainerInterface', + 'symfony\\component\\dependencyinjection\\container' => 'Symfony\\Component\\DependencyInjection\\Container', + 'symfony\\component\\dependencyinjection\\containerinterface' => 'Symfony\\Component\\DependencyInjection\\ContainerInterface', + ); $this->methodMap = array( 'baz' => 'getBazService', 'foo' => 'getFooService', diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services31.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services31.php index ae8a1d72de..e957125e64 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services31.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services31.php @@ -28,6 +28,11 @@ class ProjectServiceContainer extends Container public function __construct() { $this->services = array(); + $this->normalizedIds = array( + 'psr\\container\\containerinterface' => 'Psr\\Container\\ContainerInterface', + 'symfony\\component\\dependencyinjection\\container' => 'Symfony\\Component\\DependencyInjection\\Container', + 'symfony\\component\\dependencyinjection\\containerinterface' => 'Symfony\\Component\\DependencyInjection\\ContainerInterface', + ); $this->methodMap = array( 'bar' => 'getBarService', 'foo' => 'getFooService', diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services32.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services32.php index 442c319e27..9a06d55f90 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services32.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services32.php @@ -28,6 +28,11 @@ class ProjectServiceContainer extends Container public function __construct() { $this->services = array(); + $this->normalizedIds = array( + 'psr\\container\\containerinterface' => 'Psr\\Container\\ContainerInterface', + 'symfony\\component\\dependencyinjection\\container' => 'Symfony\\Component\\DependencyInjection\\Container', + 'symfony\\component\\dependencyinjection\\containerinterface' => 'Symfony\\Component\\DependencyInjection\\ContainerInterface', + ); $this->methodMap = array( 'bar' => 'getBarService', 'foo' => 'getFooService', diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services33.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services33.php index be3a7d684a..3eebf95081 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services33.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services33.php @@ -29,6 +29,9 @@ class ProjectServiceContainer extends Container { $this->services = array(); $this->normalizedIds = array( + 'psr\\container\\containerinterface' => 'Psr\\Container\\ContainerInterface', + 'symfony\\component\\dependencyinjection\\container' => 'Symfony\\Component\\DependencyInjection\\Container', + 'symfony\\component\\dependencyinjection\\containerinterface' => 'Symfony\\Component\\DependencyInjection\\ContainerInterface', 'symfony\\component\\dependencyinjection\\tests\\fixtures\\container33\\foo' => 'Symfony\\Component\\DependencyInjection\\Tests\\Fixtures\\Container33\\Foo', ); $this->methodMap = array( diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services8.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services8.php index 40c83315f8..0127399ff1 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services8.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services8.php @@ -30,6 +30,11 @@ class ProjectServiceContainer extends Container $this->parameters = $this->getDefaultParameters(); $this->services = array(); + $this->normalizedIds = array( + 'psr\\container\\containerinterface' => 'Psr\\Container\\ContainerInterface', + 'symfony\\component\\dependencyinjection\\container' => 'Symfony\\Component\\DependencyInjection\\Container', + 'symfony\\component\\dependencyinjection\\containerinterface' => 'Symfony\\Component\\DependencyInjection\\ContainerInterface', + ); $this->aliases = array(); } diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9.php index 5126c5d6e6..93fe0e5939 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9.php @@ -28,6 +28,11 @@ class ProjectServiceContainer extends Container public function __construct() { parent::__construct(new ParameterBag($this->getDefaultParameters())); + $this->normalizedIds = array( + 'psr\\container\\containerinterface' => 'Psr\\Container\\ContainerInterface', + 'symfony\\component\\dependencyinjection\\container' => 'Symfony\\Component\\DependencyInjection\\Container', + 'symfony\\component\\dependencyinjection\\containerinterface' => 'Symfony\\Component\\DependencyInjection\\ContainerInterface', + ); $this->methodMap = array( 'bar' => 'getBarService', 'baz' => 'getBazService', @@ -64,6 +69,9 @@ class ProjectServiceContainer extends Container 'new_factory' => true, ); $this->aliases = array( + 'Psr\\Container\\ContainerInterface' => 'service_container', + 'Symfony\\Component\\DependencyInjection\\Container' => 'service_container', + 'Symfony\\Component\\DependencyInjection\\ContainerInterface' => 'service_container', 'alias_for_alias' => 'foo', 'alias_for_foo' => 'foo', ); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_compiled.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_compiled.php index 1fc6b8cea4..8c6d8a9535 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_compiled.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_compiled.php @@ -30,6 +30,11 @@ class ProjectServiceContainer extends Container $this->parameters = $this->getDefaultParameters(); $this->services = array(); + $this->normalizedIds = array( + 'psr\\container\\containerinterface' => 'Psr\\Container\\ContainerInterface', + 'symfony\\component\\dependencyinjection\\container' => 'Symfony\\Component\\DependencyInjection\\Container', + 'symfony\\component\\dependencyinjection\\containerinterface' => 'Symfony\\Component\\DependencyInjection\\ContainerInterface', + ); $this->methodMap = array( 'bar' => 'getBarService', 'baz' => 'getBazService', diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_dump_overriden_getters_with_constructor.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_dump_overriden_getters_with_constructor.php index b2acbe01c9..4329d9fdcd 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_dump_overriden_getters_with_constructor.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_dump_overriden_getters_with_constructor.php @@ -28,6 +28,11 @@ class Symfony_DI_PhpDumper_Test_Overriden_Getters_With_Constructor extends Conta public function __construct() { $this->services = array(); + $this->normalizedIds = array( + 'psr\\container\\containerinterface' => 'Psr\\Container\\ContainerInterface', + 'symfony\\component\\dependencyinjection\\container' => 'Symfony\\Component\\DependencyInjection\\Container', + 'symfony\\component\\dependencyinjection\\containerinterface' => 'Symfony\\Component\\DependencyInjection\\ContainerInterface', + ); $this->methodMap = array( 'baz' => 'getBazService', 'foo' => 'getFooService', diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_locator_argument.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_locator_argument.php index f7dd34fecf..9859d372bd 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_locator_argument.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_locator_argument.php @@ -28,6 +28,11 @@ class Symfony_DI_PhpDumper_Test_Locator_Argument_Provide_Service_Locator extends public function __construct() { $this->services = array(); + $this->normalizedIds = array( + 'psr\\container\\containerinterface' => 'Psr\\Container\\ContainerInterface', + 'symfony\\component\\dependencyinjection\\container' => 'Symfony\\Component\\DependencyInjection\\Container', + 'symfony\\component\\dependencyinjection\\containerinterface' => 'Symfony\\Component\\DependencyInjection\\ContainerInterface', + ); $this->methodMap = array( 'lazy_context' => 'getLazyContextService', 'lazy_referenced' => 'getLazyReferencedService', diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services1.xml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services1.xml index 6aa5732f9a..a2a601b6e9 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services1.xml +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services1.xml @@ -1,2 +1,9 @@ - + + + + + + + + diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services21.xml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services21.xml index 329bc3d72a..fc7d4a820a 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services21.xml +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services21.xml @@ -1,6 +1,7 @@ + @@ -17,5 +18,8 @@ + + + diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services24.xml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services24.xml index 9f01ead067..b8df053814 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services24.xml +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services24.xml @@ -1,6 +1,10 @@ + + + + diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services8.xml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services8.xml index b17e50043c..bd6237f942 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services8.xml +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services8.xml @@ -19,4 +19,10 @@ null + + + + + + diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services9.xml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services9.xml index 001a91ecd7..fee5a138ce 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services9.xml +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services9.xml @@ -6,6 +6,7 @@ bar + @@ -143,6 +144,9 @@ + + + diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services1.yml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services1.yml index 8b13789179..94ab237f32 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services1.yml +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services1.yml @@ -1 +1,13 @@ - +services: + service_container: + class: Symfony\Component\DependencyInjection\ContainerInterface + synthetic: true + Psr\Container\ContainerInterface: + alias: service_container + public: false + Symfony\Component\DependencyInjection\ContainerInterface: + alias: service_container + public: false + Symfony\Component\DependencyInjection\Container: + alias: service_container + public: false diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services24.yml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services24.yml index 174bee32f8..cf740d61b6 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services24.yml +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services24.yml @@ -1,5 +1,17 @@ services: + service_container: + class: Symfony\Component\DependencyInjection\ContainerInterface + synthetic: true foo: class: Foo autowire: true + Psr\Container\ContainerInterface: + alias: service_container + public: false + Symfony\Component\DependencyInjection\ContainerInterface: + alias: service_container + public: false + Symfony\Component\DependencyInjection\Container: + alias: service_container + public: false diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services8.yml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services8.yml index a1fb590358..d2e1943bf0 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services8.yml +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services8.yml @@ -5,3 +5,16 @@ parameters: escape: '@@escapeme' values: [true, false, null, 0, 1000.3, 'true', 'false', 'null'] +services: + service_container: + class: Symfony\Component\DependencyInjection\ContainerInterface + synthetic: true + Psr\Container\ContainerInterface: + alias: service_container + public: false + Symfony\Component\DependencyInjection\ContainerInterface: + alias: service_container + public: false + Symfony\Component\DependencyInjection\Container: + alias: service_container + public: false diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services9.yml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services9.yml index 2f0c363ff4..e7dcd28b6a 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services9.yml +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services9.yml @@ -4,6 +4,9 @@ parameters: foo: bar services: + service_container: + class: Symfony\Component\DependencyInjection\ContainerInterface + synthetic: true foo: class: Bar\FooClass tags: @@ -121,3 +124,12 @@ services: service_locator: class: Bar arguments: [!service_locator { bar: '@bar', invalid: '@?invalid', container: '@service_container' }] + Psr\Container\ContainerInterface: + alias: service_container + public: false + Symfony\Component\DependencyInjection\ContainerInterface: + alias: service_container + public: false + Symfony\Component\DependencyInjection\Container: + alias: service_container + public: false diff --git a/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php b/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php index 03391c938e..118d6a9d87 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php @@ -185,7 +185,7 @@ class XmlFileLoaderTest extends TestCase $loader = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml')); $loader->load('services5.xml'); $services = $container->getDefinitions(); - $this->assertCount(6, $services, '->load() attributes unique ids to anonymous services'); + $this->assertCount(7, $services, '->load() attributes unique ids to anonymous services'); // anonymous service as an argument $args = $services['foo']->getArguments(); @@ -485,11 +485,11 @@ class XmlFileLoaderTest extends TestCase $loader1 = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml/extension1')); $loader1->load('services.xml'); $services = $container->getDefinitions(); - $this->assertCount(2, $services, '->load() attributes unique ids to anonymous services'); + $this->assertCount(3, $services, '->load() attributes unique ids to anonymous services'); $loader2 = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml/extension2')); $loader2->load('services.xml'); $services = $container->getDefinitions(); - $this->assertCount(4, $services, '->load() attributes unique ids to anonymous services'); + $this->assertCount(5, $services, '->load() attributes unique ids to anonymous services'); $services = $container->getDefinitions(); $args1 = $services['extension1.foo']->getArguments(); @@ -632,7 +632,7 @@ class XmlFileLoaderTest extends TestCase $ids = array_keys($container->getDefinitions()); sort($ids); - $this->assertSame(array(Prototype\Foo::class, Prototype\Sub\Bar::class), $ids); + $this->assertSame(array(Prototype\Foo::class, Prototype\Sub\Bar::class, 'service_container'), $ids); $resources = $container->getResources(); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php b/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php index fa734e75ec..f73eca0111 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php @@ -397,7 +397,7 @@ class YamlFileLoaderTest extends TestCase $ids = array_keys($container->getDefinitions()); sort($ids); - $this->assertSame(array(Prototype\Foo::class, Prototype\Sub\Bar::class), $ids); + $this->assertSame(array(Prototype\Foo::class, Prototype\Sub\Bar::class, 'service_container'), $ids); $resources = $container->getResources();