File tree 3 files changed +13
-5
lines changed
src/Symfony/Bundle/FrameworkBundle
DependencyInjection/Compiler
3 files changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -27,13 +27,21 @@ public function process(ContainerBuilder $container)
27
27
}
28
28
29
29
$ testContainer = $ container ->getDefinition ('test.service_container ' );
30
- $ privateContainer = $ container ->getDefinition ((string ) $ testContainer ->getArgument (2 ));
30
+ $ privateContainer = $ testContainer ->getArgument (2 );
31
+ if ($ privateContainer instanceof Reference) {
32
+ $ privateContainer = $ container ->getDefinition ((string ) $ privateContainer );
33
+ }
31
34
$ definitions = $ container ->getDefinitions ();
35
+ $ privateServices = $ privateContainer ->getArgument (0 );
32
36
33
- foreach ($ privateContainer -> getArgument ( 0 ) as $ id => $ argument ) {
37
+ foreach ($ privateServices as $ id => $ argument ) {
34
38
if (isset ($ definitions [$ target = (string ) $ argument ->getValues ()[0 ]])) {
35
39
$ argument ->setValues (array (new Reference ($ target )));
40
+ } else {
41
+ unset($ privateServices [$ id ]);
36
42
}
37
43
}
44
+
45
+ $ privateContainer ->replaceArgument (0 , $ privateServices );
38
46
}
39
47
}
Original file line number Diff line number Diff line change @@ -31,15 +31,15 @@ public function process(ContainerBuilder $container)
31
31
$ definitions = $ container ->getDefinitions ();
32
32
33
33
foreach ($ definitions as $ id => $ definition ) {
34
- if ((!$ definition ->isPublic () || $ definition ->isPrivate ()) && !$ definition ->getErrors () && !$ definition ->isAbstract ()) {
34
+ if ($ id && ' . ' !== $ id [ 0 ] && (!$ definition ->isPublic () || $ definition ->isPrivate ()) && !$ definition ->getErrors () && !$ definition ->isAbstract ()) {
35
35
$ privateServices [$ id ] = new ServiceClosureArgument (new Reference ($ id , ContainerBuilder::IGNORE_ON_UNINITIALIZED_REFERENCE ));
36
36
}
37
37
}
38
38
39
39
$ aliases = $ container ->getAliases ();
40
40
41
41
foreach ($ aliases as $ id => $ alias ) {
42
- if (! $ alias ->isPublic () || $ alias ->isPrivate ()) {
42
+ if ($ id && ' . ' !== $ id [ 0 ] && (! $ alias ->isPublic () || $ alias ->isPrivate () )) {
43
43
while (isset ($ aliases [$ target = (string ) $ alias ])) {
44
44
$ alias = $ aliases [$ target ];
45
45
}
Original file line number Diff line number Diff line change @@ -42,6 +42,6 @@ public function testThatPrivateServicesAreAvailableIfTestConfigIsEnabled()
42
42
$ this ->assertTrue (static ::$ container ->has (NonPublicService::class));
43
43
$ this ->assertTrue (static ::$ container ->has (PrivateService::class));
44
44
$ this ->assertTrue (static ::$ container ->has ('private_service ' ));
45
- $ this ->assertTrue (static ::$ container ->has (UnusedPrivateService::class));
45
+ $ this ->assertFalse (static ::$ container ->has (UnusedPrivateService::class));
46
46
}
47
47
}
You can’t perform that action at this time.
0 commit comments