8000 [YAML] YAML merge does not work with PARSE_OBJECT_FOR_MAP · Issue #24133 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
[YAML] YAML merge does not work with PARSE_OBJECT_FOR_MAP #24133
Closed
@ngyuki

Description

@ngyuki
Q A
Bug report? yes
Feature request? no
BC Break report? no
RFC? no
Symfony version 3.3.8
<?php
require __DIR__ . '/vendor/autoload.php';

use Symfony\Component\Yaml\Parser;
use Symfony\Component\Yaml\Yaml;

$file =<<<YAML
aaa: &A
  bbb: 1

ccc:
  ddd: 2
  <<: *A

eee:
  fff: 3
  <<:
    ggg: 4
YAML;

no $flags, does work,

$arr = (new Parser())->parse($file);
var_dump($arr);
/***
array(3) {
  'aaa' =>
  array(1) {
    'bbb' =>
    int(1)
  }
  'ccc' =>
  array(2) {
    'ddd' =>
    int(2)
    'bbb' =>
    int(1)
  }
  'eee' =>
  array(2) {
    'fff' =>
    int(3)
    'ggg' =>
    int(4)
  }
}
***/

PARSE_OBJECT_FOR_MAP, does not work.

$arr = (new Parser())->parse($file, Yaml::PARSE_OBJECT_FOR_MAP);
// Symfony\Component\Yaml\Exception\ParseException:
//   YAML merge keys used with a scalar value instead of an array at line 5 (near "<<: *A").

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0