@@ -60,6 +60,7 @@ public function process(ContainerBuilder $container)
6060 $ analyzedContainer = $ container ;
6161 }
6262 try {
63+ $ remainingInlinedIds = [];
6364 $ this ->connectedIds = $ this ->notInlinedIds = $ container ->getDefinitions ();
6465 do {
6566 if ($ this ->analyzingPass ) {
@@ -83,8 +84,10 @@ public function process(ContainerBuilder $container)
8384 }
8485 }
8586
86- foreach ($ this ->inlinedIds as $ id => $ isPublic ) {
87- if (!$ isPublic ) {
87+ foreach ($ this ->inlinedIds as $ id => $ isPublicOrNotShared ) {
88+ if ($ isPublicOrNotShared ) {
89+ $ remainingInlinedIds [$ id ] = $ id ;
90+ } else {
8891 $ container ->removeDefinition ($ id );
8992 $ analyzedContainer ->removeDefinition ($ id );
9093 }
@@ -94,6 +97,14 @@ public function process(ContainerBuilder $container)
9497 if ($ this ->inlinedIds && $ this ->repeatedPass ) {
9598 $ this ->repeatedPass ->setRepeat ();
9699 }
100+
101+ foreach ($ remainingInlinedIds as $ id ) {
102+ $ definition = $ container ->getDefinition ($ id );
103+
104+ if (!$ definition ->isShared () && !$ definition ->isPublic ()) {
105+ $ container ->removeDefinition ($ id );
106+ }
107+ }
97108 } finally {
98109 $ this ->container = null ;
99110 $ this ->connectedIds = $ this ->notInlinedIds = $ this ->inlinedIds = [];
@@ -131,7 +142,7 @@ protected function processValue($value, $isRoot = false)
131142 }
132143
133144 $ this ->container ->log ($ this , sprintf ('Inlined service "%s" to "%s". ' , $ id , $ this ->currentId ));
134- $ this ->inlinedIds [$ id ] = $ definition ->isPublic ();
145+ $ this ->inlinedIds [$ id ] = $ definition ->isPublic () || ! $ definition -> isShared () ;
135146 $ this ->notInlinedIds [$ this ->currentId ] = true ;
136147
137148 if ($ definition ->isShared ()) {
0 commit comments