php8.4 webman/think-cache安装后报错:函数参数nullable类型声明不兼容

Elaborate

问题描述

安装think-cache后报错,php8.4 函数参数类型声明不兼容

报错信息

ErrorException: Webman\ThinkCache\CacheManager::getConfig(): Implicitly marking parameter $name as nullable is deprecated, the explicit nullable type must be used instead in /app/vendor/webman/think-cache/src/CacheManager.php:50

截图报错信息里报错文件相关代码

操作系统及workerman/webman等框架组件具体版本

PHP/8.4.4 (Jit off)
webmanV2.1.2

318 2 0
2个回答

jack10082009

我记得从PHP8.4开始,如果指定变量类型(严格模式)的话,函数的string形参默认值不能为null。你可以将其默认值改为''(空字符串)。但是这样下面如果使用了(??)这个简化的null检查三元运算符应该改为(?:)这个简化的空检查三元运算符。
可以看一下PHP官方文档中有这个相关说明。

  • Elaborate 5天前

    是的,我看有提交pr都没合并,估计不更新了。

刚发了 v2.1.2 试下

  • AMG 5天前

    v2.1.2也是报错: ErrorException: Webman\ThinkCache\CacheManager::getConfig(): Implicitly marking parameter $name as nullable is deprecated, the explicit nullable type must be used instead in

  • walkor 5天前

    升级后重启下

  • AMG 5天前

    重启过了, 重新建一个新的项目, 然后再重启也是一样

  • walkor 5天前

    执行composer info 版本,看下是否真的升级成功了

  • AMG 5天前

    webman/think-cache 2.1.1
    workerman/webman-framework 2.1.2 High performance HTTP Service Framework.
    workerman/workerman 5.1.1 An asynchronous event driven PHP framework for easily building fast, scalable network applications.

  • walkor 5天前

    webman/think-cache 2.1.2

  • AMG 5天前

    执行: composer require webman/think-cache v2.1.2
    报错:
    Problem 1

    • Root composer.json requires webman/think-cache v2.1.2 (exact version match), found webman/think-cache[dev-main, v1.0.1, v1.0.2, v2.1.0, v2.1.1] but it does not match the constraint.
  • walkor 5天前

    不要用 composer 代理

  • AMG 5天前

    好的 好的, 可以啦 😁

×
🔝