-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Yaml] Add flag to dump NULL as ~ #32669
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
Oh I didn't know that, I talked to @xabbuh before starting to work on it... To me there is technical reason (regarding the comment in the other PR). I am reading Yaml files, adding some content and dumping it again to the filesystem. Now, depending on the source, wether its using Let me be more clear with an example. Adding content too this file: foo: bar
baz: ~ would result in: foo: bar
- baz: ~
+ baz: null
+ lol: null which is very verbose. The following would be less verbose: foo: bar
baz: ~
+ lol: ~ Btw. I created nearly the exact same PR like you @fancyweb without knowing it 😄 |
Let me explain a bit more why I think that this is not something I want: adding more options is adding more complexity (and complexity grows exponentially with more added options). Having only. One way to do something makes our code simpler, easier to understand, easier to document, and easier to use. Less decisions. |
I agree with you Fabien 👍. Another option would be to rework the YAML component and create an extension point for projects. I hope you read my argument, because I was updated my post. I am not the one who decides to get this merged, but as the tilde is a common used thing in YAML, I talked to @xabbuh and he asked me to create a PR, @fancyweb created the same PR... so it looks to me that for this small option the community (at least some of them 😄 ) have a need. Another point is, that YAML is best to be human readable, but a diff changes every line including a |
We moved away from generating I know that this is opinionated, but if you have a look at the flow of PRs, we have a regular stream of PRs adding options. I'm the one trying to challenge them to be sure that we really need those new options. |
And as I said its ok for me to challenge and not merge it. I gave all my arguments 😄 and I really like that you sometimes decide to not merge something 👍 |
The reason Fabien gives here:
This is one of the few things I didn't know until recently. I think an explicit NULL is far better than having a tilde. However, I also do agree with Oskar on the following:
I think it's pretty great to have a sub-set of YAML functionality provided by Symfony, to which you can create a more complete implementations via 3rd party tools. Not sure how this would be done internally though, as it sounds very complex. |
Thanks for your feedback @linaori, but I don't want to change the default value (so this is not an argument IMHO) and only want to have the option for people who know the |
If complexity is an issue, should the related code be rewritten to reduce this complexity? Even if it costs a bit of performance (you don't call this run-time, hopefully). The current flag system is also limiting at some point. |
No I am using it async to handle my YAML files. The proposed option is quite small and I think to rewrite it to fulfill my use-case is too much overhead, the flags are sufficient here. |
I smell a small inconsistency here. Using the tilde seems to be a Symfony best practise, yet the YAML dumper uses the literal |
exactly thats my point! |
I think this should be added, because Symfony interprets |
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'm personally OK to add this one.
But CI needs to be green! |
Sure thing Nicolas, will have a look soon 👀 |
I asked Oskar to open this PR as I agree with the reasoning for the changes. Dumping |
|
What about changing |
That makes definitely sense, but the intent of my PR is to handle files, delivered from customers (in my project) which are using |
@OskarStark Of course. I just wanted to follow up and finish the discussion on the Symfony part, where we can definitely standardize on using For this PR, I'm |
This is a nice addition. I would gladly help to fix those recipes, shall we run a
I know ;-) |
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.
with one minor comment
Travis failure is unrelated |
Thank you @OskarStark. |
This PR was merged into the 4.4 branch. Discussion ---------- [Yaml] Add flag to dump NULL as ~ | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #... <!-- #-prefixed issue number(s), if any --> | License | MIT | Doc PR | symfony/symfony-docs#12071 This PR adds the ability to dump `null` as `~` by a new Flag `Yaml::DUMP_NULL_AS_TILDE`: ```diff - foo: null + foo: ~ ``` Todos: - [x] Fix/add tests Commits ------- 749c11d [Yaml] Add flag to dump NULL as ~
This PR was squashed before being merged into the 4.4 branch (closes #32944). Discussion ---------- [Yaml] Removed unused $nullAsTilde property | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | N/A | License | MIT | Doc PR | N/A #32669 added a new private property `$nullAsTilde`, but that property was never used, so this PR removes the unused property Commits ------- fbef854 [Yaml] Removed unused $nullAsTilde property
This PR was merged into the 4.4 branch. Discussion ---------- [Yaml] Dump null as tilde Docs for symfony/symfony#32669 Commits ------- 68cf0cf [Yaml] Dump null as tilde
This PR adds the ability to dump
null
as~
by a new FlagYaml::DUMP_NULL_AS_TILDE
:Todos: