top-think / think-swoole

Swoole extend for thinkphp
Apache License 2.0
462 stars 105 forks source link

与thinkphp 8.0不兼容,运行报错 #359

Closed YvesHo0968 closed 1 year ago

YvesHo0968 commented 1 year ago

环境

php 8.1 swoole 4.8.13

topthink/framework thinkphp 8.0.3 topthink/think-swoole 4.0.11

错误信息

php think swoole
Starting swoole server...
You can exit with `CTRL-C`
PHP Fatal error:  Declaration of think\swoole\pool\proxy\Store::inc(string $name, int $step = 1) must be compatible with think\contract\CacheHandlerInterface::inc($name, $step = 1) in /tp/tp2/vendor/topthink/think-swoole/src/pool/proxy/Store.php on line 38

应该修改

路径 vendor/topthink/think-swoole/src/pool/proxy/Store.php

# 需要修改的地方源代码
    /**
     * @inheritDoc
     */
    public function inc(string $name, int $step = 1)
    {
        return $this->__call(__FUNCTION__, func_get_args());
    }

    /**
     * @inheritDoc
     */
    public function dec(string $name, int $step = 1)
    {
        return $this->__call(__FUNCTION__, func_get_args());
    }

    /**
     * @inheritDoc
     */
    public function clearTag(array $keys)
    {
        return $this->__call(__FUNCTION__, func_get_args());
    }

# 修改成 
    /**
     * @inheritDoc
     */
    public function inc($name, $step = 1)
    {
        return $this->__call(__FUNCTION__, func_get_args());
    }

    /**
     * @inheritDoc
     */
    public function dec($name, $step = 1)
    {
        return $this->__call(__FUNCTION__, func_get_args());
    }

    /**
     * @inheritDoc
     */
    public function clearTag($keys)
    {
        return $this->__call(__FUNCTION__, func_get_args());
    }

# 增加以下代码

    /**
     * @inheritDoc
     */
    public function pull($name): mixed
    {
        return $this->__call(__FUNCTION__, func_get_args());
    }

    /**
     * @inheritDoc
     */
    public function remember($name, $value, $expire = null): mixed
    {
        return $this->__call(__FUNCTION__, func_get_args());
    }
sy-records commented 1 year ago

Fixed via https://github.com/top-think/think-swoole/commit/6dd42498665db445c8bd89172e89bc7b5e008130