-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Explained the explicit typing in YAML documents #8200
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
Conversation
components/yaml/yaml_format.rst
Outdated
@@ -300,4 +300,25 @@ Comments can be added in YAML by prefixing them with a hash mark (``#``): | |||
Comments are simply ignored by the YAML parser and do not need to be | |||
indented according to the current level of nesting in a collection. | |||
|
|||
Explicity Typing |
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.
"Explicit Typing"?
components/yaml/yaml_format.rst
Outdated
Explicity Typing | ||
---------------- | ||
|
||
The YAML specification defines some tags to set the type of any data explicitly: |
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.
[...] to explicitly set [...]
components/yaml/yaml_format.rst
Outdated
|
||
data: | ||
# this value is parsed as a string (it's not transformed into a DateTime) | ||
start_date: !str 2002-12-14 |
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.
Actually, using the !str
tag is not valid YAML. I wonder if we should add support for !!str
in Symfony 2.7 as a bugfix.
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've created this issue: symfony/symfony#23607
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.
Issue closed. So let's keep it as is.
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 am still reluctant to document invalid YAML. I suggest to just remove it here and only document the !!str
in the 3.4 docs.
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 agree with @xabbuh. !str
is "a Symfony thing" and it's wrong. Let's pretend it doesn't exist 😁
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.
Fair enough :D
components/yaml/yaml_format.rst
Outdated
|
||
data: | ||
# this value is parsed as a string (it's not transformed into a DateTime) | ||
start_date: !str 2002-12-14 |
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.
Issue closed. So let's keep it as is.
Thank you Javier. |
…uiluz) This PR was squashed before being merged into the 2.7 branch (closes #8200). Discussion ---------- Explained the explicit typing in YAML documents I was going to fix #8173 but I couldn't find the explicit typing explanation anywhere, so I include it here. ----- When merging this into 3.4, the `!str` tag must be changed by `!!tag` and we must add this: ``` .. versionadded:: 3.4 The support of ``!!str`` tag was introduced in Symfony 3.4. In previous versions you needed to use the ``!str`` tag. ``` Commits ------- aa1b968 Explained the explicit typing in YAML documents
I was going to fix #8173 but I couldn't find the explicit typing explanation anywhere, so I include it here.
When merging this into 3.4, the
!str
tag must be changed by!!tag
and we must add this: