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