Skip to content

Commit 8faf440

Browse files
author
Vitaliy Boyko
committed
Merge branch '3.0.4-develop' of github.com:magento/magento2-phpstorm-plugin into 3.0.4->3.10-forwardport
� Conflicts: � .github/workflows/gradle.yml � CHANGELOG.md � build.gradle � resources/META-INF/plugin.xml
2 parents cc4d73e + 2e6a81e commit 8faf440

File tree

23 files changed

+660
-252
lines changed

23 files changed

+660
-252
lines changed

CHANGELOG.md

+12
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,18 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0).
66

77
## 3.1.0
88

9+
## 3.0.4
10+
11+
### Fixed
12+
13+
- Overriding the interface that generates invalid php code
14+
- Overriding a template from the base area
15+
- Disabled the ability to create a plugin for a class that implements `\Magento\Framework\ObjectManager\NoninterceptableInterface`
16+
17+
### Added
18+
19+
- `NoninterceptableInterface` case warning to the plugin inspection
20+
921
## 3.0.3
1022

1123
### Fixed

resources/fileTemplates/internal/Magento Preference Class.php.ft

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ namespace ${NAMESPACE};
99
use ${USE};
1010
#end
1111

12-
class ${NAME} #if (${EXTENDS})extends ${EXTENDS}#end {
12+
#if (${INTERFACE})interface#else class#end ${NAME} #if (${EXTENDS})extends ${EXTENDS}#end {
1313

1414
}

resources/magento2/inspection.properties

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ inspection.graphql.resolver.fix.title=Select one of the following interface
88
inspection.graphql.schema.resolver.fix.family=Create GraphQL Resolver
99
inspection.plugin.error.nonPublicMethod=You can't declare a plugin for a not public method.
1010
inspection.plugin.error.finalClass=You can't declare a plugin for a final class.
11+
inspection.plugin.error.noninterceptableInterface=You can't declare a plugin for a class that implements Magento\\Framework\\ObjectManager\\NoninterceptableInterface.
1112
inspection.plugin.error.finalMethod=You can't declare a plugin for a final method.
1213
inspection.plugin.error.staticMethod=You can't declare a plugin for a static method.
1314
inspection.plugin.error.constructMethod=You can't declare a plugin for a __construct method.

src/com/magento/idea/magento2plugin/actions/generation/CreateAPluginAction.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@
1818
import com.jetbrains.php.lang.psi.elements.PhpClass;
1919
import com.magento.idea.magento2plugin.MagentoIcons;
2020
import com.magento.idea.magento2plugin.actions.generation.dialog.CreateAPluginDialog;
21+
import com.magento.idea.magento2plugin.inspections.php.util.PhpClassImplementsNoninterceptableInterfaceUtil;
2122
import com.magento.idea.magento2plugin.project.Settings;
2223
import com.magento.idea.magento2plugin.util.GetFirstClassOfFile;
23-
import com.magento.idea.magento2plugin.util.magento.plugin.IsPluginAllowedForMethod;
24+
import com.magento.idea.magento2plugin.util.magento.plugin.IsPluginAllowedForMethodUtil;
2425
import org.jetbrains.annotations.NotNull;
2526

2627
public class CreateAPluginAction extends DumbAwareAction {
2728
public static final String ACTION_NAME = "Create a new Plugin for this method";
2829
public static final String ACTION_DESCRIPTION = "Create a new Magento 2 Plugin";
29-
private final IsPluginAllowedForMethod isPluginAllowed;// NOPMD
3030
private final GetFirstClassOfFile getFirstClassOfFile;
3131
private Method targetMethod;
3232
private PhpClass targetClass;
@@ -36,7 +36,6 @@ public class CreateAPluginAction extends DumbAwareAction {
3636
*/
3737
public CreateAPluginAction() {
3838
super(ACTION_NAME, ACTION_DESCRIPTION, MagentoIcons.MODULE);
39-
this.isPluginAllowed = IsPluginAllowedForMethod.getInstance();
4039
this.getFirstClassOfFile = GetFirstClassOfFile.getInstance();
4140
}
4241

@@ -55,6 +54,7 @@ public void update(final AnActionEvent event) {
5554
if (phpClass == null
5655
|| !(psiFile instanceof PhpFile)
5756
|| phpClass.isFinal()
57+
|| PhpClassImplementsNoninterceptableInterfaceUtil.execute(phpClass)
5858
|| this.targetMethod == null
5959
) {
6060
this.setStatus(event, false);
@@ -110,13 +110,13 @@ private void fetchTargetMethod(
110110
return;
111111
}
112112
if (element instanceof Method && element.getParent()
113-
== phpClass && isPluginAllowed.check((Method) element)) {
113+
== phpClass && IsPluginAllowedForMethodUtil.check((Method) element)) {
114114
this.targetMethod = (Method) element;
115115
return;
116116
}
117117
final PsiElement parent = element.getParent();
118118
if (parent instanceof Method && parent.getParent()
119-
== phpClass && isPluginAllowed.check((Method) parent)) {
119+
== phpClass && IsPluginAllowedForMethodUtil.check((Method) parent)) {
120120
this.targetMethod = (Method) parent;
121121
}
122122
}

src/com/magento/idea/magento2plugin/actions/generation/OverrideClassByAPreferenceAction.java

+4
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
public class OverrideClassByAPreferenceAction extends DumbAwareAction {
2323
public static final String ACTION_NAME = "Override this class by a new Preference";
2424
public static final String ACTION_DESCRIPTION = "Create a new Magento 2 Preference";
25+
public static final String INTERFACE_ACTION = "Override this interface by a new Preference";
2526
private final GetFirstClassOfFile getFirstClassOfFile;
2627
private PhpClass targetClass;
2728

@@ -44,6 +45,9 @@ public void update(final AnActionEvent event) {
4445
targetClass = phpClass;
4546
if (psiFile instanceof PhpFile && phpClass != null) {
4647
this.setStatus(event, true);
48+
if (phpClass.isInterface()) {
49+
event.getPresentation().setText(INTERFACE_ACTION);
50+
}
4751
} else {
4852
this.setStatus(event, false);
4953
}

0 commit comments

Comments
 (0)