Skip to content

Commit 8bf098a

Browse files
authored
Property was not cast if was defined as nullable.
If property was defined as @nullable i.e.: `?array, ?json, ?json-array` then it was not cast . Solution 1: add all cases with '?' at the beginning to switch. Solution 2: change type if null was not returned at the beginning of castAs method. - i've picked this one.
1 parent 3a4ade9 commit 8bf098a

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

system/Entity.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,14 @@ protected function mutateDate($value)
428428

429429
protected function castAs($value, string $type)
430430
{
431-
if(substr($type,0,1) === '?' && $value === null) return null;
431+
if(substr($type,0,1) === '?')
432+
{
433+
if($value === null)
434+
{
435+
return null;
436+
}
437+
$type = substr($type,1);
438+
}
432439

433440
switch($type)
434441
{

0 commit comments

Comments
 (0)