@@ -519,19 +519,28 @@ public function specifyTypesInCondition(
519
519
$ methodReflection = $ scope ->getMethodReflection ($ methodCalledOnType , $ expr ->name ->name );
520
520
if ($ methodReflection !== null ) {
521
521
$ referencedClasses = $ methodCalledOnType ->getObjectClassNames ();
522
- if (
523
- count ($ referencedClasses ) === 1
524
- && $ this ->reflectionProvider ->hasClass ($ referencedClasses [0 ])
525
- ) {
526
- $ methodClassReflection = $ this ->reflectionProvider ->getClass ($ referencedClasses [0 ]);
522
+ $ specifiedTypes = null ;
523
+ foreach ($ referencedClasses as $ referencedClass ) {
524
+ if (!$ this ->reflectionProvider ->hasClass ($ referencedClass )) {
525
+ continue ;
526
+ }
527
+
528
+ $ methodClassReflection = $ this ->reflectionProvider ->getClass ($ referencedClass );
527
529
foreach ($ this ->getMethodTypeSpecifyingExtensionsForClass ($ methodClassReflection ->getName ()) as $ extension ) {
528
530
if (!$ extension ->isMethodSupported ($ methodReflection , $ expr , $ context )) {
529
531
continue ;
530
532
}
531
533
532
- return $ extension ->specifyTypes ($ methodReflection , $ expr , $ scope , $ context );
534
+ if ($ specifiedTypes !== null ) {
535
+ $ specifiedTypes = $ specifiedTypes ->unionWith ($ extension ->specifyTypes ($ methodReflection , $ expr , $ scope , $ context ));
536
+ } else {
537
+ $ specifiedTypes = $ extension ->specifyTypes ($ methodReflection , $ expr , $ scope , $ context );
538
+ }
533
539
}
534
540
}
541
+ if ($ specifiedTypes !== null ) {
542
+ return $ specifiedTypes ;
543
+ }
535
544
536
545
// lazy create parametersAcceptor, as creation can be expensive
537
546
$ parametersAcceptor = null ;
@@ -572,19 +581,28 @@ public function specifyTypesInCondition(
572
581
$ staticMethodReflection = $ scope ->getMethodReflection ($ calleeType , $ expr ->name ->name );
573
582
if ($ staticMethodReflection !== null ) {
574
583
$ referencedClasses = $ calleeType ->getObjectClassNames ();
575
- if (
576
- count ($ referencedClasses ) === 1
577
- && $ this ->reflectionProvider ->hasClass ($ referencedClasses [0 ])
578
- ) {
579
- $ staticMethodClassReflection = $ this ->reflectionProvider ->getClass ($ referencedClasses [0 ]);
584
+ $ specifiedTypes = null ;
585
+ foreach ($ referencedClasses as $ referencedClass ) {
586
+ if (!$ this ->reflectionProvider ->hasClass ($ referencedClass )) {
587
+ continue ;
588
+ }
589
+
590
+ $ staticMethodClassReflection = $ this ->reflectionProvider ->getClass ($ referencedClass );
580
591
foreach ($ this ->getStaticMethodTypeSpecifyingExtensionsForClass ($ staticMethodClassReflection ->getName ()) as $ extension ) {
581
592
if (!$ extension ->isStaticMethodSupported ($ staticMethodReflection , $ expr , $ context )) {
582
593
continue ;
583
594
}
584
595
585
- return $ extension ->specifyTypes ($ staticMethodReflection , $ expr , $ scope , $ context );
596
+ if ($ specifiedTypes !== null ) {
597
+ $ specifiedTypes = $ specifiedTypes ->unionWith ($ extension ->specifyTypes ($ staticMethodReflection , $ expr , $ scope , $ context ));
598
+ } else {
599
+ $ specifiedTypes = $ extension ->specifyTypes ($ staticMethodReflection , $ expr , $ scope , $ context );
600
+ }
586
601
}
587
602
}
603
+ if ($ specifiedTypes !== null ) {
604
+ return $ specifiedTypes ;
605
+ }
588
606
589
607
// lazy create parametersAcceptor, as creation can be expensive
590
608
$ parametersAcceptor = null ;
0 commit comments