Skip to content

Commit ccda123

Browse files
authored
Merge pull request #2 from Zhang-mason/fix/empty-array-output
fix: handle empty array output
2 parents 2534155 + a325f92 commit ccda123

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)