File tree Expand file tree Collapse file tree 1 file changed +11
-14
lines changed Expand file tree Collapse file tree 1 file changed +11
-14
lines changed Original file line number Diff line number Diff line change @@ -217,21 +217,18 @@ public function has($id)
217
217
*/
218
218
public function get ($ id , $ invalidBehavior = /* self::EXCEPTION_ON_INVALID_REFERENCE */ 1 )
219
219
{
220
- if (isset ($ this ->aliases [$ id ])) {
221
- $ id = $ this ->aliases [$ id ];
222
- }
223
-
224
- // Re-use shared service instance if it exists.
225
- if (isset ($ this ->services [$ id ])) {
226
- return $ this ->services [$ id ];
227
- }
228
- if ('service_container ' === $ id ) {
229
- return $ this ;
230
- }
231
- if (isset ($ this ->factories [$ id ])) {
232
- return $ this ->factories [$ id ]();
233
- }
220
+ return $ this ->services [$ id ]
221
+ ?? $ this ->services [$ id = $ this ->aliases [$ id ] ?? $ id ]
222
+ ?? ('service_container ' === $ id ? $ this : ($ this ->factories [$ id ] ?? array ($ this , 'make ' ))($ id , $ invalidBehavior ));
223
+ }
234
224
225
+ /**
226
+ * Creates a service.
227
+ *
228
+ * As a separate method to allow "get()" to use the really fast `??` operator.
229
+ */
230
+ private function make (string $ id , int $ invalidBehavior )
231
+ {
235
232
if (isset ($ this ->loading [$ id ])) {
236
233
throw new ServiceCircularReferenceException ($ id , array_keys ($ this ->loading ));
237
234
}
You can’t perform that action at this time.
0 commit comments