Skip to content

Commit bfce1c0

Browse files
[Serializer] fix reading unset properties
1 parent 44d9be8 commit bfce1c0

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

PropertyAccessor.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,10 @@ private function readProperty(array $zval, string $property, bool $ignoreInvalid
470470
throw $e;
471471
}
472472
} elseif (PropertyReadInfo::TYPE_PROPERTY === $type) {
473+
if (!method_exists($object, '__get') && !\array_key_exists($name, (array) $object)) {
474+
throw new UninitializedPropertyException(sprintf('The property "%s::$%s" is not initialized.', $class, $name));
475+
}
476+
473477
$result[self::VALUE] = $object->$name;
474478

475479
if (isset($zval[self::REF]) && $access->canBeReference()) {

0 commit comments

Comments
 (0)