Skip to content

[YAML] YAML merge does not work with PARSE_OBJECT_FOR_MAP #24133

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
ngyuki opened this issue Sep 8, 2017 · 1 comment
Closed

[YAML] YAML merge does not work with PARSE_OBJECT_FOR_MAP #24133

ngyuki opened this issue Sep 8, 2017 · 1 comment

Comments

@ngyuki
Copy link

ngyuki commented Sep 8, 2017

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").
@xabbuh
Copy link
Member

xabbuh commented Sep 13, 2017

see #24189

fabpot added a commit that referenced this issue Sep 28, 2017
…bbuh)

This PR was merged into the 3.3 branch.

Discussion
----------

[Yaml] parse merge keys with PARSE_OBJECT_FOR_MAP flag

| Q             | A
| ------------- | ---
| Branch?       | 3.3
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #24133
| License       | MIT
| Doc PR        |

Commits
-------

534eaed parse merge keys with PARSE_OBJECT_FOR_MAP flag
@fabpot fabpot closed this as completed Sep 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants