Skip to content

Commit

Permalink
Merge pull request #58 from amllano/master
Browse files Browse the repository at this point in the history
Skip "unused formal parameter" checking when method signature has been annotated as inherited using @inheritdoc
  • Loading branch information
manuelpichler committed Dec 14, 2012
2 parents 34cfbf3 + 9530047 commit 158e1f5
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/main/php/PHP/PMD/Rule/UnusedFormalParameter.php
Expand Up @@ -88,6 +88,10 @@ public function apply(PHP_PMD_AbstractNode $node)
if ($this->isAbstractMethod($node)) {
return;
}

if ($this->isInheritedSignature($node)) {
return;
}

if ($this->isNotDeclaration($node)) {
return;
Expand Down Expand Up @@ -117,7 +121,24 @@ private function isAbstractMethod(PHP_PMD_AbstractNode $node)
}
return false;
}


/**
* Returns <b>true</b> when the given node is method with signature declared as inherited using
* {@inheritdoc} annotation.
*
* @param PHP_PMD_AbstractNode $node The context method or function instance.
*
* @return boolean
*/
private function isInheritedSignature(PHP_PMD_AbstractNode $node)
{
if ($node instanceof PHP_PMD_Node_Method) {
return preg_match('/\@inheritdoc/', $node->getDocComment());
}

return false;
}

/**
* Tests if the given <b>$node</b> is a method and if this method is also
* the initial declaration.
Expand Down

0 comments on commit 158e1f5

Please sign in to comment.