[英]Luracast Restler Validator returns warning about expecting string, getting array
I'm sending the following json: {"name":"New event"}
我发送以下json:
{"name":"New event"}
to a PATCH handler: function patch($id, $request_data = NULL)
到PATCH处理程序:
function patch($id, $request_data = NULL)
but am getting the following warning: Warning: strlen() expects parameter 1 to be string, array given in /public_html/vendor/Luracast/Restler/Data/Validator.php on line 115
但是我收到以下警告:
Warning: strlen() expects parameter 1 to be string, array given in /public_html/vendor/Luracast/Restler/Data/Validator.php on line 115
The source at that line is: 该行的来源是:
switch ($info->type) {
...
case 'string' :
$r = strlen($input);
So I added some code to the first line of Validator.validate() see what it thinks the variables are: 所以我在Validator.validate()的第一行添加了一些代码,看看它认为变量是什么:
print("$input: $info->type\n");
and I get this: 我明白了
1: int
Array: string
So it thinks the array is a string. 所以它认为数组是一个字符串。 It is still able to continue and process the request, but it returns this warning as the response instead of something valid I can process.
它仍然能够继续并处理请求,但它会将此警告作为响应返回,而不是我可以处理的有效内容。
Any ideas what I'm doing wrong? 我有什么想法我做错了吗?
v3分支中的最新版本(Restler 3 RC4)修复了此问题
I had this problem too, but that's because I gave param
wrong type. 我也有这个问题,但那是因为我给了
param
错误的类型。
For example 例如
@param string $request_data
change type 改变类型
string to mixed
the problem will be solved. 问题将得到解决。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.