Skip to content

Commit c6c2f7e

Browse files
MAGETWO-70139: Fixed coding standard violations in the Framework\Interception namespace #9359
2 parents 5e5ac82 + 6148439 commit c6c2f7e

File tree

10 files changed

+64
-60
lines changed

10 files changed

+64
-60
lines changed

lib/internal/Magento/Framework/App/Utility/Files.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1391,7 +1391,8 @@ private function classFileExistsCheckContent($fullPath, $namespace, $className)
13911391
$fileContent = file_get_contents($fullPath);
13921392
if (strpos($fileContent, 'namespace ' . $namespace) !== false
13931393
&& (strpos($fileContent, 'class ' . $className) !== false
1394-
|| strpos($fileContent, 'interface ' . $className) !== false)
1394+
|| strpos($fileContent, 'interface ' . $className) !== false
1395+
|| strpos($fileContent, 'trait ' . $className) !== false)
13951396
) {
13961397
return true;
13971398
}

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

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
* See COPYING.txt for license details.
55
*/
66

7-
// @codingStandardsIgnoreFile
8-
97
namespace Magento\Framework\Interception\Code\Generator;
108

119
class Interceptor extends \Magento\Framework\Code\Generator\EntityAbstract
@@ -87,13 +85,8 @@ protected function _getClassMethods()
8785
*/
8886
protected function isInterceptedMethod(\ReflectionMethod $method)
8987
{
90-
return !($method->isConstructor() ||
91-
$method->isFinal() ||
92-
$method->isStatic() ||
93-
$method->isDestructor()) && !in_array(
94-
$method->getName(),
95-
['__sleep', '__wakeup', '__clone']
96-
);
88+
return !($method->isConstructor() || $method->isFinal() || $method->isStatic() || $method->isDestructor()) &&
89+
!in_array($method->getName(), ['__sleep', '__wakeup', '__clone']);
9790
}
9891

9992
/**
@@ -113,8 +106,8 @@ protected function _getMethodInfo(\ReflectionMethod $method)
113106
'name' => ($method->returnsReference() ? '& ' : '') . $method->getName(),
114107
'parameters' => $parameters,
115108
'body' => "\$pluginInfo = \$this->pluginList->getNext(\$this->subjectType, '{$method->getName()}');\n" .
116-
"if (!\$pluginInfo) {\n" .
117-
" return parent::{$method->getName()}({$this->_getParameterList(
109+
"if (!\$pluginInfo) {\n" .
110+
" return parent::{$method->getName()}({$this->_getParameterList(
118111
$parameters
119112
)});\n" .
120113
"} else {\n" .
@@ -160,8 +153,8 @@ protected function _generateCode()
160153
} else {
161154
$this->_classGenerator->setExtendedClass($typeName);
162155
}
163-
$this->_classGenerator->addTrait('\Magento\Framework\Interception\Interceptor');
164-
$interfaces[] = '\Magento\Framework\Interception\InterceptorInterface';
156+
$this->_classGenerator->addTrait('\\'. \Magento\Framework\Interception\Interceptor::class);
157+
$interfaces[] = '\\'. \Magento\Framework\Interception\InterceptorInterface::class;
165158
$this->_classGenerator->setImplementedInterfaces($interfaces);
166159
return parent::_generateCode();
167160
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6+
67
namespace Magento\Framework\Interception\Test\Unit\Code\Generator;
78

89
use Composer\Autoload\ClassLoader;

lib/internal/Magento/Framework/Interception/Test/Unit/Code/InterfaceValidatorTest.php

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@
44
* See COPYING.txt for license details.
55
*/
66

7-
// @codingStandardsIgnoreFile
8-
97
namespace Magento\Framework\Interception\Test\Unit\Code;
108

119
use \Magento\Framework\Interception\Code\InterfaceValidator;
10+
use \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\InterfaceValidator\ItemPlugin\ValidPlugin;
11+
use \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\InterfaceValidator\ItemPlugin\IncompatibleInterface;
12+
use \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\InterfaceValidator\ItemPlugin\IncorrectSubject;
13+
use \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\InterfaceValidator\ItemPlugin\ExtraParameters;
14+
use \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\InterfaceValidator\ItemPlugin\InvalidProceed;
1215

1316
class InterfaceValidatorTest extends \PHPUnit_Framework_TestCase
1417
{
@@ -51,7 +54,7 @@ protected function setUp()
5154
public function testValidate()
5255
{
5356
$this->model->validate(
54-
\Magento\Framework\Interception\Test\Unit\Custom\Module\Model\InterfaceValidator\ItemPlugin\ValidPlugin::class,
57+
ValidPlugin::class,
5558
\Magento\Framework\Interception\Test\Unit\Custom\Module\Model\InterfaceValidator\ItemWithArguments::class
5659
);
5760
}
@@ -64,20 +67,20 @@ public function testValidate()
6467
public function testValidateIncorrectInterface()
6568
{
6669
$this->model->validate(
67-
\Magento\Framework\Interception\Test\Unit\Custom\Module\Model\InterfaceValidator\ItemPlugin\IncompatibleInterface::class,
70+
IncompatibleInterface::class,
6871
\Magento\Framework\Interception\Test\Unit\Custom\Module\Model\InterfaceValidator\Item::class
6972
);
7073
}
7174

7275
/**
7376
* @expectedException \Magento\Framework\Exception\ValidatorException
74-
* @expectedExceptionMessage Invalid [\Magento\Framework\Interception\Test\Unit\Custom\Module\Model\Item] $subject type
77+
* @expectedExceptionMessage $subject type
7578
* @covers \Magento\Framework\Interception\Code\InterfaceValidator::validate
7679
*/
7780
public function testValidateIncorrectSubjectType()
7881
{
7982
$this->model->validate(
80-
\Magento\Framework\Interception\Test\Unit\Custom\Module\Model\InterfaceValidator\ItemPlugin\IncorrectSubject::class,
83+
IncorrectSubject::class,
8184
\Magento\Framework\Interception\Test\Unit\Custom\Module\Model\InterfaceValidator\Item::class
8285
);
8386
}
@@ -91,8 +94,8 @@ public function testValidateIncorrectSubjectType()
9194
public function testValidateIncompatibleMethodArgumentsCount()
9295
{
9396
$this->model->validate(
94-
\Magento\Framework\Interception\Test\Unit\Custom\Module\Model::class
95-
. '\InterfaceValidator\ItemPlugin\IncompatibleArgumentsCount',
97+
\Magento\Framework\Interception\Test\Unit\Custom\Module\Model::class .
98+
'\InterfaceValidator\ItemPlugin\IncompatibleArgumentsCount',
9699
\Magento\Framework\Interception\Test\Unit\Custom\Module\Model\InterfaceValidator\Item::class
97100
);
98101
}
@@ -106,8 +109,8 @@ public function testValidateIncompatibleMethodArgumentsCount()
106109
public function testValidateIncompatibleMethodArgumentsType()
107110
{
108111
$this->model->validate(
109-
\Magento\Framework\Interception\Test\Unit\Custom\Module\Model::class
110-
. '\InterfaceValidator\ItemPlugin\IncompatibleArgumentsType',
112+
\Magento\Framework\Interception\Test\Unit\Custom\Module\Model::class .
113+
'\InterfaceValidator\ItemPlugin\IncompatibleArgumentsType',
111114
\Magento\Framework\Interception\Test\Unit\Custom\Module\Model\InterfaceValidator\ItemWithArguments::class
112115
);
113116
}
@@ -120,7 +123,7 @@ public function testValidateIncompatibleMethodArgumentsType()
120123
public function testValidateExtraParameters()
121124
{
122125
$this->model->validate(
123-
\Magento\Framework\Interception\Test\Unit\Custom\Module\Model\InterfaceValidator\ItemPlugin\ExtraParameters::class,
126+
ExtraParameters::class,
124127
\Magento\Framework\Interception\Test\Unit\Custom\Module\Model\InterfaceValidator\Item::class
125128
);
126129
}
@@ -133,7 +136,7 @@ public function testValidateExtraParameters()
133136
public function testValidateInvalidProceed()
134137
{
135138
$this->model->validate(
136-
\Magento\Framework\Interception\Test\Unit\Custom\Module\Model\InterfaceValidator\ItemPlugin\InvalidProceed::class,
139+
InvalidProceed::class,
137140
\Magento\Framework\Interception\Test\Unit\Custom\Module\Model\InterfaceValidator\Item::class
138141
);
139142
}

lib/internal/Magento/Framework/Interception/Test/Unit/Config/ConfigTest.php

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Copyright © Magento, Inc. All rights reserved.
44
* See COPYING.txt for license details.
55
*/
6-
// @codingStandardsIgnoreFile
6+
77
namespace Magento\Framework\Interception\Test\Unit\Config;
88

99
use Magento\Framework\Serialize\SerializerInterface;
@@ -130,12 +130,15 @@ public function testHasPluginsWhenDataIsNotCached($expectedResult, $type, $entit
130130
\Magento\Framework\Interception\Custom\Module\Model\Backslash\ItemProxy::class
131131
],
132132
[
133-
'virtual_custom_item', \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\Item::class,
133+
'virtual_custom_item',
134+
\Magento\Framework\Interception\Test\Unit\Custom\Module\Model\Item::class
134135
],
135136
]
136137
));
137138
$this->definitionMock->expects($this->any())->method('getClasses')->will($this->returnValue(
138-
[\Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemProxy::class, \Magento\Framework\Interception\Custom\Module\Model\Backslash\ItemProxy::class,
139+
[
140+
\Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemProxy::class,
141+
\Magento\Framework\Interception\Custom\Module\Model\Backslash\ItemProxy::class
139142
]
140143
));
141144
$this->relationsMock->expects($this->any())->method('has')->will($this->returnValue($expectedResult));
@@ -155,7 +158,7 @@ public function testHasPluginsWhenDataIsNotCached($expectedResult, $type, $entit
155158
'relations' => $this->relationsMock,
156159
'omConfig' => $this->omConfigMock,
157160
'classDefinitions' => $this->definitionMock,
158-
'serializer' => $this->serializerMock,
161+
'serializer' => $this->serializerMock
159162
]
160163
);
161164

@@ -177,7 +180,7 @@ public function testHasPluginsWhenDataIsCached($expectedResult, $type)
177180
\Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemContainer\Enhanced::class => true,
178181
\Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemContainer\Proxy::class => true,
179182
\Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemProxy::class => false,
180-
'virtual_custom_item' => true,
183+
'virtual_custom_item' => true
181184
];
182185
$this->readerMock->expects($this->never())->method('read');
183186
$this->cacheMock->expects($this->never())->method('save');
@@ -205,7 +208,7 @@ public function testHasPluginsWhenDataIsCached($expectedResult, $type)
205208
'omConfig' => $this->omConfigMock,
206209
'classDefinitions' => $this->definitionMock,
207210
'cacheId' => $cacheId,
208-
'serializer' => $this->serializerMock,
211+
'serializer' => $this->serializerMock
209212
]
210213
);
211214

@@ -218,34 +221,34 @@ public function hasPluginsDataProvider()
218221
// item container has plugins only in the backend scope
219222
[
220223
true, \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemContainer::class,
221-
[],
224+
[]
222225
],
223226
[
224227
true, \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\Item::class,
225-
[],
228+
[]
226229
],
227230
[
228231
true, \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\Item\Enhanced::class,
229-
[],
232+
[]
230233
],
231234
[
232235
// the following model has only inherited plugins
233236
true, \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemContainer\Proxy::class,
234-
[\Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemContainer::class],
237+
[\Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemContainer::class]
235238
],
236239
[
237240
// the following model has only inherited plugins
238241
true, \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemContainer\Proxy::class,
239-
[\Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemContainer::class],
242+
[\Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemContainer::class]
240243
],
241244
[
242245
false, \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\ItemProxy::class,
243-
[],
246+
[]
244247
],
245248
[
246249
true,
247250
'virtual_custom_item',
248-
[],
251+
[]
249252
]
250253
];
251254
}

lib/internal/Magento/Framework/Interception/Test/Unit/Custom/Module/Model/InterfaceValidator/ItemPlugin/ExtraParameters.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
* See COPYING.txt for license details.
55
*/
66

7-
// @codingStandardsIgnoreFile
8-
97
namespace Magento\Framework\Interception\Test\Unit\Custom\Module\Model\InterfaceValidator\ItemPlugin;
108

119
class ExtraParameters
@@ -19,7 +17,9 @@ class ExtraParameters
1917
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
2018
*/
2119
public function afterGetItem(
22-
\Magento\Framework\Interception\Test\Unit\Custom\Module\Model\InterfaceValidator\Item $subject, $name, $surname
20+
\Magento\Framework\Interception\Test\Unit\Custom\Module\Model\InterfaceValidator\Item $subject,
21+
$name,
22+
$surname
2323
) {
2424
return $name . $surname;
2525
}

lib/internal/Magento/Framework/Interception/Test/Unit/Custom/Module/Model/InterfaceValidator/ItemPlugin/IncompatibleArgumentsCount.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
* See COPYING.txt for license details.
55
*/
66

7-
// @codingStandardsIgnoreFile
8-
97
namespace Magento\Framework\Interception\Test\Unit\Custom\Module\Model\InterfaceValidator\ItemPlugin;
108

119
class IncompatibleArgumentsCount
@@ -19,7 +17,9 @@ class IncompatibleArgumentsCount
1917
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
2018
*/
2119
public function beforeGetItem(
22-
\Magento\Framework\Interception\Test\Unit\Custom\Module\Model\InterfaceValidator\Item $subject, $name, $surname
20+
\Magento\Framework\Interception\Test\Unit\Custom\Module\Model\InterfaceValidator\Item $subject,
21+
$name,
22+
$surname
2323
) {
2424
return $name . $surname;
2525
}

lib/internal/Magento/Framework/Interception/Test/Unit/Custom/Module/Model/InterfaceValidator/ItemPlugin/IncompatibleArgumentsType.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,22 @@
44
* See COPYING.txt for license details.
55
*/
66

7-
// @codingStandardsIgnoreFile
8-
97
namespace Magento\Framework\Interception\Test\Unit\Custom\Module\Model\InterfaceValidator\ItemPlugin;
108

9+
use \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\InterfaceValidator\ItemWithArguments;
10+
1111
class IncompatibleArgumentsType
1212
{
1313
/**
14-
* @param \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\InterfaceValidator\ItemWithArguments $subject
14+
* @param ItemWithArguments $subject
1515
* @param array $names
1616
* @return int
1717
*
1818
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
1919
*/
2020
public function beforeGetItem(
21-
\Magento\Framework\Interception\Test\Unit\Custom\Module\Model\InterfaceValidator\ItemWithArguments $subject, array $names
21+
ItemWithArguments $subject,
22+
array $names
2223
) {
2324
return count($names);
2425
}

lib/internal/Magento/Framework/Interception/Test/Unit/Custom/Module/Model/InterfaceValidator/ItemPlugin/InvalidProceed.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
* See COPYING.txt for license details.
55
*/
66

7-
// @codingStandardsIgnoreFile
8-
97
namespace Magento\Framework\Interception\Test\Unit\Custom\Module\Model\InterfaceValidator\ItemPlugin;
108

119
class InvalidProceed
@@ -19,7 +17,9 @@ class InvalidProceed
1917
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
2018
*/
2119
public function aroundGetItem(
22-
\Magento\Framework\Interception\Test\Unit\Custom\Module\Model\InterfaceValidator\Item $subject, $name, $surname
20+
\Magento\Framework\Interception\Test\Unit\Custom\Module\Model\InterfaceValidator\Item $subject,
21+
$name,
22+
$surname
2323
) {
2424
return $name . $surname;
2525
}

lib/internal/Magento/Framework/Interception/Test/Unit/Custom/Module/Model/InterfaceValidator/ItemPlugin/ValidPlugin.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,48 +4,50 @@
44
* See COPYING.txt for license details.
55
*/
66

7-
// @codingStandardsIgnoreFile
8-
97
namespace Magento\Framework\Interception\Test\Unit\Custom\Module\Model\InterfaceValidator\ItemPlugin;
108

9+
use \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\InterfaceValidator\ItemWithArguments;
10+
1111
class ValidPlugin
1212
{
1313
/**
14-
* @param \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\InterfaceValidator\ItemWithArguments $subject
14+
* @param ItemWithArguments $subject
1515
* @param string $result
1616
* @return string
1717
*
1818
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
1919
*/
2020
public function afterGetItem(
21-
\Magento\Framework\Interception\Test\Unit\Custom\Module\Model\InterfaceValidator\ItemWithArguments $subject, $result
21+
ItemWithArguments $subject,
22+
$result
2223
) {
2324
return $result . '!';
2425
}
2526

2627
/**
27-
* @param \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\InterfaceValidator\ItemWithArguments $subject
28+
* @param ItemWithArguments $subject
2829
* @param $name
2930
* @return string
3031
*
3132
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
3233
*/
3334
public function beforeGetItem(
34-
\Magento\Framework\Interception\Test\Unit\Custom\Module\Model\InterfaceValidator\ItemWithArguments $subject, $name
35+
ItemWithArguments $subject,
36+
$name
3537
) {
3638
return '|' . $name;
3739
}
3840

3941
/**
40-
* @param \Magento\Framework\Interception\Test\Unit\Custom\Module\Model\InterfaceValidator\ItemWithArguments $subject
42+
* @param ItemWithArguments $subject
4143
* @param Closure $proceed
4244
* @param string $name
4345
* @return string
4446
*
4547
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
4648
*/
4749
public function aroundGetItem(
48-
\Magento\Framework\Interception\Test\Unit\Custom\Module\Model\InterfaceValidator\ItemWithArguments $subject,
50+
ItemWithArguments $subject,
4951
\Closure $proceed,
5052
$name
5153
) {

0 commit comments

Comments
 (0)