@Nullable
  public static MethodReferenceBag getMethodParameterReferenceBag(
      PsiElement psiElement, int wantIndex) {

    PsiElement variableContext = psiElement.getContext();
    if (!(variableContext instanceof ParameterList)) {
      return null;
    }

    ParameterList parameterList = (ParameterList) variableContext;
    if (!(parameterList.getContext() instanceof MethodReference)) {
      return null;
    }

    ParameterBag currentIndex = PsiElementUtils.getCurrentParameterIndex(psiElement);
    if (currentIndex == null) {
      return null;
    }

    if (wantIndex >= 0 && currentIndex.getIndex() != wantIndex) {
      return null;
    }

    return new MethodReferenceBag(
        parameterList, (MethodReference) parameterList.getContext(), currentIndex);
  }
  public static boolean isFunctionReference(
      PsiElement psiElement, int wantIndex, String... funcName) {

    PsiElement variableContext = psiElement.getContext();
    if (!(variableContext instanceof ParameterList)) {
      return false;
    }

    ParameterList parameterList = (ParameterList) variableContext;
    PsiElement context = parameterList.getContext();
    if (!(context instanceof FunctionReference)) {
      return false;
    }

    FunctionReference methodReference = (FunctionReference) context;
    String name = methodReference.getName();

    if (name == null || !Arrays.asList(funcName).contains(name)) {
      return false;
    }

    ParameterBag currentIndex = getCurrentParameterIndex(psiElement);
    if (currentIndex == null) {
      return false;
    }

    return !(wantIndex >= 0 && currentIndex.getIndex() != wantIndex);
  }
  @Nullable
  public static MethodReference getMethodReferenceWithFirstStringParameter(PsiElement psiElement) {
    if (!PlatformPatterns.psiElement()
        .withParent(StringLiteralExpression.class)
        .inside(ParameterList.class)
        .withLanguage(PhpLanguage.INSTANCE)
        .accepts(psiElement)) {

      return null;
    }

    ParameterList parameterList = PsiTreeUtil.getParentOfType(psiElement, ParameterList.class);
    if (parameterList == null) {
      return null;
    }

    if (!(parameterList.getContext() instanceof MethodReference)) {
      return null;
    }

    return (MethodReference) parameterList.getContext();
  }
  @Nullable
  public static ParameterBag getCurrentParameterIndex(PsiElement psiElement) {

    if (!(psiElement.getContext() instanceof ParameterList)) {
      return null;
    }

    ParameterList parameterList = (ParameterList) psiElement.getContext();
    if (!(parameterList.getContext() instanceof ParameterListOwner)) {
      return null;
    }

    return getCurrentParameterIndex(parameterList.getParameters(), psiElement);
  }
  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;
  }