-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
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
Conversation
Invalid Types and Object Serialization | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
Advanced Usage: Flags | ||
--------------------- | ||
|
There was a problem hiding this comment.
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.
I've left some comments but this looks really nice. Thank you @dantleech. |
ee4b701
to
d682ede
Compare
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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is now.
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 |
Handling Invalid Types | ||
~~~~~~~~~~~~~~~~~~~~~~ | ||
|
||
By default the parser will encode invalid types as "null". You can make the |
There was a problem hiding this comment.
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.
@dantleech Can you please rebase, it seems there are some conflicts. Thanks! |
Rebased On Sun, Jun 26, 2016 at 05:37:00AM -0700, Jules Pietri wrote:
|
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: |
There was a problem hiding this comment.
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 | ||
|
There was a problem hiding this comment.
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
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 |
There was a problem hiding this comment.
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...
Following on from #6590 this PR documents the YAML flags introduced in Symfony 3.1