Skip to content

Commit

Permalink
Merge pull request #737 from ondrejfuhrer/ondrejfuhrer-static-access-…
Browse files Browse the repository at this point in the history
…allow-custom-exclusion

Allowing custom exclusion for StaticAccess by extending the class
  • Loading branch information
kylekatarnls committed Feb 25, 2020
2 parents 5f949a0 + bb2b093 commit c7618e4
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/main/php/PHPMD/Rule/CleanCode/StaticAccess.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,18 @@ public function apply(AbstractNode $node)
}

$className = $methodCall->getChild(0)->getNode()->getImage();
if (in_array(trim($className, " \t\n\r\0\x0B\\"), $exceptions)) {
if ($this->isExcludedFromAnalysis($className, $exceptions)) {
continue;
}

$this->addViolation($methodCall, array($className, $node->getName()));
}
}

protected function isExcludedFromAnalysis($className, $exceptions)
{
return in_array(trim($className, " \t\n\r\0\x0B\\"), $exceptions);
}

private function isStaticMethodCall(AbstractNode $methodCall)
{
Expand Down

0 comments on commit c7618e4

Please sign in to comment.