Skip to content

Commit b8bf6fd

Browse files
committed
Detect plugin in namespace
Signed-off-by: Denis Kopylov <[email protected]>
1 parent 90b33d8 commit b8bf6fd

File tree

5 files changed

+14
-24
lines changed

5 files changed

+14
-24
lines changed

app/code/Magento/Catalog/Plugin/CategoryAuthorization.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,11 @@
1212
use Magento\Catalog\Api\CategoryRepositoryInterface;
1313
use Magento\Catalog\Model\Category\Authorization;
1414
use Magento\Framework\Exception\LocalizedException;
15-
use Magento\Framework\Interception\PluginInterface;
1615

1716
/**
1817
* Perform additional authorization for category operations.
1918
*/
20-
class CategoryAuthorization implements PluginInterface
19+
class CategoryAuthorization
2120
{
2221
/**
2322
* @var Authorization

app/code/Magento/Catalog/Plugin/ProductAuthorization.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,11 @@
1212
use Magento\Catalog\Api\ProductRepositoryInterface;
1313
use Magento\Catalog\Model\Product\Authorization;
1414
use Magento\Framework\Exception\LocalizedException;
15-
use Magento\Framework\Interception\PluginInterface;
1615

1716
/**
1817
* Perform additional authorization for product operations.
1918
*/
20-
class ProductAuthorization implements PluginInterface
19+
class ProductAuthorization
2120
{
2221
/**
2322
* @var Authorization

app/code/Magento/Catalog/Plugin/RemoveImagesFromGalleryAfterRemovingProduct.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,11 @@
1212
use Magento\Catalog\Api\ProductRepositoryInterface;
1313
use Magento\Catalog\Model\Product\Gallery\ReadHandler;
1414
use Magento\Catalog\Model\ResourceModel\Product\Gallery;
15-
use Magento\Framework\Interception\PluginInterface;
1615

1716
/**
1817
* Responsible for deleting images from media gallery after deleting product
1918
*/
20-
class RemoveImagesFromGalleryAfterRemovingProduct implements PluginInterface
19+
class RemoveImagesFromGalleryAfterRemovingProduct
2120
{
2221
/**
2322
* @var Gallery

dev/tests/static/framework/Magento/CodeMessDetector/Rule/UnusedCode/UnusedFormalParameter.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ private function removeVariablesUsedInPlugins(AbstractNode $node)
4040
if ($node instanceof MethodNode) {
4141
/** @var ClassNode $classNode */
4242
$classNode = $node->getParentType();
43-
$implementInterfaces = class_implements($classNode->getFullQualifiedName());
44-
if (array_key_exists(PluginInterface::class, $implementInterfaces)) {
43+
if ($this->isPluginClass($classNode->getNamespaceName())) {
4544
/**
4645
* Around and After plugins has 2 required params $subject and $proceed or $result
4746
* that should be ignored
@@ -103,4 +102,14 @@ private function removeVariablesByCount(MethodNode $node, int $countOfRemovingVa
103102
unset($this->nodes[$methodParameter->getName()]);
104103
}
105104
}
105+
106+
/**
107+
* Check if namespace contain "Plugin"
108+
* @param $class
109+
* @return bool
110+
*/
111+
private function isPluginClass($class): bool
112+
{
113+
return (stripos($class, 'Plugin') !== false);
114+
}
106115
}

lib/internal/Magento/Framework/Interception/PluginInterface.php

Lines changed: 0 additions & 16 deletions
This file was deleted.

0 commit comments

Comments
 (0)