if (classByKeyword != null) {
return classByKeyword;
}
PhpIndex index = PhpIndex.getInstance(element.getProject());
List classes = new SmartList(index.getAnyByFQN(PhpLangUtil.toFQN(className)));
if (classes.size() > 0) {
return (PhpNamedElement) classes.get(0);
}
}
return null;
}
@Nullable
private PhpNamedElement getOriginalFunction(@NotNull Project project, @NotNull String fqn) {
if (project == null)
throw new IllegalArgumentException("Argument 0 for @NotNull parameter of com/jetbrains/php/lang/PhpReferenceContributor$CallbackReferenceProvider.getOriginalFunction must not be null");
if (fqn == null)
throw new IllegalArgumentException("Argument 1 for @NotNull parameter of com/jetbrains/php/lang/PhpReferenceContributor$CallbackReferenceProvider.getOriginalFunction must not be null");
PhpIndex index = PhpIndex.getInstance(project);
if (StringUtil.isNotEmpty(fqn)) {
int i = fqn.lastIndexOf('\\');
String name = i >= 0 ? fqn.substring(i + 1) : fqn;
String namespace = i >= 0 ? fqn.substring(0, i + 1) : "\\";
Collection functions = index.getFunctionsByName(name);
List filteredFunctions = new SmartList(index.filterNamedByNamespace(functions, PhpLangUtil.toFQN(namespace), true));
if (filteredFunctions.size() > 0) {
return (PhpNamedElement) filteredFunctions.get(0);
}
}
return null;
}
@Nullable
public Collection<PhpClass> resolveClass(@NotNull PhpIndex index, @NotNull PsiElement element, @Nullable PhpClass callerClass) {
if (index == null)
throw new IllegalArgumentException("Argument 0 for @NotNull parameter of com/jetbrains/php/lang/PhpReferenceContributor$CallbackReferenceProvider.resolveClass must not be null");
if (element == null)
throw new IllegalArgumentException("Argument 1 for @NotNull parameter of com/jetbrains/php/lang/PhpReferenceContributor$CallbackReferenceProvider.resolveClass must not be null");
PhpClass referencedClass = PhpCallbackFunctionUtil.getFirstClassByReference(element);
if (referencedClass != null) {
return new SmartList(referencedClass);
}
String callbackContent = getCallbackContent(element);
PhpClass classByKeyword = checkClassKeywords(callbackContent, callerClass);
if (classByKeyword != null) {
return new SmartList(classByKeyword);
}
if (callbackContent == null) {
PhpExpression classExpression = (element instanceof PhpExpression) ? (PhpExpression) element : (PhpExpression) PhpPsiUtil.getChildByCondition(element, PhpExpression.INSTANCEOF);