diff --git a/src/Symfony/Component/DependencyInjection/Container.php b/src/Symfony/Component/DependencyInjection/Container.php index 8e33a3260f..754cfb7568 100644 --- a/src/Symfony/Component/DependencyInjection/Container.php +++ b/src/Symfony/Component/DependencyInjection/Container.php @@ -50,6 +50,7 @@ class Container implements ResettableContainerInterface protected $aliases = array(); protected $loading = array(); protected $resolving = array(); + protected $syntheticIds = array(); /** * @internal @@ -179,31 +180,34 @@ class Container implements ResettableContainerInterface throw new InvalidArgumentException('You cannot set service "service_container".'); } - if (isset($this->aliases[$id])) { - unset($this->aliases[$id]); - } - - $wasSet = isset($this->services[$id]); - $this->services[$id] = $service; - - if (null === $service) { - unset($this->services[$id]); - } - - if (isset($this->privates[$id])) { - if (null === $service) { + if (isset($this->privates[$id]) || !(isset($this->fileMap[$id]) || isset($this->methodMap[$id]))) { + if (isset($this->syntheticIds[$id]) || (!isset($this->privates[$id]) && !isset($this->getRemovedIds()[$id]))) { + // no-op + } elseif (null === $service) { @trigger_error(sprintf('The "%s" service is private, unsetting it is deprecated since Symfony 3.2 and will fail in 4.0.', $id), E_USER_DEPRECATED); unset($this->privates[$id]); } else { @trigger_error(sprintf('The "%s" service is private, replacing it is deprecated since Symfony 3.2 and will fail in 4.0.', $id), E_USER_DEPRECATED); } - } elseif ($wasSet && (isset($this->fileMap[$id]) || isset($this->methodMap[$id]))) { + } elseif (isset($this->services[$id])) { if (null === $service) { @trigger_error(sprintf('The "%s" service is already initialized, unsetting it is deprecated since Symfony 3.3 and will fail in 4.0.', $id), E_USER_DEPRECATED); } else { @trigger_error(sprintf('The "%s" service is already initialized, replacing it is deprecated since Symfony 3.3 and will fail in 4.0.', $id), E_USER_DEPRECATED); } } + + if (isset($this->aliases[$id])) { + unset($this->aliases[$id]); + } + + if (null === $service) { + unset($this->services[$id]); + + return; + } + + $this->services[$id] = $service; } /** @@ -275,7 +279,7 @@ class Container implements ResettableContainerInterface // calling $this->normalizeId($id) unless necessary. for ($i = 2;;) { if (isset($this->privates[$id])) { - @trigger_error(sprintf('The "%s" service is private, getting it from the container is deprecated since Symfony 3.2 and will fail in 4.0. You should either make the service public, or stop getting services directly from the container and use dependency injection instead.', $id), E_USER_DEPRECATED); + @trigger_error(sprintf('The "%s" service is private, getting it from the container is deprecated since Symfony 3.2 and will fail in 4.0. You should either make the service public, or stop using the container directly and use dependency injection instead.', $id), E_USER_DEPRECATED); } if (isset($this->aliases[$id])) { $id = $this->aliases[$id]; @@ -325,6 +329,12 @@ class Container implements ResettableContainerInterface if (!$id) { throw new ServiceNotFoundException($id); } + if (isset($this->syntheticIds[$id])) { + throw new ServiceNotFoundException($id, null, null, array(), sprintf('The "%s" service is synthetic, it needs to be set at boot time before it can be used.', $id)); + } + if (isset($this->getRemovedIds()[$id])) { + throw new ServiceNotFoundException($id, null, null, array(), sprintf('The "%s" service or alias has been removed or inlined when the container was compiled. You should either make it public, or stop using the container directly and use dependency injection instead.', $id)); + } $alternatives = array(); foreach ($this->getServiceIds() as $knownId) { @@ -397,6 +407,16 @@ class Container implements ResettableContainerInterface return array_unique(array_merge($ids, array_keys($this->methodMap), array_keys($this->fileMap), array_keys($this->services))); } + /** + * Gets service ids that existed at compile time. + * + * @return array + */ + public function getRemovedIds() + { + return array(); + } + /** * Camelizes a string. * diff --git a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php index d46da389f0..17098f1e51 100644 --- a/src/Symfony/Component/DependencyInjection/ContainerBuilder.php +++ b/src/Symfony/Component/DependencyInjection/ContainerBuilder.php @@ -121,6 +121,8 @@ class ContainerBuilder extends Container implements TaggedContainerInterface private $autoconfiguredInstanceof = array(); + private $removedIds = array(); + public function __construct(ParameterBagInterface $parameterBag = null) { parent::__construct($parameterBag); @@ -517,7 +519,7 @@ class ContainerBuilder extends Container implements TaggedContainerInterface throw new BadMethodCallException(sprintf('Setting service "%s" for an unknown or non-synthetic service definition on a compiled container is not allowed.', $id)); } - unset($this->definitions[$id], $this->aliasDefinitions[$id]); + unset($this->definitions[$id], $this->aliasDefinitions[$id], $this->removedIds[$id]); parent::set($id, $service); } @@ -529,7 +531,10 @@ class ContainerBuilder extends Container implements TaggedContainerInterface */ public function removeDefinition($id) { - unset($this->definitions[$this->normalizeId($id)]); + if (isset($this->definitions[$id = $this->normalizeId($id)])) { + unset($this->definitions[$id]); + $this->removedIds[$id] = true; + } } /** @@ -793,6 +798,16 @@ class ContainerBuilder extends Container implements TaggedContainerInterface return array_unique(array_merge(array_keys($this->getDefinitions()), array_keys($this->aliasDefinitions), parent::getServiceIds())); } + /** + * Gets removed service or alias ids. + * + * @return array + */ + public function getRemovedIds() + { + return $this->removedIds; + } + /** * Adds the service aliases. * @@ -841,7 +856,7 @@ class ContainerBuilder extends Container implements TaggedContainerInterface throw new InvalidArgumentException(sprintf('An alias can not reference itself, got a circular reference on "%s".', $alias)); } - unset($this->definitions[$alias]); + unset($this->definitions[$alias], $this->removedIds[$alias]); return $this->aliasDefinitions[$alias] = $id; } @@ -853,7 +868,10 @@ class ContainerBuilder extends Container implements TaggedContainerInterface */ public function removeAlias($alias) { - unset($this->aliasDefinitions[$this->normalizeId($alias)]); + if (isset($this->aliasDefinitions[$alias = $this->normalizeId($alias)])) { + unset($this->aliasDefinitions[$alias]); + $this->removedIds[$alias] = true; + } } /** @@ -981,7 +999,7 @@ class ContainerBuilder extends Container implements TaggedContainerInterface $id = $this->normalizeId($id); - unset($this->aliasDefinitions[$id]); + unset($this->aliasDefinitions[$id], $this->removedIds[$id]); return $this->definitions[$id] = $definition; } diff --git a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php index c8a4d5cd3a..f12d813890 100644 --- a/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php +++ b/src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php @@ -172,6 +172,16 @@ use Symfony\Component\DependencyInjection\Argument\RewindableGenerator; EOF; $files = array(); + + if ($ids = array_keys($this->container->getRemovedIds())) { + sort($ids); + $c = "export($id)." => true,\n"; + } + $files['removed-ids.php'] = $c .= ");\n"; + } + foreach ($this->generateServiceFiles() as $file => $c) { $files[$file] = $fileStart.$c; } @@ -888,6 +898,7 @@ EOF; } $code .= $this->addNormalizedIds(); + $code .= $this->addSyntheticIds(); $code .= $this->addMethodMap(); $code .= $this->asFiles ? $this->addFileMap() : ''; $code .= $this->addPrivateServices(); @@ -896,6 +907,8 @@ EOF; } EOF; + $code .= $this->addRemovedIds(); + if ($this->container->isCompiled()) { $code .= <<normalizedIds = array(\n".$code." );\n" : ''; } + /** + * Adds the syntheticIds definition. + * + * @return string + */ + private function addSyntheticIds() + { + $code = ''; + $definitions = $this->container->getDefinitions(); + ksort($definitions); + foreach ($definitions as $id => $definition) { + if ($definition->isSynthetic() && 'service_container' !== $id) { + $code .= ' '.$this->export($id)." => true,\n"; + } + } + + return $code ? " \$this->syntheticIds = array(\n{$code} );\n" : ''; + } + + /** + * Adds the removedIds definition. + * + * @return string + */ + private function addRemovedIds() + { + if (!$ids = $this->container->getRemovedIds()) { + return ''; + } + if ($this->asFiles) { + $code = "require __DIR__.'/removed-ids.php'"; + } else { + $code = ''; + $ids = array_keys($ids); + sort($ids); + foreach ($ids as $id) { + $code .= ' '.$this->export($id)." => true,\n"; + } + + $code = "array(\n{$code} )"; + } + + return <<get('request'); } + /** + * @expectedException \Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException + * @expectedExceptionMessage The "inlined" service or alias has been removed or inlined when the container was compiled. You should either make it public, or stop using the container directly and use dependency injection instead. + */ + public function testGetRemovedServiceThrows() + { + require_once __DIR__.'/Fixtures/php/services9_compiled.php'; + + $container = new \ProjectServiceContainer(); + $container->get('inlined'); + } + public function testHas() { $sc = new ProjectServiceContainer(); @@ -505,7 +517,7 @@ class ContainerTest extends TestCase /** * @group legacy - * @expectedDeprecation The "internal" service is private, getting it from the container is deprecated since Symfony 3.2 and will fail in 4.0. You should either make the service public, or stop getting services directly from the container and use dependency injection instead. + * @expectedDeprecation The "internal" service is private, getting it from the container is deprecated since Symfony 3.2 and will fail in 4.0. You should either make the service public, or stop using the container directly and use dependency injection instead. */ public function testRequestAnInternalSharedPrivateServiceIsDeprecated() { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php b/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php index bda74490c9..014ce3c16f 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php @@ -287,37 +287,17 @@ class PhpDumperTest extends TestCase /** * @group legacy - * @expectedDeprecation The "bar" service is already initialized, replacing it is deprecated since Symfony 3.3 and will fail in 4.0. + * @expectedDeprecation The "decorator_service" service is already initialized, replacing it is deprecated since Symfony 3.3 and will fail in 4.0. */ public function testOverrideServiceWhenUsingADumpedContainer() { - require_once self::$fixturesPath.'/php/services9.php'; - require_once self::$fixturesPath.'/includes/foo.php'; + require_once self::$fixturesPath.'/php/services9_compiled.php'; $container = new \ProjectServiceContainer(); - $container->setParameter('foo_bar', 'foo_bar'); - $container->get('bar'); - $container->set('bar', $bar = new \stdClass()); + $container->get('decorator_service'); + $container->set('decorator_service', $decorator = new \stdClass()); - $this->assertSame($bar, $container->get('bar'), '->set() overrides an already defined service'); - } - - /** - * @group legacy - * @expectedDeprecation The "bar" service is already initialized, replacing it is deprecated since Symfony 3.3 and will fail in 4.0. - */ - public function testOverrideServiceWhenUsingADumpedContainerAndServiceIsUsedFromAnotherOne() - { - require_once self::$fixturesPath.'/php/services9.php'; - require_once self::$fixturesPath.'/includes/foo.php'; - require_once self::$fixturesPath.'/includes/classes.php'; - - $container = new \ProjectServiceContainer(); - $container->setParameter('foo_bar', 'foo_bar'); - $container->get('bar'); - $container->set('bar', $bar = new \stdClass()); - - $this->assertSame($bar, $container->get('foo')->bar, '->set() overrides an already defined service'); + $this->assertSame($decorator, $container->get('decorator_service'), '->set() overrides an already defined service'); } /** @@ -799,14 +779,14 @@ class PhpDumperTest extends TestCase /** * @group legacy - * @expectedDeprecation The "private" service is private, getting it from the container is deprecated since Symfony 3.2 and will fail in 4.0. You should either make the service public, or stop getting services directly from the container and use dependency injection instead. - * @expectedDeprecation The "private_alias" service is private, getting it from the container is deprecated since Symfony 3.2 and will fail in 4.0. You should either make the service public, or stop getting services directly from the container and use dependency injection instead. - * @expectedDeprecation The "decorated_private" service is private, getting it from the container is deprecated since Symfony 3.2 and will fail in 4.0. You should either make the service public, or stop getting services directly from the container and use dependency injection instead. - * @expectedDeprecation The "decorated_private_alias" service is private, getting it from the container is deprecated since Symfony 3.2 and will fail in 4.0. You should either make the service public, or stop getting services directly from the container and use dependency injection instead. - * @expectedDeprecation The "private_not_inlined" service is private, getting it from the container is deprecated since Symfony 3.2 and will fail in 4.0. You should either make the service public, or stop getting services directly from the container and use dependency injection instead. - * @expectedDeprecation The "private_not_removed" service is private, getting it from the container is deprecated since Symfony 3.2 and will fail in 4.0. You should either make the service public, or stop getting services directly from the container and use dependency injection instead. - * @expectedDeprecation The "private_child" service is private, getting it from the container is deprecated since Symfony 3.2 and will fail in 4.0. You should either make the service public, or stop getting services directly from the container and use dependency injection instead. - * @expectedDeprecation The "private_parent" service is private, getting it from the container is deprecated since Symfony 3.2 and will fail in 4.0. You should either make the service public, or stop getting services directly from the container and use dependency injection instead. + * @expectedDeprecation The "private" service is private, getting it from the container is deprecated since Symfony 3.2 and will fail in 4.0. You should either make the service public, or stop using the container directly and use dependency injection instead. + * @expectedDeprecation The "private_alias" service is private, getting it from the container is deprecated since Symfony 3.2 and will fail in 4.0. You should either make the service public, or stop using the container directly and use dependency injection instead. + * @expectedDeprecation The "decorated_private" service is private, getting it from the container is deprecated since Symfony 3.2 and will fail in 4.0. You should either make the service public, or stop using the container directly and use dependency injection instead. + * @expectedDeprecation The "decorated_private_alias" service is private, getting it from the container is deprecated since Symfony 3.2 and will fail in 4.0. You should either make the service public, or stop using the container directly and use dependency injection instead. + * @expectedDeprecation The "private_not_inlined" service is private, getting it from the container is deprecated since Symfony 3.2 and will fail in 4.0. You should either make the service public, or stop using the container directly and use dependency injection instead. + * @expectedDeprecation The "private_not_removed" service is private, getting it from the container is deprecated since Symfony 3.2 and will fail in 4.0. You should either make the service public, or stop using the container directly and use dependency injection instead. + * @expectedDeprecation The "private_child" service is private, getting it from the container is deprecated since Symfony 3.2 and will fail in 4.0. You should either make the service public, or stop using the container directly and use dependency injection instead. + * @expectedDeprecation The "private_parent" service is private, getting it from the container is deprecated since Symfony 3.2 and will fail in 4.0. You should either make the service public, or stop using the container directly and use dependency injection instead. */ public function testLegacyPrivateServices() { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/config/services9.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/config/services9.php index 3f4d5f15ea..b013e5126d 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/config/services9.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/config/services9.php @@ -40,9 +40,6 @@ return function (ContainerConfigurator $c) { ->args(array(ref('deprecated_service'))) ->share(false); - $s->alias('alias_for_foo', 'foo')->private()->public(); - $s->alias('alias_for_alias', ref('alias_for_foo')); - $s->set('method_call1', 'Bar\FooClass') ->file(realpath(__DIR__.'/../includes/foo.php')) ->call('setBar', array(ref('foo'))) @@ -125,4 +122,7 @@ return function (ContainerConfigurator $c) { $s->set('tagged_iterator', 'Bar') ->public() ->args(array(tagged('foo'))); + + $s->alias('alias_for_foo', 'foo')->private()->public(); + $s->alias('alias_for_alias', ref('alias_for_foo')); }; diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/container9.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/container9.php index 452dab6d80..21d35611c3 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/container9.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/container9.php @@ -48,8 +48,6 @@ $container->getParameterBag()->add(array( 'foo_class' => 'Bar\FooClass', 'foo' => 'bar', )); -$container->setAlias('alias_for_foo', 'foo')->setPublic(true); -$container->setAlias('alias_for_alias', 'alias_for_foo')->setPublic(true); $container ->register('method_call1', 'Bar\FooClass') ->setFile(realpath(__DIR__.'/../includes/foo.php')) @@ -172,5 +170,7 @@ $container ->addArgument(new TaggedIteratorArgument('foo')) ->setPublic(true) ; +$container->setAlias('alias_for_foo', 'foo')->setPublic(true); +$container->setAlias('alias_for_alias', 'alias_for_foo')->setPublic(true); return $container; 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 e696dec6ae..349358c384 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1-1.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1-1.php @@ -28,6 +28,14 @@ class Container extends AbstractContainer $this->aliases = array(); } + public function getRemovedIds() + { + return array( + 'Psr\\Container\\ContainerInterface' => true, + 'Symfony\\Component\\DependencyInjection\\ContainerInterface' => true, + ); + } + public function compile() { throw new LogicException('You cannot compile a dumped container that was already compiled.'); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1.php index c339856f02..8d7aab16c7 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services1.php @@ -26,6 +26,14 @@ class ProjectServiceContainer extends Container $this->aliases = array(); } + public function getRemovedIds() + { + return array( + 'Psr\\Container\\ContainerInterface' => true, + 'Symfony\\Component\\DependencyInjection\\ContainerInterface' => true, + ); + } + public function compile() { throw new LogicException('You cannot compile a dumped container that was already compiled.'); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services10.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services10.php index 219cf3431b..bfd6587a4e 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services10.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services10.php @@ -31,6 +31,14 @@ class ProjectServiceContainer extends Container $this->aliases = array(); } + public function getRemovedIds() + { + return array( + 'Psr\\Container\\ContainerInterface' => true, + 'Symfony\\Component\\DependencyInjection\\ContainerInterface' => true, + ); + } + public function compile() { throw new LogicException('You cannot compile a dumped container that was already compiled.'); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services12.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services12.php index 2bd134a9f8..c5c434ec7d 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services12.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services12.php @@ -35,6 +35,14 @@ class ProjectServiceContainer extends Container $this->aliases = array(); } + public function getRemovedIds() + { + return array( + 'Psr\\Container\\ContainerInterface' => true, + 'Symfony\\Component\\DependencyInjection\\ContainerInterface' => true, + ); + } + public function compile() { throw new LogicException('You cannot compile a dumped container that was already compiled.'); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services13.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services13.php index 4cc353ca27..577e0221d0 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services13.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services13.php @@ -29,6 +29,15 @@ class ProjectServiceContainer extends Container $this->aliases = array(); } + public function getRemovedIds() + { + return array( + 'Psr\\Container\\ContainerInterface' => true, + 'Symfony\\Component\\DependencyInjection\\ContainerInterface' => true, + 'foo' => true, + ); + } + public function compile() { throw new LogicException('You cannot compile a dumped container that was already compiled.'); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services19.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services19.php index 0a6b97e65d..0b2682420f 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services19.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services19.php @@ -30,6 +30,14 @@ class ProjectServiceContainer extends Container $this->aliases = array(); } + public function getRemovedIds() + { + return array( + 'Psr\\Container\\ContainerInterface' => true, + 'Symfony\\Component\\DependencyInjection\\ContainerInterface' => true, + ); + } + public function compile() { throw new LogicException('You cannot compile a dumped container that was already compiled.'); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services24.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services24.php index 7546b1765a..02a7a1b0c2 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services24.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services24.php @@ -29,6 +29,14 @@ class ProjectServiceContainer extends Container $this->aliases = array(); } + public function getRemovedIds() + { + return array( + 'Psr\\Container\\ContainerInterface' => true, + 'Symfony\\Component\\DependencyInjection\\ContainerInterface' => true, + ); + } + public function compile() { throw new LogicException('You cannot compile a dumped container that was already compiled.'); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services26.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services26.php index 7dc51d12af..6519a9dff7 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services26.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services26.php @@ -35,6 +35,14 @@ class Symfony_DI_PhpDumper_Test_EnvParameters extends Container $this->aliases = array(); } + public function getRemovedIds() + { + return array( + 'Psr\\Container\\ContainerInterface' => true, + 'Symfony\\Component\\DependencyInjection\\ContainerInterface' => true, + ); + } + public function compile() { throw new LogicException('You cannot compile a dumped container that was already compiled.'); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services33.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services33.php index e36cdcaedb..1a8b3f0c52 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services33.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services33.php @@ -34,6 +34,14 @@ class ProjectServiceContainer extends Container $this->aliases = array(); } + public function getRemovedIds() + { + return array( + 'Psr\\Container\\ContainerInterface' => true, + 'Symfony\\Component\\DependencyInjection\\ContainerInterface' => true, + ); + } + public function compile() { throw new LogicException('You cannot compile a dumped container that was already compiled.'); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services8.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services8.php index 357b8aa697..8db48ade93 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services8.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services8.php @@ -28,6 +28,14 @@ class ProjectServiceContainer extends Container $this->aliases = array(); } + public function getRemovedIds() + { + return array( + 'Psr\\Container\\ContainerInterface' => true, + 'Symfony\\Component\\DependencyInjection\\ContainerInterface' => true, + ); + } + public function compile() { throw new LogicException('You cannot compile a dumped container that was already compiled.'); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9.php index b05b886871..30b94d456e 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9.php @@ -26,6 +26,9 @@ class ProjectServiceContainer extends Container 'psr\\container\\containerinterface' => 'Psr\\Container\\ContainerInterface', 'symfony\\component\\dependencyinjection\\containerinterface' => 'Symfony\\Component\\DependencyInjection\\ContainerInterface', ); + $this->syntheticIds = array( + 'request' => true, + ); $this->methodMap = array( 'bar' => 'getBarService', 'baz' => 'getBazService', diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_as_files.txt b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_as_files.txt index 3795ade480..83074c984e 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_as_files.txt +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_as_files.txt @@ -1,5 +1,18 @@ Array ( + [Container%s/removed-ids.php] => true, + 'Symfony\\Component\\DependencyInjection\\ContainerInterface' => true, + 'configurator_service' => true, + 'configurator_service_simple' => true, + 'decorated.pif-pouf' => true, + 'decorator_service.inner' => true, + 'inlined' => true, + 'new_factory' => true, +); + [Container%s/getBarService.php] => parameters = $this->getDefaultParameters(); $this->services = array(); + $this->syntheticIds = array( + 'request' => true, + ); $this->methodMap = array( 'foo_bar' => 'getFooBarService', ); @@ -322,6 +338,11 @@ class Container%s extends Container ); } + public function getRemovedIds() + { + return require __DIR__.'/removed-ids.php'; + } + public function compile() { throw new LogicException('You cannot compile a dumped container that was already compiled.'); 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 7ec609ca5e..403eb12954 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_compiled.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services9_compiled.php @@ -24,6 +24,9 @@ class ProjectServiceContainer extends Container $this->parameters = $this->getDefaultParameters(); $this->services = array(); + $this->syntheticIds = array( + 'request' => true, + ); $this->methodMap = array( 'bar' => 'getBarService', 'baz' => 'getBazService', @@ -58,6 +61,20 @@ class ProjectServiceContainer extends Container ); } + public function getRemovedIds() + { + return array( + 'Psr\\Container\\ContainerInterface' => true, + 'Symfony\\Component\\DependencyInjection\\ContainerInterface' => true, + 'configurator_service' => true, + 'configurator_service_simple' => true, + 'decorated.pif-pouf' => true, + 'decorator_service.inner' => true, + 'inlined' => true, + 'new_factory' => true, + ); + } + public function compile() { throw new LogicException('You cannot compile a dumped container that was already compiled.'); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_array_params.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_array_params.php index e5159861b4..65e6b61e34 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_array_params.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_array_params.php @@ -35,6 +35,14 @@ class ProjectServiceContainer extends Container $this->aliases = array(); } + public function getRemovedIds() + { + return array( + 'Psr\\Container\\ContainerInterface' => true, + 'Symfony\\Component\\DependencyInjection\\ContainerInterface' => true, + ); + } + public function compile() { throw new LogicException('You cannot compile a dumped container that was already compiled.'); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_base64_env.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_base64_env.php index 8513e25d2e..d796c0dae6 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_base64_env.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_base64_env.php @@ -28,6 +28,14 @@ class Symfony_DI_PhpDumper_Test_Base64Parameters extends Container $this->aliases = array(); } + public function getRemovedIds() + { + return array( + 'Psr\\Container\\ContainerInterface' => true, + 'Symfony\\Component\\DependencyInjection\\ContainerInterface' => true, + ); + } + public function compile() { throw new LogicException('You cannot compile a dumped container that was already compiled.'); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_legacy_privates.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_legacy_privates.php index fad546d7fc..f8c33ae599 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_legacy_privates.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_legacy_privates.php @@ -55,6 +55,17 @@ class Symfony_DI_PhpDumper_Test_Legacy_Privates extends Container ); } + public function getRemovedIds() + { + return array( + 'Psr\\Container\\ContainerInterface' => true, + 'Symfony\\Component\\DependencyInjection\\ContainerInterface' => true, + 'foo' => true, + 'private_alias_decorator.inner' => true, + 'private_decorator.inner' => true, + ); + } + public function compile() { throw new LogicException('You cannot compile a dumped container that was already compiled.'); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_locator.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_locator.php index 74e2a8ce09..339076ea3b 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_locator.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_locator.php @@ -40,6 +40,17 @@ class ProjectServiceContainer extends Container $this->aliases = array(); } + public function getRemovedIds() + { + return array( + 'Psr\\Container\\ContainerInterface' => true, + 'Symfony\\Component\\DependencyInjection\\ContainerInterface' => true, + 'translator.loader_1_locator' => true, + 'translator.loader_2_locator' => true, + 'translator.loader_3_locator' => true, + ); + } + public function compile() { throw new LogicException('You cannot compile a dumped container that was already compiled.'); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_private_frozen.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_private_frozen.php index c7ea243ae8..59857ecac3 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_private_frozen.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_private_frozen.php @@ -34,6 +34,14 @@ class ProjectServiceContainer extends Container $this->aliases = array(); } + public function getRemovedIds() + { + return array( + 'Psr\\Container\\ContainerInterface' => true, + 'Symfony\\Component\\DependencyInjection\\ContainerInterface' => true, + ); + } + public function compile() { throw new LogicException('You cannot compile a dumped container that was already compiled.'); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_private_in_expression.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_private_in_expression.php index 8269736c0b..70af6ce7e3 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_private_in_expression.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_private_in_expression.php @@ -33,6 +33,15 @@ class ProjectServiceContainer extends Container $this->aliases = array(); } + public function getRemovedIds() + { + return array( + 'Psr\\Container\\ContainerInterface' => true, + 'Symfony\\Component\\DependencyInjection\\ContainerInterface' => true, + 'private_bar' => true, + ); + } + public function compile() { throw new LogicException('You cannot compile a dumped container that was already compiled.'); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_rot13_env.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_rot13_env.php index 3b26928577..d888187bf5 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_rot13_env.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_rot13_env.php @@ -35,6 +35,14 @@ class Symfony_DI_PhpDumper_Test_Rot13Parameters extends Container $this->aliases = array(); } + public function getRemovedIds() + { + return array( + 'Psr\\Container\\ContainerInterface' => true, + 'Symfony\\Component\\DependencyInjection\\ContainerInterface' => true, + ); + } + public function compile() { throw new LogicException('You cannot compile a dumped container that was already compiled.'); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_subscriber.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_subscriber.php index a4ab454e3e..76d87489a9 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_subscriber.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_subscriber.php @@ -38,6 +38,15 @@ class ProjectServiceContainer extends Container $this->aliases = array(); } + public function getRemovedIds() + { + return array( + 'Psr\\Container\\ContainerInterface' => true, + 'Symfony\\Component\\DependencyInjection\\ContainerInterface' => true, + 'service_locator.jmktfsv' => true, + ); + } + public function compile() { throw new LogicException('You cannot compile a dumped container that was already compiled.'); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_uninitialized_ref.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_uninitialized_ref.php index c47e7c15d1..df5a40c839 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_uninitialized_ref.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/php/services_uninitialized_ref.php @@ -35,6 +35,15 @@ class Symfony_DI_PhpDumper_Test_Uninitialized_Reference extends Container $this->aliases = array(); } + public function getRemovedIds() + { + return array( + 'Psr\\Container\\ContainerInterface' => true, + 'Symfony\\Component\\DependencyInjection\\ContainerInterface' => true, + 'foo2' => true, + ); + } + public function compile() { throw new LogicException('You cannot compile a dumped container that was already compiled.'); diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services6.xml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services6.xml index 5134ff7671..cffd5df605 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services6.xml +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/xml/services6.xml @@ -43,8 +43,6 @@ - - @@ -61,5 +59,7 @@ + + diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services6.yml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services6.yml index bfc995d44e..1ee6c6ec74 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services6.yml +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services6.yml @@ -17,16 +17,10 @@ services: class: FooClass calls: - [ setBar, [ foo, '@foo', [true, false] ] ] - alias_for_foo: '@foo' - another_alias_for_foo: - alias: foo - public: false request: class: Request synthetic: true lazy: true - another_third_alias_for_foo: - alias: foo decorator_service: decorates: decorated decorator_service_with_name: @@ -41,3 +35,9 @@ services: new_factory3: { class: FooBarClass, factory: [BazClass, getInstance]} new_factory4: { class: BazClass, factory: [~, getInstance]} Acme\WithShortCutArgs: [foo, '@baz'] + alias_for_foo: '@foo' + another_alias_for_foo: + alias: foo + public: false + another_third_alias_for_foo: + alias: foo diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services9.yml b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services9.yml index cf713d189e..2501ddcc1b 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services9.yml +++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/yaml/services9.yml @@ -139,12 +139,6 @@ services: class: LazyContext arguments: [!iterator ['@foo.baz', '@?invalid'], !iterator []] public: true - alias_for_foo: - alias: 'foo' - public: true - alias_for_alias: - alias: 'foo' - public: true tagged_iterator_foo: class: Bar tags: @@ -161,3 +155,9 @@ services: Symfony\Component\DependencyInjection\ContainerInterface: alias: service_container public: false + alias_for_foo: + alias: 'foo' + public: true + alias_for_alias: + alias: 'foo' + public: true