diff --git a/META-INF/plugin.xml b/META-INF/plugin.xml index 6a5fec7..65abb17 100644 --- a/META-INF/plugin.xml +++ b/META-INF/plugin.xml @@ -61,6 +61,7 @@
  • Blade (Reverted): added support to comments folding again (FR #WI-39264);
  • Development (Added): added a development guide;
  • Plugin (Fixed): recompiled to support PS 2017.3+ builds;
  • +
  • Return Type Support (Disabled): return type support was disabled temporarily due to software limitation (waiting for IntelliJ IDEA 2017.3.2);
  • ]]> diff --git a/src/laravelInsight/fluent/UsingAsTypeInspection.java b/src/laravelInsight/fluent/UsingAsTypeInspection.java index eeef6e1..6a76659 100644 --- a/src/laravelInsight/fluent/UsingAsTypeInspection.java +++ b/src/laravelInsight/fluent/UsingAsTypeInspection.java @@ -2,12 +2,9 @@ import com.intellij.codeInspection.ProblemHighlightType; import com.intellij.codeInspection.ProblemsHolder; -import com.intellij.psi.PsiElement; import com.intellij.psi.PsiElementVisitor; import com.jetbrains.php.lang.documentation.phpdoc.psi.PhpDocType; import com.jetbrains.php.lang.inspections.PhpInspection; -import com.jetbrains.php.lang.psi.elements.Function; -import com.jetbrains.php.lang.psi.elements.Method; import com.jetbrains.php.lang.psi.elements.Parameter; import com.jetbrains.php.lang.psi.visitors.PhpElementVisitor; @@ -29,24 +26,6 @@ public PsiElementVisitor buildVisitor( final boolean isOnTheFly ) { return new PhpElementVisitor() { - @Override - public void visitPhpMethod(final Method method) { - final PsiElement methodReturnType = method.getReturnType(); - - if (FluentUtil.isUsingDirectly(methodReturnType)) { - problemsHolder.registerProblem(methodReturnType, messageDirectInstantiation, ProblemHighlightType.WEAK_WARNING); - } - } - - @Override - public void visitPhpFunction(final Function function) { - final PsiElement functionReturnType = function.getReturnType(); - - if (FluentUtil.isUsingDirectly(functionReturnType)) { - problemsHolder.registerProblem(functionReturnType, messageDirectInstantiation, ProblemHighlightType.WEAK_WARNING); - } - } - @Override public void visitPhpParameter(final Parameter parameter) { if (FluentUtil.isUsingDirectly(parameter)) { diff --git a/src/utils/PhpFunctionUtil.java b/src/utils/PhpFunctionUtil.java index 12868f5..d259e3c 100644 --- a/src/utils/PhpFunctionUtil.java +++ b/src/utils/PhpFunctionUtil.java @@ -1,22 +1,18 @@ package net.rentalhost.idea.utils; -import com.intellij.lang.ASTNode; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiReference; import com.jetbrains.php.codeInsight.controlFlow.instructions.PhpInstruction; import com.jetbrains.php.codeInsight.controlFlow.instructions.PhpReturnInstruction; import com.jetbrains.php.lang.documentation.phpdoc.psi.PhpDocComment; import com.jetbrains.php.lang.documentation.phpdoc.psi.tags.PhpDocReturnTag; -import com.jetbrains.php.lang.lexer.PhpTokenTypes; import com.jetbrains.php.lang.psi.elements.ClassReference; import com.jetbrains.php.lang.psi.elements.Function; import com.jetbrains.php.lang.psi.elements.FunctionReference; import com.jetbrains.php.lang.psi.elements.NewExpression; -import com.jetbrains.php.lang.psi.elements.PhpReference; import com.jetbrains.php.lang.psi.elements.PhpTypedElement; import com.jetbrains.php.lang.psi.resolve.types.PhpType; -import java.util.Objects; import java.util.Set; import org.jetbrains.annotations.NotNull; @@ -27,25 +23,7 @@ public enum PhpFunctionUtil { @NotNull public static PhpType getReturnType(@NotNull final Function functionInitial) { final PhpType typeResolved = RecursionResolver.resolve(functionInitial, (RecursionResolver.Resolver resolver) -> { - final Function function = (Function) resolver.getObject(); - final PsiElement functionReturnType = function.getReturnType(); - - if (functionReturnType instanceof PhpReference) { - final String functionReturnTypeFQN = ((PhpReference) functionReturnType).getFQN(); - final PhpType.PhpTypeBuilder functionReturnTypePrimary = PhpType.builder().add(functionReturnTypeFQN); - - final PsiElement prevMatch = TreeUtil.getPrevMatch( - functionReturnType, - filterBy -> (filterBy instanceof ASTNode) && Objects.equals(((ASTNode) filterBy).getElementType(), PhpTokenTypes.opQUEST), - stopBy -> (stopBy instanceof ASTNode) && Objects.equals(((ASTNode) stopBy).getElementType(), PhpTokenTypes.chRPAREN) - ); - - if (prevMatch instanceof ASTNode) { - functionReturnTypePrimary.add(PhpType.NULL); - } - - return functionReturnTypePrimary.build(); - } + final Function function = (Function) resolver.getObject(); final PhpInstruction[] phpInstructions = function.getControlFlow().getInstructions(); if (phpInstructions.length != 0) {