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 Dumper to support objectMap #12860

Copy link
Copy link
Closed
@norrs

Description

@norrs
Issue body actions

As of 2.6 series[1] you introduced objectMap parsing, but there is currently no support for both dumping and parsing it again.

<?php

class ObjectMapTest extends PHPUnit_Framework_TestCase {

    public function testParseValidYamlWithObjectMap__andDumpParsedYamlWithObjectMap__andParseSameYamlWithObjectMapAgain__ShouldEqual() {
        $yaml = <<< EOF
----------------
foo:
  bar:
    class: "classBar"
    args:
      - "bar"
  zar:
    class: "classZar"
    args: [ ]
EOF;
        $parser = new \Symfony\Component\Yaml\Parser();
        $dumper = new \Symfony\Component\Yaml\Dumper();

        $objectMap = true;
        $objectSupport = false;
        $exceptionOnInvalidType = true;

        $originalParse = $parser->parse($yaml, $exceptionOnInvalidType, $objectSupport, $objectMap);

        // Problem: dumper doesn't have any input for $objectMap ..
        $test = $dumper->dump($originalParse, 10, 0, $exceptionOnInvalidType, $objectSupport);

        // So this one fails :-(
        $this->assertEquals($originalParse, $parser->parse($test, $exceptionOnInvalidType, $objectSupport, $objectMap));
    }

}

[1] http://symfony.com/blog/new-in-symfony-2-6-support-for-object-maps-in-yaml-component

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

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