@@ -216,7 +216,8 @@ public function getByType($type, $throw = false)
216
216
{
217
217
$ type = Helpers::normalizeClass ($ type );
218
218
219
- if ($ this ->currentService !== null
219
+ if (
220
+ $ this ->currentService !== null
220
221
&& is_a ($ this ->definitions [$ this ->currentService ]->getType (), $ type , true )
221
222
) {
222
223
return $ this ->currentService ;
@@ -337,7 +338,8 @@ public function prepareClassList()
337
338
}
338
339
339
340
// auto-disable autowiring for aliases
340
- if ($ def ->getAutowired () === true
341
+ if (
342
+ $ def ->getAutowired () === true
341
343
&& ($ alias = $ this ->getServiceName ($ def ->getFactory ()->getEntity ()))
342
344
&& (!$ def ->getImplement () || (!Strings::contains ($ alias , '\\' ) && $ this ->definitions [$ alias ]->getImplement ()))
343
345
) {
@@ -438,7 +440,8 @@ private function resolveImplement(ServiceDefinition $def, $name)
438
440
if (!$ def ->getEntity ()) {
439
441
$ def ->setFactory ($ def ->getType (), $ def ->getFactory () ? $ def ->getFactory ()->arguments : []);
440
442
}
441
- if (($ class = $ this ->resolveEntityType ($ def ->getFactory (), [$ name => 1 ]))
443
+ if (
444
+ ($ class = $ this ->resolveEntityType ($ def ->getFactory (), [$ name => 1 ]))
442
445
&& ($ ctor = (new ReflectionClass ($ class ))->getConstructor ())
443
446
) {
444
447
foreach ($ ctor ->getParameters () as $ param ) {
@@ -657,9 +660,10 @@ public function completeStatement(Statement $statement)
657
660
if (!$ arguments && substr ($ entity [1 ], -2 ) === '[] ' ) {
658
661
throw new ServiceCreationException ("Missing argument for $ entity [1 ]. " );
659
662
}
660
- } elseif ($ type = empty ($ service ) || $ entity [1 ] === 'create '
661
- ? $ this ->resolveEntityType ($ entity [0 ])
662
- : $ this ->definitions [$ service ]->getType ()
663
+ } elseif (
664
+ $ type = empty ($ service ) || $ entity [1 ] === 'create '
665
+ ? $ this ->resolveEntityType ($ entity [0 ])
666
+ : $ this ->definitions [$ service ]->getType ()
663
667
) {
664
668
$ arguments = $ this ->autowireArguments ($ type , $ entity [1 ], $ arguments );
665
669
}
0 commit comments