diff --git a/src/Illuminate/Collections/Arr.php b/src/Illuminate/Collections/Arr.php index 49b17766499a..ffa73e50165b 100644 --- a/src/Illuminate/Collections/Arr.php +++ b/src/Illuminate/Collections/Arr.php @@ -172,7 +172,7 @@ public static function dot($array, $prepend = '') if (is_array($value) && ! empty($value)) { $flatten($value, $newKey.'.'); } else { - $results[$newKey] = $value; + $results[$newKey] = is_array($value) ? null : $value; } } }; diff --git a/tests/Support/SupportArrTest.php b/tests/Support/SupportArrTest.php index ab5c2f2150a7..13504fb65a37 100644 --- a/tests/Support/SupportArrTest.php +++ b/tests/Support/SupportArrTest.php @@ -217,10 +217,10 @@ public function testDot() $this->assertSame([], $array); $array = Arr::dot(['foo' => []]); - $this->assertSame(['foo' => []], $array); + $this->assertSame(['foo' => null], $array); $array = Arr::dot(['foo' => ['bar' => []]]); - $this->assertSame(['foo.bar' => []], $array); + $this->assertSame(['foo.bar' => null], $array); $array = Arr::dot(['name' => 'taylor', 'languages' => ['php' => true]]); $this->assertSame(['name' => 'taylor', 'languages.php' => true], $array); @@ -243,7 +243,7 @@ public function testDot() $array = Arr::dot(['foo' => 'bar', 'empty_array' => [], 'user' => ['name' => 'Taylor'], 'key' => 'value']); $this->assertSame([ 'foo' => 'bar', - 'empty_array' => [], + 'empty_array' => null, 'user.name' => 'Taylor', 'key' => 'value', ], $array);