Skip to content

Commit f4b0975

Browse files
Merge branch '5.1' into 5.2
* 5.1: minor cs fix [Config][TwigBundle] Fixed syntax error in config [DI] Fix Xdebug 3.0 detection Use php8 stable [Notifier] Streamline changelogs of notifier bridges [Cache] fix checking for redis_sentinel support [Messenger] Fixed wording in php doc [Intl] Update the ICU data to 68.1 [FrameworkBundle] acces public-deprecated services via the private container to remove false-positive deprecations Remove unused @throws tags and handling of never thrown exceptions [PhpUnitBridge] Fix disabling DeprecationErrorHandler from phpunit configuration file
2 parents aeecee6 + f0cf800 commit f4b0975

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

DependencyInjection/Compiler/TestServiceContainerWeakRefPass.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@
2222
*/
2323
class TestServiceContainerWeakRefPass implements CompilerPassInterface
2424
{
25+
private $privateTagName;
26+
27+
public function __construct(string $privateTagName = 'container.private')
28+
{
29+
$this->privateTagName = $privateTagName;
30+
}
31+
2532
public function process(ContainerBuilder $container)
2633
{
2734
if (!$container->hasDefinition('test.private_services_locator')) {
@@ -33,7 +40,7 @@ public function process(ContainerBuilder $container)
3340
$hasErrors = method_exists(Definition::class, 'hasErrors') ? 'hasErrors' : 'getErrors';
3441

3542
foreach ($definitions as $id => $definition) {
36-
if ($id && '.' !== $id[0] && (!$definition->isPublic() || $definition->isPrivate()) && !$definition->$hasErrors() && !$definition->isAbstract()) {
43+
if ($id && '.' !== $id[0] && (!$definition->isPublic() || $definition->isPrivate() || $definition->hasTag($this->privateTagName)) && !$definition->$hasErrors() && !$definition->isAbstract()) {
3744
$privateServices[$id] = new Reference($id, ContainerBuilder::IGNORE_ON_UNINITIALIZED_REFERENCE);
3845
}
3946
}

Tests/DependencyInjection/Compiler/TestServiceContainerRefPassesTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ public function testProcess()
3636
->setPublic(true)
3737
->addArgument(new Reference('Test\private_used_shared_service'))
3838
->addArgument(new Reference('Test\private_used_non_shared_service'))
39+
->addArgument(new Reference('Test\soon_private_service'))
40+
;
41+
42+
$container->register('Test\soon_private_service')
43+
->setPublic(true)
44+
->addTag('container.private', ['package' => 'foo/bar', 'version' => '1.42'])
3945
;
4046

4147
$container->register('Test\private_used_shared_service');
@@ -48,6 +54,7 @@ public function testProcess()
4854
$expected = [
4955
'Test\private_used_shared_service' => new ServiceClosureArgument(new Reference('Test\private_used_shared_service')),
5056
'Test\private_used_non_shared_service' => new ServiceClosureArgument(new Reference('Test\private_used_non_shared_service')),
57+
'Test\soon_private_service' => new ServiceClosureArgument(new Reference('.container.private.Test\soon_private_service')),
5158
'Psr\Container\ContainerInterface' => new ServiceClosureArgument(new Reference('service_container')),
5259
'Symfony\Component\DependencyInjection\ContainerInterface' => new ServiceClosureArgument(new Reference('service_container')),
5360
];

0 commit comments

Comments
 (0)