8000 [YAML] Added support for object-maps by nicolas-grekas · Pull Request #10552 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[YAML] Added support for object-maps #10552

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

Merged

Conversation

nicolas-grekas
Copy link
Member
Q A
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets NA
License MIT
Doc PR NA

Proposal for #10114

@@ -182,6 +192,48 @@ protected function getTestsForParse()
);
}

protected function getTestsForMapObjectParse()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should probably use a @dataProvider here instead.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well, the same should be done for getTestsForParse then

@polyfractal
Copy link
Contributor

I forked this a while ago so that I could get the changes into my project. It dawned on me that Parser.php needs modification to make these changes visible to the end-user...otherwise they are inaccessible (not sure why I didn't think of that originally).

My changes are in this commit (polyfractal/Yaml@b0a08f3), we should probably add something similar to this PR.

@nicolas-grekas
Copy link
Member Author

Code updated thanks!

@polyfractal
Copy link
Contributor

Awesome! Can't wait for this to be merged so I can stop maintaining a separate fork :)

@RichardErtel
Copy link

wonderful! 👍
waiting for merge :)

@stof stof added the Yaml label Apr 9, 2014
@stof
Copy link
Member
stof commented Apr 9, 2014

👍

@nicolas-grekas
Copy link
Member Author

👍 also

@stof
Copy link
Member
stof commented Apr 10, 2014

@nicolas-grekas you cannot give a +1 on your own PRs. It does not count :)

@fabpot
Copy link
Member
fabpot commented Jun 3, 2014

@nicolas-grekas Can you rebase on current master?

@lyrixx
Copy link
Member
lyrixx commented Jun 3, 2014

@nicolas-grekas lol. You 👍 your work ;)

@nicolas-grekas
Copy link
Member Author

Well, it's @polyfractal's work, I only tried to cleanup the code in #10114 :-P

@lyrixx
Copy link
Member
lyrixx commented Jun 3, 2014

if so, you could amend your commit to keep him as contributor ;)
(git ci --amend --author="...")


array('[ foo, [ bar, foo ] ]', array('foo', array('bar', 'foo'))),

array('[{ foo: {bar: foo} }]', array((object) array('foo' => (object) array('bar' => 'foo')))),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you add a // object as the other cases in L237 and stuff?

@cordoval
Copy link
Contributor
cordoval commented Jun 4, 2014

@lyrixx is ok, he has one commit and @polyfractal has the other commit. I believe is fair 😊

< 8000 span data-view-component="true">

@cordoval
Copy link
Contributor
cordoval commented Jun 4, 2014

also could you please add documentation PR for this?

polyfractal and others added 2 commits June 4, 2014 08:30
Previously, the parser treated maps ( {} ) the same as sets ( [] ).
Both were returned as PHP associative arrays. Since
these are distinct entities, this can cause considerably problems for
the users, especially when YAML is being serialized into another
format such as JSON.

This commit allows the user to enable object-map support via a third
parameter on the Parse method.  It defaults to `false`, which means
that this commit does not break backwards compatibility.

If the user enables object-map support, maps are represented
by stdClass() objects.  Sets remain as arrays.
@nicolas-grekas
Copy link
Member Author

@fabpot rebase done

@lyrixx
Copy link
Member
lyrixx commented Jun 4, 2014

oups, I did not see it. gravatar are too small ;)

@fabpot fabpot merged commit 0cee604 into symfony:master Jun 4, 2014
fabpot added a commit that referenced this pull request Jun 4, 2014
…olas-grekas)

This PR was merged into the 2.5-dev branch.

Discussion
----------

 [YAML] Added support for object-maps

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | NA
| License       | MIT
| Doc PR        | NA

Proposal for #10114

Commits
-------

0cee604 [Yaml] Cleanups for object maps
e2d5468 [Yaml] Added support for object maps
@polyfractal
Copy link
Contributor

Woo! Thanks @nicolas-grekas for seeing this through and cleaning it up. Time to depreciate my temporary fork! :)

@nicolas-grekas nicolas-grekas deleted the features/supportEmptyMapsInYamlParser branch June 12, 2014 11:24
@qlcorp
Copy link
qlcorp commented Sep 6, 2015

Why does the object have to be on one line? Why is this not supported?

object: {
    attr1: 10,
    attr2: 20
}

@xabbuh
Copy link
Member
xabbuh commented Sep 6, 2015

for anyone being interested: see #15700

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants
0