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

Documentation for YAML flags added in 3.1 #6622

Merged
merged 1 commit into from
Sep 17, 2016
Merged

Conversation

dantleech
Copy link
Contributor

Following on from #6590 this PR documents the YAML flags introduced in Symfony 3.1

Invalid Types and Object Serialization
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Advanced Usage: Flags
---------------------

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought about adding a table here with the flag, which method it applies to (linking to a section below) and a short description.

@javiereguiluz
Copy link
Member

I've left some comments but this looks really nice. Thank you @dantleech.

@dantleech dantleech force-pushed the yaml_3_1 branch 3 times, most recently from ee4b701 to d682ede Compare May 27, 2016 14:08
@dantleech
Copy link
Contributor Author

Updated.

@@ -250,6 +233,77 @@ representation of the object.
parsers will likely not recognize the ``php/object`` tag and non-PHP
implementations certainly won't - use with discretion!

Handling Invalid Types
Copy link
Member

Choose a reason for hiding this comment

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

before this headline, we should add a line: .. _invalid-types-and-object-serialization: This way, all section links still work across versions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well spotted

@@ -127,20 +127,6 @@ error occurred:

.. _components-yaml-dump:

Objects for Mappings
Copy link
Member

Choose a reason for hiding this comment

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

We should add a label to the new headline for existing deep links to the section (like you already have done it for the "Invalid Types and Object Serialization" headline).

Copy link
Contributor Author

@dantleech dantleech May 31, 2016

Choose a reason for hiding this comment

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

Added an additional .. _objects-for-mappings is that what you meant?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, but wouldn't that better fit just above the "Using Objects for Maps" headline?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is now.

@dantleech
Copy link
Contributor Author

Don't know why platform sh failed - it seems to have gone away now,

Also I don't seem to be able to build the docs locally as $ git submodule update --init doesn't seem to do anything.

Handling Invalid Types
~~~~~~~~~~~~~~~~~~~~~~

By default the parser will encode invalid types as "null". You can make the
Copy link
Member

Choose a reason for hiding this comment

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

I would enclose null with double backticks instead of quotes.

@HeahDude
Copy link
Contributor

@dantleech Can you please rebase, it seems there are some conflicts. Thanks!

@dantleech
Copy link
Contributor Author

Rebased

On Sun, Jun 26, 2016 at 05:37:00AM -0700, Jules Pietri wrote:

[1]@dantleech Can you please rebase, it seems there are some conflicts.
Thanks!


You are receiving this because you were mentioned.
Reply to this email directly, [2]view it on GitHub, or [3]mute the thread.

Reverse link: [4]unknown

References

Visible links

  1. https://github.com/dantleech
  2. Documentation for YAML flags added in 3.1 #6622 (comment)
  3. https://github.com/notifications/unsubscribe/AAgZcQoWdHyH1k4cVymTyLdMBx9-BIRnks5qPnJsgaJpZM4IoXrx
  4. Documentation for YAML flags added in 3.1 #6622 (comment)

@HeahDude
Copy link
Contributor

Looks good, thanks!

Status: Needs Review

$data = new \stdClass(); // by default objects are invalid.
Yaml::parse($data, Yaml::DUMP_EXCEPTION_ON_INVALID_TYPE); // throws an exception

.. _objects-for-mappings:
Copy link
Contributor

Choose a reason for hiding this comment

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

This looks like a wrong place, should be up before Object Parsing and Dumping subtitle, right?


$date = Yaml::parse('2016-05-27', Yaml::PARSE_DATETIME);
var_dump(get_class($date)); // DateTime

Copy link
Member

Choose a reason for hiding this comment

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

I would add a note saying that the dumper accepts DateTime (and DateTimeImmutable) objects since 3.1 as well, to dump them as YAML timestamps, without the need for any flag

@weaverryan weaverryan merged commit 3895fc9 into symfony:3.1 Sep 17, 2016
weaverryan added a commit that referenced this pull request Sep 17, 2016
This PR was merged into the 3.1 branch.

Discussion
----------

Documentation for YAML flags added in 3.1

Following on from #6590 this PR documents the YAML flags introduced in Symfony 3.1

Commits
-------

3895fc9 Documentation for YAML flags added in 3.1
Similarly you can use ``DUMP_EXCEPTION_ON_INVALID_TYPE`` when dumping::

$data = new \stdClass(); // by default objects are invalid.
Yaml::parse($data, Yaml::DUMP_EXCEPTION_ON_INVALID_TYPE); // throws an exception
Copy link
Member

Choose a reason for hiding this comment

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

this should have been dump(), right? I'm making that change now...

weaverryan added a commit that referenced this pull request Sep 17, 2016
weaverryan added a commit that referenced this pull request Sep 17, 2016
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.

8 participants