Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/Handler/Handlers/ObjectHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function serialize(mixed $value, Metadata $metadata, SerializationContext

public static function supportsDeserialize(mixed $value, string $type): bool
{
return is_array($value);
return is_array($value) || ($value instanceof \stdClass && $type === Type::BUILTIN_TYPE_ARRAY);
}

/**
Expand All @@ -64,6 +64,9 @@ public static function supportsDeserialize(mixed $value, string $type): bool
*/
public function deserialize(mixed $value, Metadata $metadata): object|iterable
{
if ($value instanceof \stdClass && Type::BUILTIN_TYPE_ARRAY === $metadata->type) {
return (array) $value;
}
if (is_a($metadata->type, Collection::class, true)) {
/** @var Collection<int|string, iterable|object> $collection */
$collection = new ArrayCollection();
Expand Down