-
-
Notifications
You must be signed in to change notification settings - Fork 586
Manage empty array for serializer #510
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
A test is needed to prevent regressions |
I was looking for it but I don't know how to manage tests files. Look at the test classes for yml, I don't know how to put the expected result to assert. Any clue? |
Well, there is a |
138d266
to
8c6f1c9
Compare
Ok so I have to manage all file formats. Will work on it. Actually, I got hard to understand phpunit errors. |
Well, I got this error on master too. Not related. For me, this PR is ready to merge. ping @schmittjoh |
ping @schmittjoh Could you please take a look? This issue is quite annoying, a quick patch is needed IMHO. |
👍 |
@@ -111,6 +111,11 @@ public function visitArray($data, array $type, Context $context) | |||
->rtrim(false) | |||
->writeln(' {}') | |||
; | |||
} elseif (0 === count($data)) { |
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.
Can you change this to empty($data)
if we specifically check for 0.
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 not sure empty($data)
is the good way. We check for an empty array.
All another empty values should have ~
and not []
.
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.
Oh I say something wrong, we are on visitArray
. Will modify it.
8c6f1c9
to
08e7f48
Compare
08e7f48
to
a6443ad
Compare
@schmittjoh Review corrected. |
Manage empty array for serializer
How does this PR fix #124? I don't see it. |
Yes, that seems unrelated, but seems to have been auto-closed. |
@Tobion @schmittjoh My bad, I was thinking it was related. |
Fixes #183.
Fixes #124.
Actually, empty array would produce this:
This is not correct. Furthermore, if you parse it with JMS or Symfony Yaml component, you will got
null
that is not the expected return.With this PR, you will have this: