I have two class :
class EntityVoter
{
protected function canPutToBlockChain($entity, $viewer)
{
return false;
}
}
class VerificationVoter extends EntityVoter
{
public function canPutToBlockChain($entity, $viewer)
{
return $this->canShare($entity, $viewer);
}
}
PHPMD scan EntityVoter class and throw: Avoid unused parameters such as '$entity', '$viewer'.
My solution is creating a interface:
interface EntityVoterInterface
{
function canPutToBlockChain($entity, $viewer);
}
and then add @inhericDoc annotation:
class EntityVoter implements EntityVoterInterface
{
/**
* @inheritDoc
*/
protected function canPutToBlockChain($entity, $viewer)
{
return false;
}
}
Is there any better solution ?
Another option is to suppress PHPMD warning for the rule on the method:
For more information, see PHPMD Suppressing Warnings @ PHP Mess Detector documentation.
I would not use wildcard exclusion such as
@SuppressWarnings("unused")but targeted exclusion is OK for warnings linked to third-party code.