Skip to content

[Serializer] MaxDepth annotation not working as expected #20932

Closed
@digilist

Description

@digilist
Q A
Bug report? yes
Feature request? no
BC Break report? no
RFC? no
Symfony version 3.1.7

I tested the new MaxDepth annotation in the Symfony serializer (see #17113). Consider some code that extends the example code given in the pull request with more levels (4, 5, etc.). By keeping a max depth of 2, the result is the following:

        'foo' => 'level1',
        'child' =>
            array (
                'foo' => 'level2',
                'child' =>
                    array (
                        'child' =>
                            array (
                                'child' =>
                                    array (
                                        'child' =>
                                            array (
                                                'child' => NULL,
                                            ),
                                    ),
                            ),
                    ),
            ),
    )

As you can see, it considers all child nodes and does not stop after the configured max depths. Only the data of the objects in deeper levels is excluded (attribute foo).

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