Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[Yaml] properly parse lists in object maps #17729

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
merged 1 commit into from
Feb 14, 2016

Conversation

xabbuh
Copy link
Member

@xabbuh xabbuh commented Feb 8, 2016

Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #17709, #17710, #17711
License MIT
Doc PR
  • do not cast parsed sequences to objects
  • properly handle numeric mapping keys

@fabpot
Copy link
Member

fabpot commented Feb 12, 2016

👍

@@ -303,8 +303,14 @@ public function parse($value, $exceptionOnInvalidType = false, $objectSupport =
mb_internal_encoding($mbEncoding);
}

if ($objectForMap && !is_object($data)) {
$data = (object) $data;
Copy link
Member

Choose a reason for hiding this comment

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

I don't understand why we made this change:

-            $data = (object) $data;
+            $object = new \stdClass();
+
+            foreach ($data as $key => $value) {
+                $object->$key = $value;
+            }
+
+            $data = $object;

Copy link
Member Author

Choose a reason for hiding this comment

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

PHP behaves a bit different when it comes to numeric keys (see https://3v4l.org/dUGiM).

Copy link
Member

Choose a reason for hiding this comment

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

@xabbuh thanks for the explanation!

* do not cast parsed sequences to objects
* properly handle numeric mapping keys
@javiereguiluz
Copy link
Member

👍

Status: reviewed

@fabpot
Copy link
Member

fabpot commented Feb 14, 2016

Thank you @xabbuh.

@fabpot fabpot merged commit ee9ca93 into symfony:2.8 Feb 14, 2016
fabpot added a commit that referenced this pull request Feb 14, 2016
This PR was merged into the 2.8 branch.

Discussion
----------

[Yaml] properly parse lists in object maps

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #17709, #17710, #17711
| License       | MIT
| Doc PR        |
* do not cast parsed sequences to objects
* properly handle numeric mapping keys

Commits
-------

ee9ca93 [Yaml] properly parse lists in object maps
@xabbuh xabbuh deleted the issue-17709-17710 branch February 14, 2016 10:44
This was referenced Feb 28, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.