Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Serializer] Serializing empty class without properties serializes to [] when preserve_empty_objects is enabled #56875

Copy link
Copy link
Closed
@ruudk

Description

@ruudk
Issue body actions

Symfony version(s) affected

7.1-RC1

Description

While testing 7.1-RC1 I noticed a change in behavior.

I have a test suite that serializes all commands (for a command bus) and confirms that they can be deserialized.

There is a command that does not have any properties:

final class DoSomethingCommand {}

When this is serialized with Symfony 7.0, it produces {}.

But with Symfony 7.1-RC1 it becomes [].

How to reproduce

See above.

Possible Solution

While debugging the situation, I notice that in 7.0 the empty object gets normalized into ArrayObject (empty).
Screenshot 2024-05-22 at 09 29 47@2x

But on 7.1-RC1 it becomes an empty array.
Screenshot 2024-05-22 at 09 31 35@2x

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.