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 +13
-6
lines changed Expand file tree Collapse file tree 1 file changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -248,20 +248,27 @@ public function build($name, array $options = null)
248
248
*/
249
249
public function has ($ name )
250
250
{
251
- $ name = $ this ->resolvedAliases [$ name ] ?? $ name ;
252
- $ found = isset ($ this ->services [$ name ]) || isset ($ this ->factories [$ name ]);
253
-
254
- if ($ found ) {
255
- return $ found ;
251
+ // Check services and factories first to speedup the most common requests
252
+ if (isset ($ this ->services [$ name ]) || isset ($ this ->factories [$ name ])) {
253
+ return true ;
256
254
}
257
255
258
- // Check abstract factories
256
+ // Check abstract factories next
259
257
foreach ($ this ->abstractFactories as $ abstractFactory ) {
260
258
if ($ abstractFactory ->canCreate ($ this ->creationContext , $ name )) {
261
259
return true ;
262
260
}
263
261
}
264
262
263
+ // If $name is no alias, we are done
264
+ if (! isset ($ this ->resolvedAliases [$ name ])) {
265
+ return false ;
266
+ }
267
+
268
+ // Finally check aliases
269
+ $ name = $ this ->resolvedAliases [$ name ];
270
+ return isset ($ this ->services [$ name ]) || isset ($ this ->factories [$ name ]);
271
+
265
272
return false ;
266
273
}
267
274
You can’t perform that action at this time.
0 commit comments