Allow null on enum properties.

This commit is contained in:
KJ 2024-09-23 15:06:44 -04:00
parent 73b7b8f72a
commit 3e27b1b7af

View File

@ -250,7 +250,8 @@ class Model {
foreach ($elem as $key => $value) {
$index = array_search($key, $propertyNames);
if (is_numeric($index) && enum_exists($properties[$index]->getType()->getName()))
if (is_numeric($index) && isset($value) &&
enum_exists($properties[$index]->getType()->getName()))
$instance->$key = $properties[$index]->getType()->getName()::tryfrom($value);
else
$instance->$key = $value;