Skip to content

Commit e4d1043

Browse files
committed
Merge remote-tracking branch 'origin/BUG#AC-2855' into Hammer_Quality_Issue_PR_31May
2 parents 088f5b0 + 6e5597a commit e4d1043

File tree

5 files changed

+159
-6
lines changed

5 files changed

+159
-6
lines changed

lib/internal/Magento/Framework/Code/Generator/EntityAbstract.php

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
/**
1212
* Abstract entity
13+
*
14+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1315
*/
1416
abstract class EntityAbstract
1517
{
@@ -18,7 +20,7 @@ abstract class EntityAbstract
1820
/**
1921
* Entity type abstract
2022
*/
21-
const ENTITY_TYPE = 'abstract';
23+
public const ENTITY_TYPE = 'abstract';
2224

2325
/**
2426
* @var string[]
@@ -332,14 +334,22 @@ private function extractParameterType(
332334
/** @var string|null $typeName */
333335
$typeName = null;
334336
$parameterType = $parameter->getType();
335-
if ($parameterType->getName() === 'array') {
337+
338+
if ($parameterType instanceof \ReflectionUnionType) {
339+
$parameterType = $parameterType->getTypes();
340+
$parameterType = implode('|', $parameterType);
341+
} else {
342+
$parameterType = $parameterType->getName();
343+
}
344+
345+
if ($parameterType === 'array') {
336346
$typeName = 'array';
337347
} elseif ($parameterClass = $this->getParameterClass($parameter)) {
338348
$typeName = $this->_getFullyQualifiedClassName($parameterClass->getName());
339-
} elseif ($parameterType->getName() === 'callable') {
349+
} elseif ($parameterType === 'callable') {
340350
$typeName = 'callable';
341351
} else {
342-
$typeName = $parameterType->getName();
352+
$typeName = $parameterType;
343353
}
344354

345355
if ($parameter->allowsNull()) {

lib/internal/Magento/Framework/Interception/Code/Generator/Interceptor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ protected function _getClassMethods()
7272
$reflectionClass = new \ReflectionClass($this->getSourceClassName());
7373
$publicMethods = $reflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC);
7474
foreach ($publicMethods as $method) {
75-
if ($this->isInterceptedMethod($method)) {
75+
if (!$method->isInternal() && $this->isInterceptedMethod($method)) {
7676
$methods[] = $this->_getMethodInfo($method);
7777
}
7878
}

lib/internal/Magento/Framework/Interception/Test/Unit/Code/Generator/InterceptorTest.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,12 @@ public function interceptorDataProvider()
9090
\Magento\Framework\Interception\Code\Generator\TSample::class,
9191
\Magento\Framework\Interception\Code\Generator\TSample\Interceptor::class,
9292
'TInterceptor'
93-
]
93+
],
94+
[
95+
\Magento\Framework\Interception\Code\Generator\SampleBackendMenu::class,
96+
\Magento\Framework\Interception\Code\Generator\SampleBackendMenu\Interceptor::class,
97+
'SampleBackendMenuInterceptor',
98+
],
9499
];
95100
}
96101
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
namespace Magento\Framework\Interception\Code\Generator;
9+
10+
use Magento\Backend\Model\Menu;
11+
12+
class SampleBackendMenu extends Menu
13+
{
14+
15+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
namespace Magento\Framework\Interception\Code\Generator\SampleBackendMenu;
2+
3+
/**
4+
* Interceptor class for @see \Magento\Framework\Interception\Code\Generator\SampleBackendMenu
5+
*/
6+
class Interceptor extends \Magento\Framework\Interception\Code\Generator\SampleBackendMenu implements \Magento\Framework\Interception\InterceptorInterface
7+
{
8+
use \Magento\Framework\Interception\Interceptor;
9+
10+
public function __construct(\Psr\Log\LoggerInterface $logger, $pathInMenuStructure = '', ?\Magento\Backend\Model\Menu\Item\Factory $menuItemFactory = null, ?\Magento\Framework\Serialize\SerializerInterface $serializer = null)
11+
{
12+
$this->___init();
13+
parent::__construct($logger, $pathInMenuStructure, $menuItemFactory, $serializer);
14+
}
15+
16+
/**
17+
* {@inheritdoc}
18+
*/
19+
public function add(\Magento\Backend\Model\Menu\Item $item, $parentId = null, $index = null)
20+
{
21+
$pluginInfo = $this->pluginList->getNext($this->subjectType, 'add');
22+
return $pluginInfo ? $this->___callPlugins('add', func_get_args(), $pluginInfo) : parent::add($item, $parentId, $index);
23+
}
24+
25+
/**
26+
* {@inheritdoc}
27+
*/
28+
public function get($itemId)
29+
{
30+
$pluginInfo = $this->pluginList->getNext($this->subjectType, 'get');
31+
return $pluginInfo ? $this->___callPlugins('get', func_get_args(), $pluginInfo) : parent::get($itemId);
32+
}
33+
34+
/**
35+
* {@inheritdoc}
36+
*/
37+
public function move($itemId, $toItemId, $sortIndex = null)
38+
{
39+
$pluginInfo = $this->pluginList->getNext($this->subjectType, 'move');
40+
return $pluginInfo ? $this->___callPlugins('move', func_get_args(), $pluginInfo) : parent::move($itemId, $toItemId, $sortIndex);
41+
}
42+
43+
/**
44+
* {@inheritdoc}
45+
*/
46+
public function remove($itemId)
47+
{
48+
$pluginInfo = $this->pluginList->getNext($this->subjectType, 'remove');
49+
return $pluginInfo ? $this->___callPlugins('remove', func_get_args(), $pluginInfo) : parent::remove($itemId);
50+
}
51+
52+
/**
53+
* {@inheritdoc}
54+
*/
55+
public function reorder($itemId, $position)
56+
{
57+
$pluginInfo = $this->pluginList->getNext($this->subjectType, 'reorder');
58+
return $pluginInfo ? $this->___callPlugins('reorder', func_get_args(), $pluginInfo) : parent::reorder($itemId, $position);
59+
}
60+
61+
/**
62+
* {@inheritdoc}
63+
*/
64+
public function isLast(\Magento\Backend\Model\Menu\Item $item)
65+
{
66+
$pluginInfo = $this->pluginList->getNext($this->subjectType, 'isLast');
67+
return $pluginInfo ? $this->___callPlugins('isLast', func_get_args(), $pluginInfo) : parent::isLast($item);
68+
}
69+
70+
/**
71+
* {@inheritdoc}
72+
*/
73+
public function getFirstAvailable()
74+
{
75+
$pluginInfo = $this->pluginList->getNext($this->subjectType, 'getFirstAvailable');
76+
return $pluginInfo ? $this->___callPlugins('getFirstAvailable', func_get_args(), $pluginInfo) : parent::getFirstAvailable();
77+
}
78+
79+
/**
80+
* {@inheritdoc}
81+
*/
82+
public function getParentItems($itemId)
83+
{
84+
$pluginInfo = $this->pluginList->getNext($this->subjectType, 'getParentItems');
85+
return $pluginInfo ? $this->___callPlugins('getParentItems', func_get_args(), $pluginInfo) : parent::getParentItems($itemId);
86+
}
87+
88+
/**
89+
* {@inheritdoc}
90+
*/
91+
public function serialize()
92+
{
93+
$pluginInfo = $this->pluginList->getNext($this->subjectType, 'serialize');
94+
return $pluginInfo ? $this->___callPlugins('serialize', func_get_args(), $pluginInfo) : parent::serialize();
95+
}
96+
97+
/**
98+
* {@inheritdoc}
99+
*/
100+
public function toArray()
101+
{
102+
$pluginInfo = $this->pluginList->getNext($this->subjectType, 'toArray');
103+
return $pluginInfo ? $this->___callPlugins('toArray', func_get_args(), $pluginInfo) : parent::toArray();
104+
}
105+
106+
/**
107+
* {@inheritdoc}
108+
*/
109+
public function unserialize($serialized)
110+
{
111+
$pluginInfo = $this->pluginList->getNext($this->subjectType, 'unserialize');
112+
return $pluginInfo ? $this->___callPlugins('unserialize', func_get_args(), $pluginInfo) : parent::unserialize($serialized);
113+
}
114+
115+
/**
116+
* {@inheritdoc}
117+
*/
118+
public function populateFromArray(array $data)
119+
{
120+
$pluginInfo = $this->pluginList->getNext($this->subjectType, 'populateFromArray');
121+
return $pluginInfo ? $this->___callPlugins('populateFromArray', func_get_args(), $pluginInfo) : parent::populateFromArray($data);
122+
}
123+
}

0 commit comments

Comments
 (0)