[Serializer] Add a MaxDepth option#17113
Conversation
There was a problem hiding this comment.
Good catch, needs a new interface...
There was a problem hiding this comment.
By the way, I think than introducing such interfaces was a (my) mistake. Serializer Metadata are value objects. Nobody will (nor should) implement these interfaces. Composition is better for "extending" metadata.
What do you think about marking them as @internal (and even deprecated) @symfony/deciders?
There was a problem hiding this comment.
What do you think about using the reference operator &$data to avoid useless copy of the array?
There was a problem hiding this comment.
You can also add an array type hint.
There was a problem hiding this comment.
I prefer to avoid references when possible (http://schlueters.de/blog/archives/125-do-not-use-php-references.html).
Typehint added.
|
👍 to merge this. |
|
Sounds good to me |
This PR was merged into the 2.7 branch. Discussion ---------- [Serializer] Make metadata interfaces internal | Q | A | ------------- | --- | Bug fix? | no | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #17113 (comment) | License | MIT | Doc PR | n/a Introducing such interfaces was a (my) mistake. Serializer metadata are value objects. Nobody will (nor should) implement these interfaces. Composition is better for "extending" metadata. They were not marked as `@api` and should now be marked as `@internal` (or even deprecated but it will cause some maintenance headaches). Commits ------- 3f6cfcd [Serializer] Make metadata interfaces internal
|
ping @symfony/deciders Would be nice to merge soon to be able to work on #16143 without creating conflicts. |
There was a problem hiding this comment.
What about also checking that the value is greater than zero?
|
Status: needs review ping @symfony/deciders |
|
Made some small comments, 👍 |
|
Should be ok now. |
|
Thank you @dunglas. |
…oNormalize (dunglas) This PR was squashed before being merged into the 3.1 branch (closes #20530). Discussion ---------- [Serializer] Remove AbstractObjectNormalizer::isAttributeToNormalize | Q | A | ------------- | --- | Branch? | 3.1 | Bug fix? | yes | New feature? | no | BC breaks? | unclear | Deprecations? | no | Tests pass? | yes | Fixed tickets | n/a | License | MIT | Doc PR | n/a I've introduced this method by error in #17113. It has been forgotten during a refactoring. It has always been unused, is not covered by our test suite and has never been documented. Technically it's a BC break (because this is a protected method), but I think that it's better to remove it has it has never be intended to be used, it's just a miss. An alternative is to deprecate it and remove it in v4. Commits ------- fea18aa [Serializer] Remove AbstractObjectNormalizer::isAttributeToNormalize
…, javiereguiluz) This PR was merged into the 3.1 branch. Discussion ---------- [Serializer] Docs for the @MaxDepth annotation Docs for symfony/symfony#17113. Commits ------- d7395d3 Make lines shorter to comply with our soft limit of 80 chars per line 93dcc3f Fix comments 97f48e5 [Serializer] Docs for the @MaxDepth annotation
Add a max depth option during the normalization process. Especially useful when normalizing trees.
Usage:
@MaxDepth(2)annotation and loader/cc @mRoca @csarrazi