@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); }
@Nullable public static String getArrayHashValue( ArrayCreationExpression arrayCreationExpression, String keyName) { ArrayHashElement translationArrayHashElement = PsiElementUtils.getChildrenOfType( arrayCreationExpression, PlatformPatterns.psiElement(ArrayHashElement.class) .withFirstChild( PlatformPatterns.psiElement(PhpElementTypes.ARRAY_KEY) .withText( PlatformPatterns.string() .oneOf("'" + keyName + "'", "\"" + keyName + "\"")))); if (translationArrayHashElement == null) { return null; } if (!(translationArrayHashElement.getValue() instanceof StringLiteralExpression)) { return null; } StringLiteralExpression valueString = (StringLiteralExpression) translationArrayHashElement.getValue(); if (valueString == null) { return null; } return valueString.getContents(); }