PHP warning array_flip()
Opened this issue · 0 comments
PHP Warning: array_flip(): Can only flip STRING and INTEGER values! in /var/www/html/site/vendor/klein/klein/src/Klein/DataCollection/DataCollection.php on line 135
I am running PHP version 7.2.5 And I get the warning consistently when hitting routes where I use GET parameters.
So I went into DataCollection.php and found the all() function that seemed to be causing the problem.
I var_dump($mask) just before it is passed into array_flip(). To my surprise, I see that one of the values passed in is actually a BOOLEAN (false).
array(2) { [0]=> string(3) "new" [1]=> bool(false) }
I did not use that as part of my mask, but I notice that the mask is modified within the function, the rest of the function arguments are added in.
So I went over to Request.php, lines 282 thru 285 (the params() function)
return array_merge(
$attributes,
$this->params_get->all($mask, false),
$this->params_post->all($mask, false),
$this->cookies->all($mask, false),
$this->params_named->all($mask, false) // Add our named params last
);
There it is! A boolean is being passed in.