|
30 | 30 | import com.jetbrains.php.lang.psi.elements.impl.PhpDefineImpl;
|
31 | 31 | import com.jetbrains.php.lang.psi.resolve.types.PhpType;
|
32 | 32 | import com.jetbrains.php.lang.psi.stubs.indexes.expectedArguments.PhpExpectedFunctionArgument;
|
| 33 | +import com.jetbrains.php.lang.psi.stubs.indexes.expectedArguments.PhpExpectedFunctionArgumentsRegistry; |
33 | 34 | import com.jetbrains.php.lang.psi.stubs.indexes.expectedArguments.PhpExpectedFunctionScalarArgument;
|
34 | 35 | import com.jetbrains.php.phpunit.PhpUnitUtil;
|
35 | 36 | import com.jetbrains.php.refactoring.PhpAliasImporter;
|
@@ -1230,14 +1231,23 @@ public static PhpClass getClassInsideNamespaceScope(@NotNull Project project, @N
|
1230 | 1231 | * Resolves MethodReference and compare containing class against implementations instances
|
1231 | 1232 | */
|
1232 | 1233 | public static boolean isMethodReferenceInstanceOf(@NotNull MethodReference methodReference, @NotNull String expectedClassName) {
|
1233 |
| - for (ResolveResult resolveResult : methodReference.multiResolve(false)) { |
1234 |
| - PsiElement resolve = resolveResult.getElement(); |
| 1234 | + PhpIndex instance = PhpIndex.getInstance(methodReference.getProject()); |
| 1235 | + PhpType classType = (new PhpType()).add(methodReference.getClassReference()).global(methodReference.getProject()); |
1235 | 1236 |
|
1236 |
| - if(!(resolve instanceof Method)) { |
| 1237 | + Collection<PhpClass> instanceClasses = classType.getTypes() |
| 1238 | + .stream() |
| 1239 | + .flatMap((fqn) -> instance.getAnyByFQN(fqn).stream()) |
| 1240 | + .distinct() |
| 1241 | + .collect(Collectors.toList()); |
| 1242 | + |
| 1243 | + for (PhpClass phpClass : instanceClasses) { |
| 1244 | + Method method = phpClass.findMethodByName(methodReference.getName()); |
| 1245 | + if (method == null) { |
1237 | 1246 | continue;
|
1238 | 1247 | }
|
1239 | 1248 |
|
1240 |
| - PhpClass containingClass = ((Method) resolve).getContainingClass(); |
| 1249 | + // different class possible |
| 1250 | + PhpClass containingClass = method.getContainingClass(); |
1241 | 1251 | if(containingClass == null) {
|
1242 | 1252 | continue;
|
1243 | 1253 | }
|
|
0 commit comments