From 690bd2ec1ac0851d992c413cf8e340e02a90d7fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Riku=20S=C3=A4rkinen?= Date: Sun, 12 Feb 2023 23:18:47 +0000 Subject: [PATCH] Fix parsing empty constructor array --- src/Dot.php | 2 +- tests/DotTest.php | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Dot.php b/src/Dot.php index 36cb0d6..9350fb6 100644 --- a/src/Dot.php +++ b/src/Dot.php @@ -36,7 +36,7 @@ class Dot implements ArrayAccess, Countable, IteratorAggregate, JsonSerializable * * @var array */ - protected $items; + protected $items = []; /** * The character to use as a delimiter, defaults to dot (.) diff --git a/tests/DotTest.php b/tests/DotTest.php index d16b8fd..e0dcca2 100644 --- a/tests/DotTest.php +++ b/tests/DotTest.php @@ -59,6 +59,10 @@ public function testConstructWithParsing(): void $dot = new Dot(['foo.bar' => 'baz'], true); $this->assertEquals(['foo' => ['bar' => 'baz']], $dot->get()); + + $dot = new Dot([], true); + + $this->assertEquals([], $dot->get()); } public function testConstructWithCustomDelimiter(): void