Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d4844ef

Browse files
committed
bug #40872 [DependencyInjection] [AliasDeprecatedPublicServicesPass] Noop when the service is private (fancyweb)
This PR was merged into the 5.2 branch. Discussion ---------- [DependencyInjection] [AliasDeprecatedPublicServicesPass] Noop when the service is private | Q | A | ------------- | --- | Branch? | 5.2 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | - | License | MIT | Doc PR | - If the service is already private, I think we can just ignore the tag and do nothing. Moreover, when we deprecate a public service, if an user already sets its definition to private, it will be transparent instead of throwing. Commits ------- 00048a9 [DependencyInjection][AliasDeprecatedPublicServicesPass] Noop when the service is private
2 parents bf6e98c + 00048a9 commit d4844ef

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

src/Symfony/Component/DependencyInjection/Compiler/AliasDeprecatedPublicServicesPass.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public function process(ContainerBuilder $container)
5454

5555
$definition = $container->getDefinition($id);
5656
if (!$definition->isPublic() || $definition->isPrivate()) {
57-
throw new InvalidArgumentException(sprintf('The "%s" service is private: it cannot have the "%s" tag.', $id, $this->tagName));
57+
continue;
5858
}
5959

6060
$container

src/Symfony/Component/DependencyInjection/Tests/Compiler/AliasDeprecatedPublicServicesPassTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,14 +59,13 @@ public function processWithMissingAttributeProvider()
5959

6060
public function testProcessWithNonPublicService()
6161
{
62-
$this->expectException(InvalidArgumentException::class);
63-
$this->expectExceptionMessage('The "foo" service is private: it cannot have the "container.private" tag.');
64-
6562
$container = new ContainerBuilder();
6663
$container
6764
->register('foo')
6865
->addTag('container.private', ['package' => 'foo/bar', 'version' => '1.2']);
6966

7067
(new AliasDeprecatedPublicServicesPass())->process($container);
68+
69+
$this->assertTrue($container->hasDefinition('foo'));
7170
}
7271
}

0 commit comments

Comments
 (0)