/** new FooClass() */ @Nullable private static PhpClass getNewExpressionPhpClass(@NotNull NewExpression newExpression) { ClassReference classReference = newExpression.getClassReference(); if (classReference != null) { String fqn = classReference.getFQN(); if (fqn != null) { return PhpElementsUtil.getClass(newExpression.getProject(), fqn); } } return null; }
/** * Extract type hint from method parameter * * <p>function foo(\FooClass $class) */ @Nullable public static String getMethodParameterTypeHint(@NotNull Method method) { ParameterList childOfType = PsiTreeUtil.getChildOfType(method, ParameterList.class); if (childOfType == null) { return null; } PsiElement[] parameters = childOfType.getParameters(); if (parameters.length == 0) { return null; } ClassReference classReference = PsiTreeUtil.getChildOfType(parameters[0], ClassReference.class); if (classReference == null) { return null; } String fqn = classReference.getFQN(); if (fqn == null) { return null; } return fqn; }