From 572ba1695b8cb9d7df6738c38488eb1830d626aa Mon Sep 17 00:00:00 2001 From: Alex Blackham Date: Fri, 21 Jun 2019 10:44:31 +0100 Subject: [PATCH] The input()->all method will now set every key specified in the filter. If the key doesn't exist it will be set to null. --- src/Pecee/Http/Input/InputHandler.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Pecee/Http/Input/InputHandler.php b/src/Pecee/Http/Input/InputHandler.php index f05bf10..07c68d1 100644 --- a/src/Pecee/Http/Input/InputHandler.php +++ b/src/Pecee/Http/Input/InputHandler.php @@ -303,13 +303,22 @@ class InputHandler // Append any PHP-input json if (strpos(trim($contents), '{') === 0) { $post = json_decode($contents, true); + if ($post !== false) { $output += $post; } } } - return (\count($filter) > 0) ? array_intersect_key($output, array_flip($filter)) : $output; + $output = (\count($filter) > 0) ? array_intersect_key($output, array_flip($filter)) : $output; + + foreach ($filter as $value) { + if (!array_key_exists($value, $output)) { + $output[$value] = null; + } + } + + return $output; } /**