diff --git a/src/Illuminate/Support/Arr.php b/src/Illuminate/Support/Arr.php index a9e09ce81287..df9f8a142eee 100755 --- a/src/Illuminate/Support/Arr.php +++ b/src/Illuminate/Support/Arr.php @@ -594,13 +594,17 @@ public static function where($array, callable $callback) } /** - * If the given value is not an array, wrap it in one. + * If the given value is not an array and not null, wrap it in one. * * @param mixed $value * @return array */ public static function wrap($value) { + if (is_null($value)) { + return []; + } + return ! is_array($value) ? [$value] : $value; } } diff --git a/tests/Support/SupportArrTest.php b/tests/Support/SupportArrTest.php index 794e9de2e46a..90644d9a5474 100644 --- a/tests/Support/SupportArrTest.php +++ b/tests/Support/SupportArrTest.php @@ -662,5 +662,6 @@ public function testWrap() $this->assertEquals(['a'], Arr::wrap($string)); $this->assertEquals($array, Arr::wrap($array)); $this->assertEquals([$object], Arr::wrap($object)); + $this->assertEquals([], Arr::wrap(null)); } }