This repository was archived by the owner on Feb 6, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +12
-7
lines changed Expand file tree Collapse file tree 1 file changed +12
-7
lines changed Original file line number Diff line number Diff line change @@ -253,21 +253,26 @@ public function build($name, array $options = null)
253
253
*/
254
254
public function has ($ name )
255
255
{
256
- $ name = $ this ->aliases [$ name ] ?? $ name ;
257
- $ found = isset ($ this ->services [$ name ]) || isset ($ this ->factories [$ name ]);
258
-
259
- if ($ found ) {
260
- return $ found ;
256
+ // Check services and factories first to speedup the most common requests
257
+ if (isset ($ this ->services [$ name ]) || isset ($ this ->factories [$ name ])) {
258
+ return true ;
261
259
}
262
260
263
- // Check abstract factories
261
+ // Check abstract factories next
264
262
foreach ($ this ->abstractFactories as $ abstractFactory ) {
265
263
if ($ abstractFactory ->canCreate ($ this ->creationContext , $ name )) {
266
264
return true ;
267
265
}
268
266
}
269
267
270
- return false ;
268
+ // If $name is no alias, we are done
269
+ if (! isset ($ this ->aliases [$ name ])) {
270
+ return false ;
271
+ }
272
+
273
+ // Finally check aliases
274
+ $ resolvedName = $ this ->aliases [$ name ];
275
+ return isset ($ this ->services [$ resolvedName ]) || isset ($ this ->factories [$ resolvedName ]);
271
276
}
272
277
273
278
/**
You can’t perform that action at this time.
0 commit comments