Skip to content

Commit f541ed8

Browse files
committed
Allow for null values in list responsesAddresses #22 in v1 release series
1 parent 70bb4f2 commit f541ed8

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/Hydratable.php

+6-4
Original file line numberDiff line numberDiff line change
@@ -448,17 +448,19 @@ private function hydrateArray(string $field, $value, array $def): void
448448
foreach ($value as $k => $v) {
449449
// todo: causes double-checking for null if value isn't null, not great...
450450
if (null === $v) {
451-
continue;
451+
$this->{$field}[$k] = null;
452+
} else {
453+
$this->{$field}[$k] = $this->buildObjectValue($field, $v, $class, false);
452454
}
453-
$this->{$field}[$k] = $this->buildObjectValue($field, $v, $class, false);
454455
}
455456
} else {
456457
// in all other cases, just set as-is
457458
foreach ($value as $k => $v) {
458459
if (null === $v) {
459-
continue;
460+
$this->{$field}[$k] = null;
461+
} else {
462+
$this->{$field}[$k] = $this->buildScalarValue($field, $v, $type, false);
460463
}
461-
$this->{$field}[$k] = $this->buildScalarValue($field, $v, $type, false);
462464
}
463465
}
464466
}

0 commit comments

Comments
 (0)