@@ -60,6 +60,7 @@ public function process(ContainerBuilder $container)
60
60
$ analyzedContainer = $ container ;
61
61
}
62
62
try {
63
+ $ remainingInlinedIds = [];
63
64
$ this ->connectedIds = $ this ->notInlinedIds = $ container ->getDefinitions ();
64
65
do {
65
66
if ($ this ->analyzingPass ) {
@@ -83,8 +84,10 @@ public function process(ContainerBuilder $container)
83
84
}
84
85
}
85
86
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 {
88
91
$ container ->removeDefinition ($ id );
89
92
$ analyzedContainer ->removeDefinition ($ id );
90
93
}
@@ -94,6 +97,14 @@ public function process(ContainerBuilder $container)
94
97
if ($ this ->inlinedIds && $ this ->repeatedPass ) {
95
98
$ this ->repeatedPass ->setRepeat ();
96
99
}
100
+
101
+ foreach ($ remainingInlinedIds as $ id ) {
102
+ $ definition = $ container ->getDefinition ($ id );
103
+
104
+ if (!$ definition ->isShared () && !$ definition ->isPublic ()) {
105
+ $ container ->removeDefinition ($ id );
106
+ }
107
+ }
97
108
} finally {
98
109
$ this ->container = null ;
99
110
$ this ->connectedIds = $ this ->notInlinedIds = $ this ->inlinedIds = [];
@@ -131,7 +142,7 @@ protected function processValue($value, $isRoot = false)
131
142
}
132
143
133
144
$ 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 () ;
135
146
$ this ->notInlinedIds [$ this ->currentId ] = true ;
136
147
137
148
if ($ definition ->isShared ()) {
0 commit comments