Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New normalizers #6314

Closed
wants to merge 7 commits into from
Closed

New normalizers #6314

wants to merge 7 commits into from

Conversation

mcfedr
Copy link
Contributor

@mcfedr mcfedr commented Mar 1, 2016

Q A
Doc fix? no
New docs? yes symfony/symfony#17603 symfony/symfony#17411 symfony/symfony#16164
Applies to 3.1
Fixed tickets

@@ -511,6 +511,26 @@ There are several types of normalizers available:

Objects are normalized to a map of property names to property values.

::class:`Symfony\\Component\\Serializer\\Normalizer\\JsonSerializableNormalizer`
This normalizer works with classes that implement `\JsonSerializable`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use double backticks here and below to enclose class names, method names, etc.

This means that nested ``JsonSerializable`` classes will also be normalized.

This normalizer is particularly helpful when you want to gradually migrate
from an existing codebase using simple ``json_encode`` to the full Symfony
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you could add a link to the PHP doc for the json_encode function IMO

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can remove the full

@theofidry
Copy link
Contributor

Not sure why your class names stats with a ::

screen shot 2016-03-01 at 21 59 27

@@ -511,6 +511,26 @@ There are several types of normalizers available:

Objects are normalized to a map of property names to property values.

::class:`Symfony\\Component\\Serializer\\Normalizer\\JsonSerializableNormalizer`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The colon @theofidry is confused of comes from the double colon here (the directive is :class:).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ha indeed, misread I though it was the same for the others

@theofidry
Copy link
Contributor

It may not be the best place to ask that but can't those new serializers be back-ported? Sounds extreme to apply it only to ~3.1 cc @dunglas.

@mcfedr
Copy link
Contributor Author

mcfedr commented Mar 2, 2016

Should I be adding these .. versionadded:: ?

@mcfedr
Copy link
Contributor Author

mcfedr commented Mar 2, 2016

@theofidry I would love to backport these to 2.8 but my understanding is that new features are only added to new version, I am trying to get my project up to date with 3.0 so I can use these

@dunglas
Copy link
Member

dunglas commented Mar 2, 2016

New features are, indeed, only allowed in master. The only way to bring new normalizers to old component version is to extract them to a separate (non-core) library or bundle.

However, you can use an old version of Symfony (like 2.8) with only the Serializer Component in 3.1.

:class:`Symfony\\Component\\Serializer\\Normalizer\\DateTimeNormalizer`
This normalizer converts :phpclass:`DateTimeInterface` objects (e.g.
:phpclass:`DateTime` and :phpclass:`DateTimeImmutable`) into strings.
By default it uses the RFC3339 format.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe add a link to the RFC3339 specification here?

@wouterj
Copy link
Member

wouterj commented Mar 5, 2016

@mcfedr yes, can you please add the .. versionadded:: 3.1 directives? (you may also include only one after the list of normalizers)

mcfedr added 2 commits March 5, 2016 17:05
Linked direct to the example section as its probably most helpful
@theofidry
Copy link
Contributor

Is there anything left for merging this PR @wouterj @xabbuh?

@wouterj
Copy link
Member

wouterj commented Mar 13, 2016

As far as I can see, no. 👍

@xabbuh
Copy link
Member

xabbuh commented Mar 13, 2016

👍

@dunglas
Copy link
Member

dunglas commented Mar 13, 2016

👍

If you think it's interesting I'll split the serializer doc in several files and add details on how to configure the DateTimeNormalizer and DataUriNormalizer when I'll be less busy. I also need to document the new @MaxDepth annotation.

@xabbuh
Copy link
Member

xabbuh commented Mar 13, 2016

Thank you @mcfedr.

@xabbuh xabbuh closed this in 10ea5e9 Mar 13, 2016
@xabbuh
Copy link
Member

xabbuh commented Mar 13, 2016

@dunglas Sounds like a good idea to me.

@theofidry
Copy link
Contributor

I also need to document the new @MaxDepth annotation.

A must do, it's an awesome feature.

@mcfedr mcfedr deleted the new-normalizers branch March 16, 2016 06:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants