Skip to content

Commit 32993d2

Browse files
author
Oleksandr Gorkun
committed
MAGETWO-95945: Add a code mess rule for improper session and cookies usages
1 parent 9f92a45 commit 32993d2

File tree

2 files changed

+28
-33
lines changed

2 files changed

+28
-33
lines changed

app/code/Magento/Customer/Model/FileProcessor.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
/**
1111
* Class FileProcessor
12-
* @package Magento\Customer\Model
1312
*/
1413
class FileProcessor
1514
{

dev/tests/static/framework/Magento/CodeMessDetector/Rule/Design/CookieAndSessionMisuse.php

Lines changed: 28 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -74,25 +74,23 @@ private function isUiDocument(\ReflectionClass $class): bool
7474
*/
7575
private function isControllerPlugin(\ReflectionClass $class): bool
7676
{
77-
try {
78-
foreach ($class->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) {
79-
if (preg_match('/^(after|around|before).+/i', $method->getName())) {
80-
try {
81-
$argument = $method->getParameters()[0]->getClass();
82-
} catch (\ReflectionException $exception) {
83-
//Non-existing class (autogenerated perhaps)
84-
continue;
85-
}
86-
$isAction = $argument->isSubclassOf(\Magento\Framework\App\ActionInterface::class)
87-
|| $argument->getName() === \Magento\Framework\App\ActionInterface::class;
88-
if ($isAction) {
89-
return true;
90-
}
77+
foreach ($class->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) {
78+
if (preg_match('/^(after|around|before).+/i', $method->getName())) {
79+
try {
80+
$argument = $method->getParameters()[0]->getClass();
81+
} catch (\ReflectionException $exception) {
82+
//Non-existing class (autogenerated perhaps)
83+
continue;
84+
}
85+
$isAction = $argument->isSubclassOf(\Magento\Framework\App\ActionInterface::class)
86+
|| $argument->getName() === \Magento\Framework\App\ActionInterface::class;
87+
if ($isAction) {
88+
return true;
9189
}
9290
}
93-
} catch (\Throwable $exception) {
94-
return false;
9591
}
92+
93+
return false;
9694
}
9795

9896
/**
@@ -103,25 +101,23 @@ private function isControllerPlugin(\ReflectionClass $class): bool
103101
*/
104102
private function isBlockPlugin(\ReflectionClass $class): bool
105103
{
106-
try {
107-
foreach ($class->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) {
108-
if (preg_match('/^(after|around|before).+/i', $method->getName())) {
109-
try {
110-
$argument = $method->getParameters()[0]->getClass();
111-
} catch (\ReflectionException $exception) {
112-
//Non-existing class (autogenerated perhaps)
113-
continue;
114-
}
115-
$isBlock = $argument->isSubclassOf(\Magento\Framework\View\Element\BlockInterface::class)
116-
|| $argument->getName() === \Magento\Framework\View\Element\BlockInterface::class;
117-
if ($isBlock) {
118-
return true;
119-
}
104+
foreach ($class->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) {
105+
if (preg_match('/^(after|around|before).+/i', $method->getName())) {
106+
try {
107+
$argument = $method->getParameters()[0]->getClass();
108+
} catch (\ReflectionException $exception) {
109+
//Non-existing class (autogenerated perhaps)
110+
continue;
111+
}
112+
$isBlock = $argument->isSubclassOf(\Magento\Framework\View\Element\BlockInterface::class)
113+
|| $argument->getName() === \Magento\Framework\View\Element\BlockInterface::class;
114+
if ($isBlock) {
115+
return true;
120116
}
121117
}
122-
} catch (\Throwable $exception) {
123-
return false;
124118
}
119+
120+
return false;
125121
}
126122

127123
/**

0 commit comments

Comments
 (0)