|
11 | 11 | import com.jetbrains.php.lang.psi.PhpPsiElementFactory; |
12 | 12 | import com.jetbrains.php.lang.psi.elements.Method; |
13 | 13 | import com.jetbrains.php.lang.psi.elements.Parameter; |
14 | | -import com.jetbrains.php.lang.psi.elements.PhpReturnType; |
15 | 14 | import com.magento.idea.magento2plugin.actions.generation.data.code.PluginMethodData; |
| 15 | +import com.magento.idea.magento2plugin.actions.generation.generator.util.PhpClassGeneratorUtil; |
16 | 16 | import com.magento.idea.magento2plugin.actions.generation.references.PhpClassReferenceResolver; |
17 | 17 | import com.magento.idea.magento2plugin.util.php.PhpTypeMetadataParserUtil; |
18 | 18 | import java.util.ArrayList; |
@@ -55,19 +55,19 @@ public void execute( |
55 | 55 | final PsiElement targetClass = (PsiElement) pluginMethod.getTargetMethod() |
56 | 56 | .getUserData(targetClassKey); |
57 | 57 | resolver.processElement(targetClass); |
58 | | - PhpReturnType returnType = targetMethod.getReturnType(); |
59 | | - final String returnTypeFqn = |
60 | | - PhpTypeMetadataParserUtil.getMethodReturnType(targetMethod); |
61 | 58 |
|
62 | | - if (returnType == null && returnTypeFqn != null) { |
63 | | - returnType = PhpPsiElementFactory.createReturnType( |
64 | | - pluginMethod.getTargetMethod().getProject(), |
65 | | - returnTypeFqn |
66 | | - ); |
67 | | - } |
| 59 | + final String returnTypeCandidate = PhpTypeMetadataParserUtil.getMethodReturnType( |
| 60 | + targetMethod |
| 61 | + ); |
68 | 62 |
|
69 | | - if (returnType != null) { |
70 | | - resolver.processElement(returnType); |
| 63 | + if (returnTypeCandidate != null |
| 64 | + && PhpClassGeneratorUtil.isValidFqn(returnTypeCandidate)) { |
| 65 | + resolver.processElement( |
| 66 | + PhpPsiElementFactory.createReturnType( |
| 67 | + pluginMethod.getTargetMethod().getProject(), |
| 68 | + returnTypeCandidate |
| 69 | + ) |
| 70 | + ); |
71 | 71 | } |
72 | 72 |
|
73 | 73 | textBuf.append('\n'); |
|
0 commit comments