Skip to content

Commit a959d95

Browse files
committed
Fixed coding standard violations in the Framework\Interception namespace, so that it will be checked bij PHP CS and no longer be ignored while doing CI checks. Made the following changes:
- Removed @codingStandardsIgnoreFile from the head of the file. - Added use statement to so files in order to get shortes class names and fix line length - Fixed identation
1 parent bbe3ee0 commit a959d95

File tree

9 files changed

+65
-60
lines changed

9 files changed

+65
-60
lines changed

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

Lines changed: 10 additions & 12 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
@@ -88,9 +86,9 @@ protected function _getClassMethods()
8886
protected function isInterceptedMethod(\ReflectionMethod $method)
8987
{
9088
return !($method->isConstructor() ||
91-
$method->isFinal() ||
92-
$method->isStatic() ||
93-
$method->isDestructor()) && !in_array(
89+
$method->isFinal() ||
90+
$method->isStatic() ||
91+
$method->isDestructor()) && !in_array(
9492
$method->getName(),
9593
['__sleep', '__wakeup', '__clone']
9694
);
@@ -113,13 +111,13 @@ protected function _getMethodInfo(\ReflectionMethod $method)
113111
'name' => $method->getName(),
114112
'parameters' => $parameters,
115113
'body' => "\$pluginInfo = \$this->pluginList->getNext(\$this->subjectType, '{$method->getName()}');\n" .
116-
"if (!\$pluginInfo) {\n" .
117-
" return parent::{$method->getName()}({$this->_getParameterList(
114+
"if (!\$pluginInfo) {\n" .
115+
" return parent::{$method->getName()}({$this->_getParameterList(
118116
$parameters
119117
)});\n" .
120-
"} else {\n" .
121-
" return \$this->___callPlugins('{$method->getName()}', func_get_args(), \$pluginInfo);\n" .
122-
"}",
118+
"} else {\n" .
119+
" return \$this->___callPlugins('{$method->getName()}', func_get_args(), \$pluginInfo);\n" .
120+
"}",
123121
'docblock' => ['shortDescription' => '{@inheritdoc}'],
124122
];
125123

@@ -159,8 +157,8 @@ protected function _generateCode()
159157
} else {
160158
$this->_classGenerator->setExtendedClass($typeName);
161159
}
162-
$this->_classGenerator->addTrait('\Magento\Framework\Interception\Interceptor');
163-
$interfaces[] = '\Magento\Framework\Interception\InterceptorInterface';
160+
$this->_classGenerator->addTrait('\\'. \Magento\Framework\Interception\Interceptor::class);
161+
$interfaces[] = '\\'. \Magento\Framework\Interception\InterceptorInterface::class;
164162
$this->_classGenerator->setImplementedInterfaces($interfaces);
165163
return parent::_generateCode();
166164
}

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

Lines changed: 0 additions & 2 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\Code\Generator;
108

119
class InterceptorTest extends \PHPUnit_Framework_TestCase

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)