/usr/share/php/PHP/PMD/Rule/CleanCode/StaticAccess.php is in phpmd 1.5.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | <?php
require_once 'PHP/PMD/AbstractRule.php';
require_once 'PHP/PMD/Rule/IMethodAware.php';
require_once 'PHP/PMD/Rule/IFunctionAware.php';
/**
* Check if static access is used in a method.
*
* Static access is known to cause hard dependencies between classes
* and is a bad practice.
*/
class PHP_PMD_Rule_CleanCode_StaticAccess
extends PHP_PMD_AbstractRule
implements PHP_PMD_Rule_IMethodAware,
PHP_PMD_Rule_IFunctionAware
{
public function apply(PHP_PMD_AbstractNode $node)
{
$staticReferences = $node->findChildrenOfType('ClassOrInterfaceReference');
foreach ($staticReferences as $reference) {
if ($this->isReferenceInParameter($reference)) {
continue;
}
$this->addViolation($reference, array($reference->getImage(), $node->getImage()));
}
}
private function isReferenceInParameter($reference)
{
return $reference->getParent()->getNode() instanceof PHP_Depend_Code_ASTFormalParameter;
}
}
|