From 10793d22df72f12f2f14c730c09b5018b5b6e63a Mon Sep 17 00:00:00 2001 From: winter Date: Tue, 17 Dec 2024 20:43:44 +0000 Subject: bugfixing --- Digitigrade/Model.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'Digitigrade/Model.php') diff --git a/Digitigrade/Model.php b/Digitigrade/Model.php index 40e85f4..80a6d91 100644 --- a/Digitigrade/Model.php +++ b/Digitigrade/Model.php @@ -54,8 +54,15 @@ abstract class Model { $result = []; foreach ($props as $p) { $pName = $p->getName(); - if (!isset($this->{$pName})) - $this->{$pName} = null; + // set all nullable properties to null if they aren't already + if (!isset($this->{$pName})) { + try { + $this->{$pName} = null; + } catch (\TypeError $e) { + // if it can't be set, just ignore it + continue; + } + } // we need to determine the plain value to insert ... $value = $this->{$pName}; $discarded = false; -- cgit v1.3