easy-swoole / easyswoole

swoole,easyswoole,swoole framework
https://www.easyswoole.com/
Apache License 2.0
4.75k stars 511 forks source link

[notice]:[Array to string conversion at file: easyswoole/easyswoole/src/Command/Utility.php line:43 #454

Closed getchu closed 3 years ago

getchu commented 3 years ago

当 配置文件(dev.php produce.php) 的 MAIN_SERVER . SETTING 启用 静态http server特性时,

如果配置的 value值 是 Array, 则报notice级别错, 比如:

'static_handler_locations' => ['/static'],

'http_index_files' => ['index.html'],

完整配置如下:

<?php
return [
    'SERVER_NAME' => "CL",
    'MAIN_SERVER' => [
        'LISTEN_ADDRESS' => '0.0.0.0',
        'PORT' => 9601,
        'SERVER_TYPE' => EASYSWOOLE_WEB_SOCKET_SERVER, //可选为 EASYSWOOLE_SERVER  EASYSWOOLE_WEB_SERVER EASYSWOOLE_WEB_SOCKET_SERVER
        'SOCK_TYPE' => SWOOLE_TCP,
        'RUN_MODEL' => SWOOLE_PROCESS,
        'SETTING' => [
            'worker_num' => swoole_cpu_num() * 2,
            'reload_async' => true,
            'max_wait_time'=>3,
            'package_max_length' => 256 * 1024 * 1024,

            'enable_coroutine' => true,
            'open_cpu_affinity' => true,
            'open_tcp_nodelay' => true,
            'max_coroutine' => 100000,
            'open_http2_protocol' => true,
            'max_request' => 10000,

            'http_compression' => true,
            'http_compression_level' => 1,
            'document_root'            => EASYSWOOLE_ROOT .'/Public',
            'enable_static_handler'    => true,
            'static_handler_locations' => ['/static'],
            'http_autoindex'           => true,
            'http_index_files'         => ['index.html'],
            'http_parse_files'         => true,
            'upload_tmp_dir'           => EASYSWOOLE_ROOT . '/Temp/uploads',
            'http_parse_cookie'        => false,
            'http_parse_post'          => true,
            'task_worker_num' => 0,
            'task_enable_coroutine' => false,
        ],
        'TASK'=>[
            'workerNum'=>4,
            'maxRunningNum'=>128,
            'timeout'=>30
        ]
    ],
    'TEMP_DIR' => null,
    'LOG_DIR' => null,
];

具体代码:

/vendor/easyswoole/easyswoole/src/Command/Utility.php line:43

    static function displayItem($name, $value)
    {
        if ($value === true) {
            $value = 'true';
        } else if ($value === false) {
            $value = 'false';
        } else if ($value === null) {
            $value = 'null';
        }
        return "\e[32m" . str_pad($name, 30, ' ', STR_PAD_RIGHT) . "\e[34m" . $value . "\e[0m";
    }

修改建议: 对数组类型的$value, 添加多一个逻辑判断

 else if (is_array($value)) {
     $value = json_encode($value, JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES);;
 }
kiss291323003 commented 3 years ago

好的。

Player626 commented 3 years ago

https://github.com/easy-swoole/easyswoole/commit/5f6b208f293e7ff474ff6ad3cb1cbdcf443f1e75