From cc74b52392b82d5d1b4befb5a222fae6941e9d16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?ShaoBo=20Wan=28=E7=84=A1=E5=B0=98=29?= <756684177@qq.com> Date: Tue, 29 Jun 2021 18:20:14 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=91=E5=AE=9A=E8=B7=AF=E7=94=B1=E5=8F=82?= =?UTF-8?q?=E6=95=B0=EF=BC=8C=E5=A6=82=E6=9E=9C=E8=AF=B7=E6=B1=82=E7=9A=84?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E4=B8=BA=E7=B4=A2=E5=BC=95=E6=95=B0=E7=BB=84?= =?UTF-8?q?=EF=BC=8C=E8=B7=AF=E7=94=B1=E5=8F=82=E6=95=B0=E5=8F=96=E5=80=BC?= =?UTF-8?q?=E4=B8=8D=E6=98=AFurl=E5=9C=B0=E5=9D=80=E5=8F=82=E6=95=B0?= =?UTF-8?q?=EF=BC=8C=E8=80=8C=E6=98=AFbody=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 例如: - route 绑定参数: `http://capi.train.tinywan.cn/h/v1/user/{{uid}}/info-save` 请求地址: `http://capi.train.tinywan.cn/h/v1/user/10478916/info-save` - post param ``` { "10086": "Tinywan", "10000": "mobile" } ``` 定义方法 ``` /** * @param int $uid * @return Response */ public function infoSave(int $uid): Response{} ``` 最后的参数是: ``` array(3) { [ 0 ]=> string(7) "Tinywan" [ 1 ]=> string(6) "mobile" [ "uid" ]=> string(8) "10478916" } ``` 最后传入的参数 `infoSave(Tinywan)` 错误信息 ``` Argument 1 passed to app\\controller\\home\\v1\\User::infoSave() must be of the type int, string given ``` --- src/think/Request.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/think/Request.php b/src/think/Request.php index 4cb208fcfd..192c55c785 100644 --- a/src/think/Request.php +++ b/src/think/Request.php @@ -858,8 +858,7 @@ public function param($name = '', $default = null, $filter = '') } // 当前请求参数和URL地址中的参数合并 - $this->param = array_merge($this->param, $this->get(false), $vars, $this->route(false)); - + $this->param = array_merge($this->param, $this->route(false), $this->get(false), $vars); $this->mergeParam = true; }