Thanks to visit codestin.com
Credit goes to github.com

Skip to content

New DUMP_MULTI_LINE_LITERAL_BLOCK doesn't indent at all #17977

Closed
@schorsch3000

Description

@schorsch3000

Hi,
i've tested the new DUMP_MULTI_LINE_LITERAL_BLOCK which got into master a few days ago with eff6902. It seems it doesn't indent the literal block at all as it should.

i've used this simple example:

<?php
include 'vendor/autoload.php';
use Symfony\Component\Yaml\Yaml;
$data = ['foo' => 'bar', 'error' => "foo\nbar"];
$yaml = Yaml::dump($data, 2, 0, Yaml::DUMP_MULTI_LINE_LITERAL_BLOCK);
Yaml::parse($yaml);

while requiring "symfony/yaml": "dev-master"

the string in $yaml is:

foo: bar
error: |
foo
bar

it should be:

foo: bar
error: |
    foo
    bar

that's because the parser throws:

Fatal error: Uncaught exception 'Symfony\Component\Yaml\Exception\ParseException' with message 'Unable to parse at line 3 (near "foo").' in vendor/symfony/yaml/Parser.php on line 321

I don't think that it matters, but since the bug report guidelines talk about this stuff, here are some of my details:

$ cat /etc/debian_version 
8.3
$ uname -a
Linux localhost 3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt20-1+deb8u3 (2016-01-17) x86_64 GNU/Linux
$ php -v
PHP 5.6.17-0+deb8u1 (cli) (built: Jan 13 2016 09:10:12) 
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies
    with XCache v3.2.0, Copyright (c) 2005-2014, by mOo
    with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2015, by Zend Technologies
    with Xdebug v2.2.5, Copyright (c) 2002-2014, by Derick Rethans
    with XCache Optimizer v3.2.0, Copyright (c) 2005-2014, by mOo
    with XCache Cacher v3.2.0, Copyright (c) 2005-2014, by mOo
    with XCache Coverager v3.2.0, Copyright (c) 2005-2014, by mOo
$ grep -A 12 '"name": "symfony/yaml"'  composer.lock 
            "name": "symfony/yaml",
            "version": "dev-master",
            "source": {
                "type": "git",
                "url": "https://github.com/symfony/yaml.git",
                "reference": "c9821ffc2965d57b0404e40ef08dc8da642238f2"
            },
            "dist": {
                "type": "zip",
                "url": "https://api.github.com/repos/symfony/yaml/zipball/c9821ffc2965d57b0404e40ef08dc8da642238f2",
                "reference": "c9821ffc2965d57b0404e40ef08dc8da642238f2",
                "shasum": ""
            },



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