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"

63 1 0
1个回答

walkor 打赏

执行 composer require workerman/webman-framework ^1.6.6

  • loaderwang 13小时前

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

×
🔝