PHP 7.2 abstract function override 的使用

简介: PHP 7.2 abstract function override 的使用
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

11

目录
相关文章
|
9月前
|
PHP
PHP报错Call to undefined function utf8_decode()的解决方案
PHP报错Call to undefined function utf8_decode()的解决方案
|
9月前
|
PHP
漏刻有时环境部署:php安装提示Can‘t use function return value in write context
漏刻有时环境部署:php安装提示Can‘t use function return value in write context
38 0
|
消息中间件 PHP
laravel6 使用rabbitmq报错:Call to a member function make() on null at Queue\\Jobs\\Job.php:215
laravel6 使用rabbitmq报错:Call to a member function make() on null at Queue\\Jobs\\Job.php:215
129 0
|
PHP Windows
php使用register_tick_function来定位执行慢的代码
php使用register_tick_function来定位执行慢的代码
164 0
|
存储 PHP
PHP 零基础入门笔记(9):函数 function
PHP 零基础入门笔记(9):函数 function
|
PHP
【PHP报错集锦】 Maximum function nesting level of ‘256‘ reached, aborting!
【PHP报错集锦】 Maximum function nesting level of ‘256‘ reached, aborting!
415 0
【PHP报错集锦】 Maximum function nesting level of ‘256‘ reached, aborting!