17
17
import com .jetbrains .php .lang .psi .elements .Parameter ;
18
18
import com .jetbrains .php .lang .psi .elements .PhpClass ;
19
19
import com .jetbrains .php .lang .psi .elements .PhpPsiElement ;
20
- import com .jetbrains .php .lang .psi .elements .PhpReturnType ;
21
20
import com .magento .idea .magento2plugin .actions .generation .data .code .PluginMethodData ;
22
21
import com .magento .idea .magento2plugin .actions .generation .generator .code .util .ConvertPluginParamsToPhpDocStringUtil ;
23
22
import com .magento .idea .magento2plugin .actions .generation .generator .code .util .ConvertPluginParamsToString ;
23
+ import com .magento .idea .magento2plugin .actions .generation .generator .util .PhpClassGeneratorUtil ;
24
24
import com .magento .idea .magento2plugin .magento .files .Plugin ;
25
25
import com .magento .idea .magento2plugin .magento .packages .MagentoPhpClass ;
26
+ import com .magento .idea .magento2plugin .util .php .PhpTypeMetadataParserUtil ;
26
27
import java .util .ArrayList ;
27
28
import java .util .Arrays ;
28
29
import java .util .Collection ;
@@ -123,12 +124,15 @@ private Properties getAccessMethodAttributes(
123
124
attributes ,
124
125
type
125
126
);
126
- this .addReturnType (attributes , pluginMethodReturnType );
127
+
128
+ if (pluginMethodReturnType != null ) {
129
+ this .addReturnType (attributes , pluginMethodReturnType );
130
+ }
127
131
128
132
return attributes ;
129
133
}
130
134
131
- private @ NotNull String fillAttributes (
135
+ private String fillAttributes (
132
136
final @ Nullable PhpPsiElement scopeForUseOperator ,
133
137
final Properties attributes ,
134
138
final @ NotNull Plugin .PluginType type
@@ -139,18 +143,17 @@ private Properties getAccessMethodAttributes(
139
143
final String pluginMethodName = type .toString ().concat (methodSuffix );
140
144
141
145
attributes .setProperty ("NAME" , pluginMethodName );
142
- final PhpReturnType targetMethodReturnType = myMethod .getReturnType ();
143
- String returnType = "" ;
146
+ String returnType = PhpTypeMetadataParserUtil .getMethodReturnType (this .myMethod );
147
+
148
+ if (returnType != null && PhpClassGeneratorUtil .isValidFqn (returnType )) {
149
+ returnType = PhpClassGeneratorUtil .getNameFromFqn (returnType );
150
+ }
144
151
145
- if (targetMethodReturnType != null
146
- && (type .equals (Plugin .PluginType .after ) || type .equals (Plugin .PluginType .around ))
147
- ) {
148
- returnType = targetMethodReturnType .getText ();
149
- } else if (type .equals (Plugin .PluginType .before )) {
152
+ if (type .equals (Plugin .PluginType .before )) {
150
153
returnType = MagentoPhpClass .ARRAY_TYPE ;
151
154
}
152
155
153
- final Collection <PsiElement > parameters = new ArrayList ();
156
+ final Collection <PsiElement > parameters = new ArrayList <> ();
154
157
parameters .add (myTargetClass );
155
158
parameters .addAll (Arrays .asList (myMethod .getParameters ()));
156
159
attributes .setProperty ("PARAM_DOC" , ConvertPluginParamsToPhpDocStringUtil .execute (
0 commit comments