diff --git a/src/Illuminate/Support/Arr.php b/src/Illuminate/Support/Arr.php index 3759b04b8c2f..456b867f026c 100755 --- a/src/Illuminate/Support/Arr.php +++ b/src/Illuminate/Support/Arr.php @@ -262,7 +262,7 @@ public static function forget(&$array, $keys) */ public static function get($array, $key, $default = null) { - if (! $array) { + if (! static::accessible($array)) { return value($default); } diff --git a/tests/Support/SupportArrTest.php b/tests/Support/SupportArrTest.php index 8651076e76e9..3b37d761f534 100644 --- a/tests/Support/SupportArrTest.php +++ b/tests/Support/SupportArrTest.php @@ -182,8 +182,13 @@ public function testGet() $this->assertNull(Arr::get($array, 'bar.baz', 'default')); // Test $array not an array - $this->assertEquals('default', Arr::get(null, 'foo', 'default')); - $this->assertEquals('default', Arr::get(false, 'foo', 'default')); + $this->assertSame('default', Arr::get(null, 'foo', 'default')); + $this->assertSame('default', Arr::get(false, 'foo', 'default')); + $this->assertSame('default', Arr::get(null, null, 'default')); + + // Test $array is empty and key is null + $this->assertSame([], Arr::get([], null)); + $this->assertSame([], Arr::get([], null, 'default')); } public function testHas()