コード例 #1
0
    @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;
    }
コード例 #2
0
  @Nullable
  public static MethodMatcher.MethodMatchParameter getMatchedSignatureWithDepth(
      PsiElement psiElement,
      MethodMatcher.CallToSignature[] callToSignatures,
      int defaultParameterIndex) {

    if (!LaravelProjectComponent.isEnabled(psiElement)) {
      return null;
    }

    MethodMatcher.MethodMatchParameter methodMatchParameter =
        new MethodMatcher.StringParameterMatcher(psiElement, defaultParameterIndex)
            .withSignature(callToSignatures)
            .match();

    if (methodMatchParameter != null) {
      return methodMatchParameter;
    }

    // try on resolved method
    return new MethodMatcher.StringParameterRecursiveMatcher(psiElement, defaultParameterIndex)
        .withSignature(callToSignatures)
        .match();
  }
コード例 #3
0
    @Nullable
    public MethodMatchParameter match() {

      if (!LaravelProjectComponent.isEnabled(psiElement)) {
        return null;
      }

      MethodReferenceBag bag =
          PhpElementsUtil.getMethodParameterReferenceBag(psiElement, this.parameterIndex);
      if (bag == null) {
        return null;
      }

      CallToSignature matchedMethodSignature = this.isCallTo(bag.getMethodReference());
      if (matchedMethodSignature == null) {
        return null;
      }

      return new MethodMatchParameter(
          matchedMethodSignature,
          bag.getParameterBag(),
          bag.getParameterList().getParameters(),
          bag.getMethodReference());
    }