0

我有两节课:

class EntityVoter
{
    protected function canPutToBlockChain($entity, $viewer)
    {
        return false;
    }
}
class VerificationVoter extends EntityVoter
{
    public function canPutToBlockChain($entity, $viewer)
    {
        return $this->canShare($entity, $viewer);
    }
}

PHPMD 扫描 EntityVoter 类并抛出:避免使用未使用的参数,例如 '$entity'、'$viewer'。

我的解决方案是创建一个界面:

interface EntityVoterInterface 
{
     function canPutToBlockChain($entity, $viewer);
}

然后添加@inhericDoc注释:

class EntityVoter implements EntityVoterInterface
{
    /**
     * @inheritDoc
     */
    protected function canPutToBlockChain($entity, $viewer)
    {
        return false;
    }
}

有没有更好的解决方案?

4

0 回答 0