我有接口X
interface X { public function foo($x, $y = 0); }
那么我有课
class xx implements X { public function foo($x, $y = 0) { // use $x, but not $y } }
这很正常,因为我不想使用可选 $y 在此实施中 X 。但PMD警告$y是未使用的参数。
$y
X
我可以做什么来轻松改变PMD的行为?我找到的唯一解决方案是用 @SuppressWarnings(unused) 注释,这肯定不是我真正喜欢的。
@SuppressWarnings(unused)
您可以使用 {@inheritdoc} ,在中引入 this commit 跳过对已实现方法的检查。时至今日,我想这是解决这个问题的唯一办法。
{@inheritdoc}
只需将其添加为已实现方法的DocBlock
/** * {@inheritdoc} */