hyperf / hyperf

🚀 A coroutine framework that focuses on hyperspeed and flexibility. Building microservice or middleware with ease.
https://www.hyperf.io
MIT License
6.22k stars 1.21k forks source link

[BUG] 代理的方法如果使用了...运算符,实际的参数有错 #1347

Closed hectorqin closed 4 years ago

hectorqin commented 4 years ago

Execute the command and paste the result below.

Command: uname -a && php -v && composer info | grep hyperf && php --ri swoole

Darwin hectordeair 18.7.0 Darwin Kernel Version 18.7.0: Sat Oct 12 00:02:19 PDT 2019; root:xnu-4903.278.12~1/RELEASE_X86_64 x86_64
PHP 7.2.27 (cli) (built: Jan 24 2020 03:49:45) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
    with Zend OPcache v7.2.27, Copyright (c) 1999-2018, by Zend Technologies
hectorqin/hyperf-generator              dev-master Hyperf generator
hectorqin/hyperf-thinkphp               dev-master Some thinkphp features...
hyperf/async-queue                      v1.1.17    A async queue componen...
hyperf/cache                            v1.1.13    A cache component for ...
hyperf/command                          v1.1.8     Command for hyperf
hyperf/config                           v1.1.7     An independent compone...
hyperf/constants                        v1.1.13    A constants component ...
hyperf/contract                         v1.1.9     The contracts of Hyperf.
hyperf/crontab                          v1.1.17    A crontab component fo...
hyperf/database                         v1.1.17    A flexible database li...
hyperf/db-connection                    v1.1.11    A hyperf db connection...
hyperf/devtool                          v1.1.17    A Devtool for Hyperf.
hyperf/di                               v1.1.14    A DI for Hyperf.
hyperf/dispatcher                       v1.1.3     A HTTP Server for Hyperf.
hyperf/event                            v1.1.3     an event manager that ...
hyperf/exception-handler                v1.1.6     Exception handler for ...
hyperf/framework                        v1.1.16    A coroutine framework ...
hyperf/guzzle                           v1.1.10    Swoole coroutine handl...
hyperf/http-message                     v1.1.13    microservice framework...
hyperf/http-server                      v1.1.13    A HTTP Server for Hyperf.
hyperf/logger                           v1.1.16    A logger component for...
hyperf/memory                           v1.1.3     An independent compone...
hyperf/model-listener                   v1.1.7     A model listener for H...
hyperf/paginator                        v1.1.17    A paginator component ...
hyperf/pool                             v1.1.17    An independent univers...
hyperf/process                          v1.1.16    A process component fo...
hyperf/redis                            v1.1.8     A redis component for ...
hyperf/server                           v1.1.7     A base server library ...
hyperf/session                          v1.1.17    A session library
hyperf/testing                          v1.1.4     Testing for hyperf
hyperf/translation                      v1.1.17    An independent transla...
hyperf/utils                            v1.1.17    A tools package that c...
hyperf/validation                       v1.1.17    hyperf validation
hyperf/websocket-client                 v1.1.8     A websocket client lib...
hyperf/websocket-server                 v1.1.3     A websocket server lib...

swoole

Swoole => enabled
Author => Swoole Team <team@swoole.com>
Version => 4.4.15
Built => Feb 13 2020 09:38:39
coroutine => enabled
kqueue => enabled
rwlock => enabled
sockets => enabled
openssl => OpenSSL 1.1.1d  10 Sep 2019
http2 => enabled
pcre => enabled
zlib => 1.2.11
brotli => E16777223/D16777223
mysqlnd => enabled
async_redis => enabled

Directive => Local Value => Master Value
swoole.enable_coroutine => On => On
swoole.enable_library => On => On
swoole.enable_preemptive_scheduler => Off => Off
swoole.display_errors => On => On
swoole.use_shortname => Off => Off
swoole.unixsock_buffer_size => 262144 => 262144

Description:

   //原方法
    /**
     * 异步发送短信验证码
     * @AsyncQueueMessage
     */
    public function sendCodeAsync(...$params)
    {
        return $this->sendMsg('sendCode', $params);
    }

   // 代理类方法
    /**
     * 异步发送短信验证码
     * @AsyncQueueMessage
     */
    public function sendCodeAsync(...$params)
    {
        $__function__ = __FUNCTION__;
        $__method__ = __METHOD__;
        return self::__proxyCall(SMSService::class, __FUNCTION__, self::getParamsMap(SMSService::class, __FUNCTION__, func_get_args()), function ($params) use($__function__, $__method__) {
            return $this->sendMsg('sendCode',$params);
        });
    }

代理的方法如果使用了 … 运算符,那么实际获取的参数是 [$params]

Steps To Reproduce:

limingxinleo commented 4 years ago

我记得这个问题应该处理过了。。。

https://github.com/hyperf/hyperf/pull/1199

好像只处理了 Task 。。。

Reasno commented 4 years ago

我看DI组件生成代理的时候有判断variadic啊 实际没测过

limingxinleo commented 4 years ago

你按照这个 PR 里,这里修改的内容,修改一下看看

image