@@ -1521,35 +1521,26 @@ public static int getFunctionArgumentByName(@NotNull Function function, @NotNull
1521
1521
return -1 ;
1522
1522
}
1523
1523
1524
- /**
1525
- * Single resolve doesnt work if we have non unique class names in project context,
1526
- * so try a multiResolve
1527
- */
1528
1524
@ NotNull
1529
- public static Method [] getMultiResolvedMethod (@ NotNull PsiReference psiReference ) {
1530
- // class be unique in normal case, so try this first
1531
- PsiElement resolvedReference = psiReference .resolve ();
1532
- if (resolvedReference instanceof Method ) {
1533
- return new Method [] { (Method ) resolvedReference };
1534
- }
1535
-
1536
- // try multiResolve if class exists twice in project
1537
- if (psiReference instanceof PsiPolyVariantReference ) {
1538
- Collection <Method > methods = new HashSet <>();
1539
- for (ResolveResult resolveResult : ((PsiPolyVariantReference ) psiReference ).multiResolve (false )) {
1540
- PsiElement element = resolveResult .getElement ();
1541
- if (element instanceof Method ) {
1542
- methods .add ((Method ) element );
1543
- }
1544
- }
1525
+ public static Collection <Method > getMultiResolvedMethod (@ NotNull MethodReference methodReference ) {
1526
+ PhpIndex instance = PhpIndex .getInstance (methodReference .getProject ());
1527
+ PhpType classType = (new PhpType ()).add (methodReference .getClassReference ()).global (methodReference .getProject ());
1545
1528
1546
- if (methods .size () > 0 ) {
1547
- return methods .toArray (new Method [methods .size ()]);
1548
- }
1529
+ Collection <PhpClass > instanceClasses = classType .getTypes ()
1530
+ .stream ()
1531
+ .flatMap ((fqn ) -> instance .getAnyByFQN (fqn ).stream ())
1532
+ .distinct ()
1533
+ .collect (Collectors .toList ());
1549
1534
1535
+ Set <Method > methods = new HashSet <>();
1536
+ for (PhpClass phpClass : instanceClasses ) {
1537
+ Method method = phpClass .findMethodByName (methodReference .getName ());
1538
+ if (method != null ) {
1539
+ methods .add (method );
1540
+ }
1550
1541
}
1551
1542
1552
- return new Method [ 0 ] ;
1543
+ return methods ;
1553
1544
}
1554
1545
1555
1546
/**
0 commit comments