周梦康 发表于 2019-01-20 923 次浏览 标签 : php
abstract class KeyManagerAbstract
{
    /**
     * 类似于
     *
     * return [
     *    self::UCC_USER_DETAIL => ["ucc:user:h:%d", 10],
     * ];
     *
     * @return array
     */
    abstract protected static function hashMap();

    public static function getHashKey(string $format, int $id)
    {

    }
}

class KeyManager extends KeyManagerAbstract
{
    protected static function hashMap()
    {
        // TODO: Implement hashMap() method.
    }
}

php 7.2 之前这样写是会报错

Fatal error: Can't inherit abstract function

php 7.2 则支持了abstract function override

评论列表