@Nullable protected CallToSignature isCallTo(MethodReference methodReference) { Symfony2InterfacesUtil interfacesUtil = new Symfony2InterfacesUtil(); for (CallToSignature signature : this.signatures) { if (interfacesUtil.isCallTo( methodReference, signature.getInstance(), signature.getMethod())) { return signature; } } return null; }
@Nullable public MethodMatchParameter match() { if (!LaravelProjectComponent.isEnabled(psiElement)) { return null; } MethodReferenceBag bag = PhpElementsUtil.getMethodParameterReferenceBag(psiElement); if (bag == null) { return null; } // try on current method MethodMatcher.MethodMatchParameter methodMatchParameter = new StringParameterMatcher(psiElement, parameterIndex) .withSignature(this.signatures) .match(); if (methodMatchParameter != null) { return methodMatchParameter; } // walk down next method MethodReference methodReference = bag.getMethodReference(); Method method = Symfony2InterfacesUtil.getMultiResolvedMethod(methodReference); if (method == null) { return null; } PsiElement[] parameterReferences = PhpElementsUtil.getMethodParameterReferences(method, bag.getParameterBag().getIndex()); if (parameterReferences == null || parameterReferences.length == 0) { return null; } for (PsiElement var : parameterReferences) { MethodMatcher.MethodMatchParameter methodMatchParameterRef = new MethodMatcher.StringParameterMatcher(var, parameterIndex) .withSignature(this.signatures) .match(); if (methodMatchParameterRef != null) { return methodMatchParameterRef; } } return null; }
public static boolean isCallToWithParameter( PsiElement psiElement, String className, String methodName, int parameterIndex) { if (!(psiElement.getContext() instanceof ParameterList)) { return false; } ParameterList parameterList = (ParameterList) psiElement.getContext(); if (parameterList == null || !(parameterList.getContext() instanceof MethodReference)) { return false; } MethodReference method = (MethodReference) parameterList.getContext(); Symfony2InterfacesUtil interfacesUtil = new Symfony2InterfacesUtil(); if (!interfacesUtil.isCallTo(method, className, methodName)) { return false; } ParameterBag currentIndex = PsiElementUtils.getCurrentParameterIndex(psiElement); if (currentIndex == null || currentIndex.getIndex() != parameterIndex) { return false; } return true; }