From f08fff6f54ffabb4c259a18f1cf00683e1fa97ba Mon Sep 17 00:00:00 2001 From: Andrea Marco Sartori Date: Sun, 6 Nov 2022 01:06:49 +1000 Subject: [PATCH] Handle unset keys --- src/Tree.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Tree.php b/src/Tree.php index 9cfc334..b2e9c5d 100644 --- a/src/Tree.php +++ b/src/Tree.php @@ -90,7 +90,9 @@ class Tree implements IteratorAggregate */ public function inObject(): bool { - return is_string($this->original[$this->depth]); + $key = $this->original[$this->depth] ?? null; + + return is_string($key); } /**