-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Yaml] Support parsing YAML timestamps as DateTime #14420
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
Changes from 1 commit
238589d
3daae64
9db5c6f
663a9ca
41c5f12
dd4798e
1f4269e
028f2d7
5d75dd0
72abdee
1b970f3
422d838
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,7 +55,7 @@ class Yaml | |
*/ | ||
public static function parse($input, $exceptionOnInvalidType = false, $objectSupport = false, $objectForMap = false, $timestampAsDateTime = false) | ||
{ | ||
if ($timestampAsDateTime) { | ||
if (!$timestampAsDateTime) { | ||
trigger_error('The ability to pass $timestampAsDateTime = false to the '.__METHOD__.' method is deprecated since version 2.8. The argument will be removed in 3.0. Pass true instead.', E_USER_DEPRECATED); | ||
} | ||
|
||
|
@@ -106,7 +106,7 @@ public static function parse($input, $exceptionOnInvalidType = false, $objectSup | |
*/ | ||
public static function dump($array, $inline = 2, $indent = 4, $exceptionOnInvalidType = false, $objectSupport = false, $timestampAsDateTime = false) | ||
{ | ||
if ($timestampAsDateTime) { | ||
if (!$timestampAsDateTime) { | ||
trigger_error('The ability to pass $timestampAsDateTime = false to the '.__METHOD__.' method is deprecated since version 2.8. The argument will be removed in 3.0. Pass true instead.', E_USER_DEPRECATED); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It does not work because your dumper does not care about the value passed here at all. Any time it finds a DateTimeInterface, it will dump it as a yaml timestamp, whatever the value of this flag is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah some times I feel idiot. I think for the BC reasons it's better to let the argument. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is nothing about BC here. Your argument does strictly nothing as the code ignores it (except for the deprecation warning being triggered all the time by default, which is bad). |
||
} | ||
|
||
|
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 triggers the deprecation message by default, which is bad
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 there is no other choice.
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, if you cannot avoid triggering the warning for people using this method in the most common way (
Yaml::parse($yaml)
), you should not trigger it at all.Currently, you will force everyone to pass all arguments explicitly to change the default to avoid the deprecation warning, which is a no-go
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.
What do you think:
this doesn't work if we add another param to the function, but it's something
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.
@dosten No bad idea. It's useless and it should be the same behaviour for everyone.
@stof So I remove the trigger but I keep the deprecation ?
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.
@Stop What do you think ?