Skip to content

Commit

Permalink
JsonConverter: Fix handling of empty arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
Dominic Tubach committed Mar 13, 2024
1 parent 6934400 commit 585db1f
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Form/Util/JsonConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ public static function toArray(\stdClass $data): array {
* @throws \JsonException
*/
public static function toStdClass(array $data): \stdClass {
if ([] === $data) {
return new \stdClass();
}

$result = \json_decode(\json_encode($data, JSON_THROW_ON_ERROR));
Assertion::isInstanceOf($result, \stdClass::class);

Expand Down

0 comments on commit 585db1f

Please sign in to comment.