Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AllPurposeAction.php
Go to the documentation of this file.
1 <?php
7 declare(strict_types=1);
8 
10 
11 use PDepend\Source\AST\ASTClass;
12 use PHPMD\AbstractNode;
13 use PHPMD\AbstractRule;
14 use PHPMD\Node\ClassNode;
15 use PHPMD\Rule\ClassAware;
17 
21 class AllPurposeAction extends AbstractRule implements ClassAware
22 {
28  public function apply(AbstractNode $node)
29  {
30  try {
31  $impl = class_implements($node->getFullQualifiedName(), true);
32  } catch (\Throwable $exception) {
33  //Couldn't load a class.
34  return;
35  }
36 
37  if (in_array(ActionInterface::class, $impl, true)) {
38  $methodsDefined = false;
39  foreach ($impl as $i) {
40  if (preg_match('/\\\Http[a-z]+ActionInterface$/i', $i)) {
41  $methodsDefined = true;
42  break;
43  }
44  }
45  if (!$methodsDefined) {
46  $this->addViolation($node, [$node->getFullQualifiedName()]);
47  }
48  }
49  }
50 }
$i
Definition: gallery.phtml:31