Skip to content

Commit

Permalink
Merge pull request #21 from youzan/hotfix/stdclass_convert
Browse files Browse the repository at this point in the history
update stdClass convert
  • Loading branch information
xu42 authored Feb 23, 2021
2 parents 617aeba + 0404065 commit 62ecdd3
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Util/ObjectBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,11 @@ public function convertArrayToObjectInstance($input, ReflectionClass $refParamet

// 匿名类直接转换
if ($refParameterClass->getName() == 'stdClass') {
return json_decode(json_encode($input));
if (empty($input)) {
return (object) $input;
} else {
return json_decode(json_encode($input));
}
}

$instance = $refParameterClass->newInstanceWithoutConstructor();
Expand Down

0 comments on commit 62ecdd3

Please sign in to comment.