workerman/workerman (v4.2.0 => v4.2.1)后webman报错

loaderwang

问题描述

今日更新后 运行报错 运行环境PHP8.3

程序代码

Method 'Webman\Http\Request::file()' is not compatible with method 'Workerman\Protocols\Http\Request::file()'

报错信息

Worker process terminated with ERROR: E_COMPILE_ERROR "Declaration of Webman\Http\Request::file($name = null) must be compatible with Workerman\Protocols\Http\Request::file(?string $name = null): mixed in D:\MyCode\BackEnd\ErpServer\vendor\workerman\webman-framework\src\Http\Request.php on line 119"
PHP Fatal error:  Declaration of Webman\Http\Request::file($name = null) must be compatible with Workerman\Protocols\Http\Request::file(?string $name = null): mixed in D:\MyCode\BackEnd\ErpServer\vendor\workerman\webman-framework\src\Http\Request.php on line 119

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

/**
 * File
 * @param string|null $name
 * @return null|UploadFile[]|UploadFile
 */
public function file($name = null)
{
    $files = parent::file($name);
    if (null === $files) {
        return $name === null ? [] : null;
    }
    if ($name !== null) {
        // Multi files
        if (is_array(current($files))) {
            return $this->parseFiles($files);
        }
        return $this->parseFile($files);
    }
    $uploadFiles = [];
    foreach ($files as $name => $file) {
        // Multi files
        if (is_array(current($file))) {
            $uploadFiles[$name] = $this->parseFiles($file);
        } else {
            $uploadFiles[$name] = $this->parseFile($file);
        }
    }
    return $uploadFiles;
}

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

"php": ">=7.2",
"workerman/webman-framework": "1.6.4",
"monolog/monolog": "^2.0",
"illuminate/database": "^11.27",
"laravel/serializable-closure": "^1.3",
"illuminate/pagination": "^11.32",
"psr/container": "^2.0",
"php-di/php-di": "^7.0",
"doctrine/annotations": "^2.0",
"illuminate/redis": "^11.32",
"illuminate/events": "^11.29",
"vlucas/phpdotenv": "^5.6"

550 1 0
1个回答

walkor 打赏

执行

composer config --unset repos.packagist
composer require workerman/webman-framework ^1.6.6 -W
  • loaderwang 2024-11-25

    嗯 可以了 应该是阿里源的问题 最新在1.6.4 更换源后 就能更新到1.6.6了

  • miraclesev 2024-11-26

    不用阿里源用哪个呢

  • 尚新 2024-11-27

    我执行完 还是报这个错 我用的是php 8.3.12 执行完上面的命令之后 直接升级到5.0.0-rc.3了

  • walkor 2024-11-27

    composer info | grep workerman 看下workerman/webman-framework升级成功了没

  • 尚新 2024-11-27

    升级到了1.7.x

  • walkor 2024-11-27

    composer require workerman/webman-framework 1.6.6

  • fklee 2024-11-27

    能不能回退v4.2.0,我本地2.0,线上不知道怎么更新到2.1了,也是错误

  • walkor 2024-11-27

    composer require workerman/workerman 4.2.0

  • walkor 2024-11-27

    学习下composer用法吧

  • 尚新 2024-11-27

    把阿里云镜像 却换成 腾讯云镜像 再升级成1.6.6就可以了
    composer config -g repos.packagist composer https://mirrors.tencent.com/composer/

  • happydigua 29天前

    @尚新 实测有效,感谢。

×
🔝