- ArrayOf errors now catched in EntityTrait (event soon to be attached to it)

- Fixed some non-nullable defaulted to null vars in functions
- Added a new diff method for entities which skips nullable values if they are not defined.
This commit is contained in:
mcndave committed 2026-07-13 12:33:40 +00:00
1 parent 709ed63323
commit 13b7cf06f1
9 files changed
+52 -26

No files matched your search

+9 -5
View File
@@ -25,22 +25,26 @@ class ArrayOf implements \Ulmus\Entity\EntityValueModifier
sprintf("Given item '%s' is not a valid enum for type %s ; try one of theses instead : %s", $item, $this->type, implode("', '", array_map(fn($e) => $e->value, $this->type::cases())))
);
} else {
$value = $this->type::from($item);
$obj = $this->type::from($item);
}
}
elseif (class_exists($this->type)) {
if (is_subclass_of($this->type, JsonUnserializable::class)) {
$value = (new \ReflectionClass($this->type))->newInstanceWithoutConstructor();
$value->jsonUnserialize($item);
$obj = (new \ReflectionClass($this->type))->newInstanceWithoutConstructor();
$obj->jsonUnserialize($item);
}
else {
$value = new $this->type($item);
$obj = new $this->type($item);
}
}
else {
throw new \InvalidArgumentException("Given type for ArrayOf is incompatible with it's use. An object should be provided");
}
$return[$index] = $value;
$return[$index] = $obj;
}
}
if (! $property->type->builtIn) {
$cls = $property->type->type;