Skip to content

Commit

Permalink
修复ConvertJson在定义的函数不为空,restore没回复默认实例的bug
Browse files Browse the repository at this point in the history
  • Loading branch information
kiss291323003 committed Aug 31, 2024
1 parent d72fb28 commit 057053c
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions src/AbstractInterface/AbstractEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,25 @@ function setData(array $data,bool $mergeCompare = false)
}
/** @var Property $property */
$property = $allProperties[$key];
if($property->convertObject && ($val !== null)){
if($val instanceof $property->convertObject){
$object = $val;
if($property->convertObject){
if($val !== null){
if($val instanceof $property->convertObject){
$object = $val;
}else{
$object = call_user_func([$property->convertObject,'toObject'],$val);
}
$this->{$key} = $object;
if($mergeCompare){
$this->compareData[$key] = $this->{$key}->toValue();
}
}else{
$object = call_user_func([$property->convertObject,'toObject'],$val);
}
$this->{$key} = $object;
if($mergeCompare){
$this->compareData[$key] = $this->{$key}->toValue();
if(!$property->allowNull){
$object = call_user_func([$property->convertObject,'toObject'],$val);
$this->{$key} = $object;
if($mergeCompare){
$this->compareData[$key] = $this->{$key}->toValue();
}
}
}
}else{
$this->{$key} = $val;
Expand Down

0 comments on commit 057053c

Please sign in to comment.