1

I have interface X

interface X
{
    public function foo($x, $y = 0);
}

then I have class

class xx implements X
{
    public function foo($x, $y = 0)
    {
        // use $x, but not $y
    }
}

This is perfectly normal, because I do not want to use optional $y in this implementation of X. But PMD yells that $y is unused parameter.

What can I do to easily change PMD behaviour? Only solution that I found was to suppress the warning with @SuppressWarnings(unused) annotation, bet thats not what I really like.

Mantas
  • 4,259
  • 2
  • 27
  • 32

1 Answers1

2

You can use {@inheritdoc}, which was introduced in this commit to skip the check for implemented methods. to this day i guess this is the only solution to this problem.

Just add this as DocBlock for the implemented method

/**
 * {@inheritdoc}
 */
Martin Trenker
  • 167
  • 1
  • 8