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

Fixed list handing when dealing with object maps #17711

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

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Minor tweak
  • Loading branch information
johnknl committed Feb 6, 2016
commit a43a6363857ebc4d6073a3b43dbb6e794f9fcfb9
10 changes: 4 additions & 6 deletions 10 src/Symfony/Component/Yaml/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -301,12 +301,10 @@ public function parse($value, $exceptionOnInvalidType = false, $objectSupport =
mb_internal_encoding($mbEncoding);
}

if ($objectForMap && !is_object($data)) {
if (is_array($data)) {
foreach (array_keys($data) as $index => $key) {
if ($index !== $key) {
return empty($data) ? null : (object) $data;
}
if ($objectForMap && is_array($data)) {
foreach (array_keys($data) as $index => $key) {
if ($index !== $key) {
return (object) $data;
}
}
}
Expand Down
11 changes: 11 additions & 0 deletions 11 src/Symfony/Component/Yaml/Tests/ParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,17 @@ public function testWillObjectForMapOptionWillIgnoreArrays()
$this->assertSame('two', $actual->array[1]->key);
}

public function testWillObjectForMapOptionWillIgnoreEmptyArrays()
{
$yaml = <<<YAML
array: []
YAML;
$actual = $this->parser->parse($yaml, true, false, true);
$this->assertInternalType('object', $actual);

$this->assertInternalType('array', $actual->array);
}

/**
* @dataProvider invalidDumpedObjectProvider
* @expectedException \Symfony\Component\Yaml\Exception\ParseException
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.