Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
  • Loading branch information
kiss291323003 committed Mar 9, 2023
1 parent fcc7c5f commit 528bba9
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/SplBean.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,18 @@ final public function jsonSerialize(): array
{
$data = [];
foreach ($this->properties as $key => $property){
if($this->{$key} instanceof SplBean){
$data[$key] = $this->{$key}->jsonSerialize();
$temp = new \ReflectionProperty(static::class,$key);
if($temp->isInitialized($this)){
if($this->{$key} instanceof SplBean){
$data[$key] = $this->{$key}->jsonSerialize();
}else{
$data[$key] = $this->{$key};
}
}else{
$data[$key] = $this->{$key};
$data[$key] = null;
}


}
return $data;
}
Expand Down

0 comments on commit 528bba9

Please sign in to comment.