[DependencyInjection][AliasDeprecatedPublicServicesPass] Noop when the service is private

This commit is contained in:
Thomas Calvet 2021-04-19 18:05:59 +02:00
parent bf6e98c220
commit 00048a9c73
2 changed files with 3 additions and 4 deletions

View File

@ -54,7 +54,7 @@ final class AliasDeprecatedPublicServicesPass extends AbstractRecursivePass
$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

View File

@ -59,14 +59,13 @@ final class AliasDeprecatedPublicServicesPassTest extends TestCase
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'));
}
}