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

PHP warning array_flip() #391

Open
eric-hoppenworth opened this issue May 17, 2018 · 0 comments
Open

PHP warning array_flip() #391

eric-hoppenworth opened this issue May 17, 2018 · 0 comments

Comments

@eric-hoppenworth
Copy link

eric-hoppenworth commented May 17, 2018

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.

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

No branches or pull requests

1 participant