From 8d3b543f83097593f6ccb285815810500d2f0af6 Mon Sep 17 00:00:00 2001 From: Robbie Thompson Date: Thu, 28 Feb 2019 16:37:25 +0000 Subject: [PATCH] Check if MessageBag is empty before checking keys exist --- src/Illuminate/Support/MessageBag.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Illuminate/Support/MessageBag.php b/src/Illuminate/Support/MessageBag.php index 72fe683edb0b..b20bd77a7b7a 100755 --- a/src/Illuminate/Support/MessageBag.php +++ b/src/Illuminate/Support/MessageBag.php @@ -105,6 +105,10 @@ public function merge($messages) */ public function has($key) { + if ($this->isEmpty()) { + return false; + } + if (is_null($key)) { return $this->any(); } @@ -128,6 +132,10 @@ public function has($key) */ public function hasAny($keys = []) { + if ($this->isEmpty()) { + return false; + } + $keys = is_array($keys) ? $keys : func_get_args(); foreach ($keys as $key) {