0

私は2つのクラスを持っています:

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