When setting the preserve_empty_objects flag in a normalization context, objects normalized to empty arrays are returned from the Symfony\Component\Serializer\Normalizer\NormalizerInterface::normalize() method as ArrayObject. This is expected behavior. However, when using this flag and using this package, the following error occurs:
TypeError: array_merge(): Argument #2 must be of type array, ArrayObject given
/app/vendor/dunglas/doctrine-json-odm/src/SerializerTrait.php:59
/app/vendor/dunglas/doctrine-json-odm/src/TypedSerializerTrait.php:26
/app/vendor/symfony/serializer/Normalizer/AbstractObjectNormalizer.php:227
/app/vendor/symfony/serializer/Serializer.php:152
...
As a solution to the problem, I suggest interacting with the result of object normalization as ArrayAccess, not array.