Skip to content

Commit c58f414

Browse files
committed
Don't cast null
1 parent bf1f317 commit c58f414

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/PHPFUI/ORM/Cast.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,15 @@ public function setValue(mixed $value, array $parameters) : void
2121
{
2222
$class = \array_shift($parameters);
2323

24-
if (! ($value instanceof $class))
24+
if ($value === null)
2525
{
26-
throw new \PHPFUI\ORM\Exception(__METHOD__ . ': Error - ' . \get_debug_type($value) . ' is not an instance of ' . $class);
26+
$this->currentRecord[$this->fieldName] = null;
27+
28+
return;
29+
}
30+
else if (! ($value instanceof $class))
31+
{
32+
$value = new $class($value);
2733
}
2834

2935
$this->currentRecord[$this->fieldName] = "{$value}";

0 commit comments

Comments
 (0)