Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

绑定路由参数,如果请求的参数为索引数组,路由参数取值不是url地址参数,而是body参数 #2555

Open
wants to merge 1 commit into
base: 6.0
Choose a base branch
from

Conversation

Tinywan
Copy link

@Tinywan Tinywan commented Jun 29, 2021

例如:

  • 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

例如:
- 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
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant