Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,69 @@
enabledByDefault="true"
level="WARNING"
implementationClass="com.magento.idea.magento2uct.inspections.php.deprecation.ImportingDeprecatedInterface"/>
<localInspection language="PHP" groupPath="UCT"
shortName="UsingDeprecatedClass"
bundle="uct.bundle.inspection" key="inspection.displayName.UsingDeprecatedClass"
groupBundle="uct.bundle.inspection" groupKey="inspection.deprecation.group.name"
enabledByDefault="true"
level="WARNING"
implementationClass="com.magento.idea.magento2uct.inspections.php.deprecation.UsingDeprecatedClass"/>
<localInspection language="PHP" groupPath="UCT"
shortName="UsingDeprecatedInterface"
bundle="uct.bundle.inspection" key="inspection.displayName.UsingDeprecatedInterface"
groupBundle="uct.bundle.inspection" groupKey="inspection.deprecation.group.name"
enabledByDefault="true"
level="WARNING"
implementationClass="com.magento.idea.magento2uct.inspections.php.deprecation.UsingDeprecatedInterface"/>
<localInspection language="PHP" groupPath="UCT"
shortName="UsingDeprecatedConstant"
bundle="uct.bundle.inspection" key="inspection.displayName.UsingDeprecatedConstant"
groupBundle="uct.bundle.inspection" groupKey="inspection.deprecation.group.name"
enabledByDefault="true"
level="WARNING"
implementationClass="com.magento.idea.magento2uct.inspections.php.deprecation.UsingDeprecatedConstant"/>
<localInspection language="PHP" groupPath="UCT"
shortName="OverridingDeprecatedConstant"
bundle="uct.bundle.inspection" key="inspection.displayName.OverridingDeprecatedConstant"
groupBundle="uct.bundle.inspection" groupKey="inspection.deprecation.group.name"
enabledByDefault="true"
level="WARNING"
implementationClass="com.magento.idea.magento2uct.inspections.php.deprecation.OverridingDeprecatedConstant"/>
<localInspection language="PHP" groupPath="UCT"
shortName="OverridingDeprecatedProperty"
bundle="uct.bundle.inspection" key="inspection.displayName.OverridingDeprecatedProperty"
groupBundle="uct.bundle.inspection" groupKey="inspection.deprecation.group.name"
enabledByDefault="true"
level="WARNING"
implementationClass="com.magento.idea.magento2uct.inspections.php.deprecation.OverridingDeprecatedProperty"/>
<localInspection language="PHP" groupPath="UCT"
shortName="InheritedDeprecatedInterface"
bundle="uct.bundle.inspection" key="inspection.displayName.InheritedDeprecatedInterface"
groupBundle="uct.bundle.inspection" groupKey="inspection.deprecation.group.name"
enabledByDefault="true"
level="WARNING"
implementationClass="com.magento.idea.magento2uct.inspections.php.deprecation.InheritedDeprecatedInterface"/>
<localInspection language="PHP" groupPath="UCT"
shortName="ImplementedDeprecatedInterface"
bundle="uct.bundle.inspection" key="inspection.displayName.ImplementedDeprecatedInterface"
groupBundle="uct.bundle.inspection" groupKey="inspection.deprecation.group.name"
enabledByDefault="true"
level="WARNING"
implementationClass="com.magento.idea.magento2uct.inspections.php.deprecation.ImplementedDeprecatedInterface"/>
<localInspection language="PHP" groupPath="UCT"
shortName="CallingDeprecatedMethod"
bundle="uct.bundle.inspection" key="inspection.displayName.CallingDeprecatedMethod"
groupBundle="uct.bundle.inspection" groupKey="inspection.deprecation.group.name"
enabledByDefault="true"
level="WARNING"
implementationClass="com.magento.idea.magento2uct.inspections.php.deprecation.CallingDeprecatedMethod"/>
<localInspection language="PHP" groupPath="UCT"
shortName="UsingDeprecatedProperty"
bundle="uct.bundle.inspection" key="inspection.displayName.UsingDeprecatedProperty"
groupBundle="uct.bundle.inspection" groupKey="inspection.deprecation.group.name"
enabledByDefault="true"
level="WARNING"
implementationClass="com.magento.idea.magento2uct.inspections.php.deprecation.UsingDeprecatedProperty"/>
<!-- \UCT inspection -->

<internalFileTemplate name="Magento Composer JSON"/>
Expand Down
7 changes: 7 additions & 0 deletions resources/inspectionDescriptions/CallingDeprecatedMethod.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<html>
<body>
<p>[1439] Call Adobe Commerce @deprecated method: The deprecated method will be removed in upcoming versions. Consider relying on methods declared in API interfaces instead.</p>
<!-- tooltip end -->
<p>Text after this comment will only be shown in the settings of the inspection.</p>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<html>
<body>
<p>[1338] Implemented Adobe Commerce @deprecated interface: The deprecated interface will be removed in upcoming versions. Consider removing the interface inheritance, using an interface marked as @api or an interface introduced within your implementation instead.</p>
<!-- tooltip end -->
<p>Text after this comment will only be shown in the settings of the inspection.</p>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<html>
<body>
<p>[1337] Inherited from Adobe Commerce @deprecated interface: The deprecated interface will be removed in upcoming versions. Consider removing the interface inheritance, using an interface marked as @api or an interface introduced within your implementation instead.</p>
<!-- tooltip end -->
<p>Text after this comment will only be shown in the settings of the inspection.</p>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<html>
<body>
<p>[1235] Overriding Adobe Commerce @deprecated constant: The deprecated constant will be removed in upcoming versions. Consider using a constant marked as @api or a private constant within your implementation instead.</p>
<!-- tooltip end -->
<p>Text after this comment will only be shown in the settings of the inspection.</p>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<html>
<body>
<p>[1535] Overriding Adobe Commerce @deprecated property: The deprecated property will be removed in upcoming versions. Consider relying on methods declared in API interfaces or using a private property within your implementation instead.</p>
<!-- tooltip end -->
<p>Text after this comment will only be shown in the settings of the inspection.</p>
</body>
</html>
7 changes: 7 additions & 0 deletions resources/inspectionDescriptions/UsingDeprecatedClass.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<html>
<body>
<p>[1134] Using Adobe Commerce @deprecated class: The extended class will be removed in upcoming versions. Consider using Adobe Commerce class marked as @api instead.</p>
<!-- tooltip end -->
<p>Text after this comment will only be shown in the settings of the inspection.</p>
</body>
</html>
7 changes: 7 additions & 0 deletions resources/inspectionDescriptions/UsingDeprecatedConstant.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<html>
<body>
<p>[1234] Using Adobe Commerce @deprecated constant: The deprecated constant will be removed in upcoming versions. Consider using a constant marked as @api or a private constant within your implementation instead.</p>
<!-- tooltip end -->
<p>Text after this comment will only be shown in the settings of the inspection.</p>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<html>
<body>
<p>[1334] Used Adobe Commerce @deprecated interface: The deprecated interface will be removed in upcoming versions. Consider using an interface or class marked as @api instead.</p>
<!-- tooltip end -->
<p>Text after this comment will only be shown in the settings of the inspection.</p>
</body>
</html>
7 changes: 7 additions & 0 deletions resources/inspectionDescriptions/UsingDeprecatedProperty.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<html>
<body>
<p>[1534] Using Adobe Commerce @deprecated property: The deprecated method will be removed in upcoming versions. Consider relying on methods declared in API interfaces instead.</p>
<!-- tooltip end -->
<p>Text after this comment will only be shown in the settings of the inspection.</p>
</body>
</html>
33 changes: 19 additions & 14 deletions resources/uct/bundle/inspection.properties
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
inspection.deprecation.group.name=Deprecation Inspections
inspection.displayName.ExtendingDeprecatedClass=Extending from Adobe Commerce @deprecated class
inspection.displayName.ImportingDeprecatedClass=Importing Adobe Commerce @deprecated class
inspection.displayName.ImportingDeprecatedInterface=Importing Adobe Commerce @deprecated interface
inspection.displayName.ImportingDeprecatedInterface=Imported Adobe Commerce @deprecated interface
inspection.displayName.UsingDeprecatedClass=Using Adobe Commerce @deprecated class
inspection.displayName.UsingDeprecatedInterface=Used Adobe Commerce @deprecated interface
inspection.displayName.UsingDeprecatedConstant=Using Adobe Commerce @deprecated constant
inspection.displayName.OverridingDeprecatedConstant=Overriding Adobe Commerce @deprecated constant
inspection.displayName.OverridingDeprecatedProperty=Overriding Adobe Commerce @deprecated property
inspection.displayName.InheritedDeprecatedInterface=Inherited from Adobe Commerce @deprecated interface
inspection.displayName.ImplementedDeprecatedInterface=Implemented Adobe Commerce @deprecated interface
inspection.displayName.CallingDeprecatedMethod=Call Adobe Commerce @deprecated method
inspection.displayName.UsingDeprecatedProperty=Using Adobe Commerce @deprecated property
customCode.warnings.deprecated.1131=[1131] Extending from @deprecated class ''{0}''
customCode.warnings.deprecated.1132=[1132] Importing @deprecated class ''{0}''
customCode.warnings.deprecated.1133=[1133] Loading Adobe Commerce @deprecated class {0} in {1}. The extended class will be removed in upcoming versions. Consider using Adobe Commerce class marked as @api instead.
customCode.warnings.deprecated.1134=[1134] Using Adobe Commerce @deprecated class {0} in {1}::{2}. The extended class will be removed in upcoming versions. Consider using Adobe Commerce class marked as @api instead.
customCode.warnings.deprecated.1234=[1234] Using Adobe Commerce @deprecated constant {0}::{1} in {2}. The deprecated constant will be removed in upcoming versions. Consider using a constant marked as @api or a private constant within your implementation instead.
customCode.warnings.deprecated.1235=[1235] Overriding Adobe Commerce @deprecated constant {0}::{1} in {2}. The deprecated constant will be removed in upcoming versions. Consider using a constant marked as @api or a private constant within your implementation instead.
customCode.warnings.deprecated.1236=[1236] Assignation of Adobe Commerce @deprecated constant {0}::{1} in {2}. The deprecated constant will be removed in upcoming versions. Consider using a constant marked as @api or a private constant within your implementation instead.
customCode.warnings.deprecated.1134=[1134] Using @deprecated class ''{0}''
customCode.warnings.deprecated.1234=[1234] Using @deprecated constant ''{0}''
customCode.warnings.deprecated.1235=[1235] Overriding @deprecated constant ''{0}''
customCode.warnings.deprecated.1332=[1332] Imported @deprecated interface ''{0}''
customCode.warnings.deprecated.1334=[1334] Used Adobe Commerce @deprecated interface {0} in {1}::{2}. The deprecated interface will be removed in upcoming versions. Consider using an interface or class marked as @api instead.
customCode.warnings.deprecated.1337=[1337] Inherited from Adobe Commerce @deprecated interface {0} in {1}. The deprecated interface will be removed in upcoming versions. Consider removing the interface inheritance, using an interface marked as @api or an interface introduced within your implementation instead.
customCode.warnings.deprecated.1338=[1338] Implemented Adobe Commerce @deprecated interface {0} in {1}. The deprecated interface will be removed in upcoming versions. Consider removing the interface inheritance, using an interface marked as @api or an interface introduced within your implementation instead.
customCode.warnings.deprecated.1430=[1430] Call not declared dataobject method. The magic methods that are not declared may be changed. Consider relying on interface methods instead.
customCode.warnings.deprecated.1439=[1439] Call Adobe Commerce @deprecated method. The deprecated method will be removed in upcoming versions. Consider relying on methods declared in API interfaces instead.
customCode.warnings.deprecated.1534=[1534] Using Adobe Commerce @deprecated property. The deprecated method will be removed in upcoming versions. Consider relying on methods declared in API interfaces instead.
customCode.warnings.deprecated.1535=[1535] Overriding Adobe Commerce @deprecated property {0}::{1} in {2}. The deprecated property will be removed in upcoming versions. Consider relying on methods declared in API interfaces or using a private property within your implementation instead.
customCode.warnings.deprecated.1536=[1536] Assignation of Adobe Commerce @deprecated property. The deprecated method will be removed in upcoming versions. Consider relying on methods declared in API interfaces instead.
customCode.warnings.deprecated.1334=[1334] Used @deprecated interface ''{0}''
customCode.warnings.deprecated.1337=[1337] Inherited from @deprecated interface ''{0}''
customCode.warnings.deprecated.1338=[1338] Implemented @deprecated interface ''{0}''
customCode.warnings.deprecated.1439=[1439] Call @deprecated method ''{0}''
customCode.warnings.deprecated.1534=[1534] Using @deprecated property ''{0}''
customCode.warnings.deprecated.1535=[1535] Overriding @deprecated property ''{0}''
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,23 @@

package com.magento.idea.magento2uct.execution;

import com.intellij.codeInspection.InspectionManager;
import com.intellij.codeInspection.ProblemDescriptor;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiDirectory;
import com.intellij.psi.PsiFile;
import com.intellij.psi.PsiManager;
import com.intellij.psi.util.PsiTreeUtil;
import com.jetbrains.php.codeInsight.PhpCodeInsightUtil;
import com.jetbrains.php.lang.psi.PhpFile;
import com.jetbrains.php.lang.psi.elements.ClassConstantReference;
import com.jetbrains.php.lang.psi.elements.Field;
import com.jetbrains.php.lang.psi.elements.PhpClass;
import com.jetbrains.php.lang.psi.elements.PhpPsiElement;
import com.jetbrains.php.lang.psi.elements.PhpUseList;
import com.jetbrains.php.lang.psi.resolve.types.PhpTypeAnalyserVisitor;
import com.magento.idea.magento2plugin.util.GetFirstClassOfFile;
import com.magento.idea.magento2uct.execution.process.OutputWrapper;
import com.magento.idea.magento2uct.execution.scanner.ModuleFilesScanner;
import com.magento.idea.magento2uct.execution.scanner.ModuleScanner;
import com.magento.idea.magento2uct.execution.scanner.data.ComponentData;
import com.magento.idea.magento2uct.inspections.UctInspectionManager;
import com.magento.idea.magento2uct.inspections.UctProblemsHolder;
import com.magento.idea.magento2uct.inspections.php.DeprecationInspection;
import com.magento.idea.magento2uct.packages.SupportedIssue;
import java.io.File;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
import org.jetbrains.annotations.NotNull;

public class GenerateUctReportCommand {
Expand Down Expand Up @@ -95,73 +82,6 @@ public void execute() {
}
}

/**
* Visit directory recursively.
*
* @param directory PsiDirectory
*/
private void visitDirectory(final @NotNull PsiDirectory directory) {
final PsiFile[] files = directory.getFiles();

for (final PsiFile file : files) {
if (!(file instanceof PhpFile)) {
continue;
}
final PhpClass phpClass = GetFirstClassOfFile.getInstance().execute((PhpFile) file);

if (phpClass != null) {
final DeprecationInspection deprecationInspection =
new DeprecationInspection(phpClass);
final UctProblemsHolder problemsHolder = new UctProblemsHolder(
InspectionManager.getInstance(project),
phpClass.getContainingFile(),
false
);
final PhpTypeAnalyserVisitor visitor =
(PhpTypeAnalyserVisitor) deprecationInspection.buildVisitor(
problemsHolder,
false
);
visitor.visitPhpClass(phpClass);

final PhpPsiElement scopeForUseOperator =
PhpCodeInsightUtil.findScopeForUseOperator(phpClass);

if (scopeForUseOperator != null) {
final List<PhpUseList> imports =
PhpCodeInsightUtil.collectImports(scopeForUseOperator);

for (final PhpUseList phpUseList : imports) {
visitor.visitPhpUseList(phpUseList);
}
}

final List<ClassConstantReference> classConstantReferences =
new ArrayList<>(
PsiTreeUtil.findChildrenOfType(
phpClass,
ClassConstantReference.class
)
);
for (final ClassConstantReference constantReference : classConstantReferences) {
visitor.visitPhpClassConstantReference(constantReference);
}

for (final Field field : phpClass.getOwnFields()) {
visitor.visitPhpField(field);
}

for (final ProblemDescriptor descriptor : problemsHolder.getResults()) {
output.print(descriptor.getDescriptionTemplate());
}
}
}

for (final PsiDirectory subDirectory : directory.getSubdirectories()) {
visitDirectory(subDirectory);
}
}

/**
* Get target psi directory.
*
Expand Down
Loading