Skip to content

Commit c56f546

Browse files
author
Vitaliy
authored
Merge pull request #165 from magento/fixed-plugin-inspection-closure
Fixed error on around plugin
2 parents aa14634 + f8929b0 commit c56f546

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/com/magento/idea/magento2plugin/inspections/php/PluginInspection.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import com.jetbrains.php.lang.psi.visitors.PhpElementVisitor;
2121
import com.magento.idea.magento2plugin.inspections.php.util.PhpClassImplementsInterfaceUtil;
2222
import com.magento.idea.magento2plugin.magento.files.Plugin;
23+
import com.magento.idea.magento2plugin.magento.packages.Package;
2324
import com.magento.idea.magento2plugin.util.GetPhpClassByFQN;
2425
import com.magento.idea.magento2plugin.util.magento.plugin.GetTargetClassNamesByPluginClassName;
2526
import org.jetbrains.annotations.NotNull;
@@ -128,7 +129,7 @@ private void checkParametersCompatibility(Method pluginMethod, String pluginPref
128129
String declaredType = pluginMethodParameter.getDeclaredType().toString();
129130

130131
if (index == 1) {
131-
String targetClassFqn = "\\".concat(targetClassName);
132+
String targetClassFqn = Package.FQN_SEPARATOR.concat(targetClassName);
132133
if (!checkTypeIncompatibility(targetClassFqn, declaredType, phpIndex)) {
133134
problemsHolder.registerProblem(pluginMethodParameter, PhpBundle.message("inspection.wrong_param_type", new Object[]{declaredType, targetClassFqn}), ProblemHighlightType.ERROR);
134135
}
@@ -138,7 +139,8 @@ private void checkParametersCompatibility(Method pluginMethod, String pluginPref
138139
continue;
139140
}
140141
if (index == 2 && pluginPrefix.equals(Plugin.PluginType.around.toString())) {
141-
if (!checkTypeIncompatibility("callable", declaredType, phpIndex)) {
142+
if (!checkTypeIncompatibility(Plugin.CALLABLE_PARAM, declaredType, phpIndex) &&
143+
!checkTypeIncompatibility(Package.FQN_SEPARATOR.concat(Plugin.CLOSURE_PARAM), declaredType, phpIndex)) {
142144
problemsHolder.registerProblem(pluginMethodParameter, PhpBundle.message("inspection.wrong_param_type", new Object[]{declaredType, "callable"}), ProblemHighlightType.ERROR);
143145
}
144146
continue;

src/com/magento/idea/magento2plugin/magento/files/Plugin.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ public class Plugin implements ModuleFileInterface {
1212
private static final String AROUND_METHOD_TEMPLATE_NAME = "Magento Plugin Around Method";
1313
private static final String AFTER_METHOD_TEMPLATE_NAME = "Magento Plugin After Method";
1414

15+
public static final String CALLABLE_PARAM = "callable";
16+
public static final String CLOSURE_PARAM = "Closure";
17+
1518
public enum PluginType {
1619
before,
1720
after,

0 commit comments

Comments
 (0)