diff --git a/src/Symfony/Component/DependencyInjection/Compiler/AliasDeprecatedPublicServicesPass.php b/src/Symfony/Component/DependencyInjection/Compiler/AliasDeprecatedPublicServicesPass.php index 802c40766212f..a44767de3ab6c 100644 --- a/src/Symfony/Component/DependencyInjection/Compiler/AliasDeprecatedPublicServicesPass.php +++ b/src/Symfony/Component/DependencyInjection/Compiler/AliasDeprecatedPublicServicesPass.php @@ -54,7 +54,7 @@ public function process(ContainerBuilder $container) $definition = $container->getDefinition($id); if (!$definition->isPublic() || $definition->isPrivate()) { - throw new InvalidArgumentException(sprintf('The "%s" service is private: it cannot have the "%s" tag.', $id, $this->tagName)); + continue; } $container diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/AliasDeprecatedPublicServicesPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/AliasDeprecatedPublicServicesPassTest.php index b1f13ddb29d5d..d03ece235afcc 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/AliasDeprecatedPublicServicesPassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/AliasDeprecatedPublicServicesPassTest.php @@ -59,14 +59,13 @@ public function processWithMissingAttributeProvider() public function testProcessWithNonPublicService() { - $this->expectException(InvalidArgumentException::class); - $this->expectExceptionMessage('The "foo" service is private: it cannot have the "container.private" tag.'); - $container = new ContainerBuilder(); $container ->register('foo') ->addTag('container.private', ['package' => 'foo/bar', 'version' => '1.2']); (new AliasDeprecatedPublicServicesPass())->process($container); + + $this->assertTrue($container->hasDefinition('foo')); } }