Skip to content

Commit a8c0e9b

Browse files
authored
Merge pull request #33432 from AntonEvers/phpmd
Resolve warnings in PHPMD execution Fixes #33430
2 parents 404a4e2 + e62a2fe commit a8c0e9b

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ public function apply(AbstractNode $node)
3232
return;
3333
}
3434
try {
35+
if (!class_exists($node->getFullQualifiedName(), true)) {
36+
return;
37+
}
3538
$impl = class_implements($node->getFullQualifiedName(), true);
3639
} catch (\Throwable $exception) {
3740
//Couldn't load a class.

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,11 @@ private function isControllerPlugin(\ReflectionClass $class): bool
110110
foreach ($class->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) {
111111
if (preg_match('/^(after|around|before).+/i', $method->getName())) {
112112
try {
113-
$argument = $this->getParameterClass($method->getParameters()[0]);
113+
$parameters = $method->getParameters();
114+
if (count($parameters) === 0) {
115+
continue;
116+
}
117+
$argument = $this->getParameterClass($parameters[0]);
114118
} catch (\Throwable $exception) {
115119
//Non-existing class (autogenerated perhaps) or doesn't have an argument.
116120
continue;
@@ -139,7 +143,11 @@ private function isBlockPlugin(\ReflectionClass $class): bool
139143
foreach ($class->getMethods(\ReflectionMethod::IS_PUBLIC) as $method) {
140144
if (preg_match('/^(after|around|before).+/i', $method->getName())) {
141145
try {
142-
$argument = $this->getParameterClass($method->getParameters()[0]);
146+
$parameters = $method->getParameters();
147+
if (count($parameters) === 0) {
148+
continue;
149+
}
150+
$argument = $this->getParameterClass($parameters[0]);
143151
} catch (\Throwable $exception) {
144152
//Non-existing class (autogenerated perhaps) or doesn't have an argument.
145153
continue;

0 commit comments

Comments
 (0)