use of com.jetbrains.php.lang.psi.elements.PhpExpression in project phpinspectionsea by kalessil.
the class CanNotReturnTypeStrategy method apply.
public static void apply(final Method method, final ProblemsHolder holder) {
final Collection<PhpReturn> returnStatements = PsiTreeUtil.findChildrenOfType(method, PhpReturn.class);
if (!returnStatements.isEmpty() && NamedElementUtil.getNameIdentifier(method) != null) {
final String message = strProblemDescription.replace("%m%", method.getName());
for (final PhpReturn returnExpression : returnStatements) {
final PhpExpression returnValue = ExpressionSemanticUtil.getReturnValue(returnExpression);
if (null != returnValue && method == ExpressionSemanticUtil.getScope(returnExpression)) {
holder.registerProblem(returnExpression, MessagesPresentationUtil.prefixWithEa(message));
}
}
}
returnStatements.clear();
}
use of com.jetbrains.php.lang.psi.elements.PhpExpression in project idea-php-typo3-plugin by cedricziel.
the class MethodArgumentDroppedMatcherInspection method buildVisitor.
@NotNull
@Override
public PsiElementVisitor buildVisitor(@NotNull ProblemsHolder problemsHolder, boolean b) {
return new PhpElementVisitor() {
@Override
public void visitPhpElement(PhpPsiElement element) {
if (!PlatformPatterns.psiElement(PhpElementTypes.METHOD_REFERENCE).accepts(element)) {
return;
}
MethodReference methodReference = (MethodReference) element;
ParameterList parameterList = methodReference.getParameterList();
PhpExpression classReference = methodReference.getClassReference();
if (classReference != null) {
PhpType inferredType = classReference.getInferredType();
String compiledClassMethodKey = inferredType.toString() + "->" + methodReference.getName();
if (ExtensionScannerUtil.classMethodHasDroppedArguments(element.getProject(), compiledClassMethodKey)) {
Integer maximumNumberOfArguments = ExtensionScannerUtil.getMaximumNumberOfArguments(element.getProject(), compiledClassMethodKey);
if (parameterList != null && maximumNumberOfArguments != -1 && parameterList.getParameters().length != maximumNumberOfArguments) {
problemsHolder.registerProblem(element, "Number of arguments changed with TYPO3 9, consider refactoring");
}
}
}
}
};
}
Aggregations