From dc608a40a0ed452b1e4849a166e42f4c6190e5de Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 21 Oct 2025 02:32:23 +0600 Subject: [PATCH 1/2] Add empty arrays to null in Arr::dot() --- src/Illuminate/Collections/Arr.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; } } }; From 93d913621814dffc630a37633490bd2ec3bd321c Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 21 Oct 2025 02:33:17 +0600 Subject: [PATCH 2/2] Update test for empty arrays to null in Arr::dot() --- tests/Support/SupportArrTest.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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);