Skip to content

Commit a325f92

Browse files
committed
fix: handle empty array output
1. Initialize properties array in walkProperties to prevent undefined index errors.
1 parent 2534155 commit a325f92

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/ImmutableBase.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ final public function toArray(): array
204204
$value = $property->getValue($this);
205205
$key = $property->getName();
206206
if (is_array($value)) {
207+
$properties[$key] = [];
207208
foreach ($value as $v) {
208209
if (is_object($v) && method_exists($v, 'toArray')) {
209210
$properties[$key][] = $v->toArray();

0 commit comments

Comments
 (0)