aboutsummaryrefslogtreecommitdiffhomepage
path: root/Digitigrade/Model.php
diff options
context:
space:
mode:
Diffstat (limited to 'Digitigrade/Model.php')
-rw-r--r--Digitigrade/Model.php11
1 files changed, 9 insertions, 2 deletions
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;