Skip to content

Symfony/Yaml: objectSupport is ignored. #17075

Closed
@IngwiePhoenix

Description

@IngwiePhoenix

Testcase:

<?php

# Load Composer
define("AUTOLOADER_FILE", realpath(__DIR__."/../php_modules/autoload.php"));
require_once(AUTOLOADER_FILE);

# Test data
$configString = <<<EOT
Group:
    owner: Ingwie Phoenix
    id: 0
EOT;

echo "--- Data: YAML ---".PHP_EOL;
echo $configString.PHP_EOL;
echo "---".PHP_EOL;

use Symfony\Component\Yaml\Yaml;
$parsedYaml = Yaml::parse($configString, false, true);
$t = gettype($parsedYaml);
if($t == "object") {
    echo "YAML was parsed and returned as object.";
} else {
    echo "YAML was parsed, but not returned as object. Got: $t";
}
echo PHP_EOL;

Output:

Ingwie@Ingwies-Macbook-Pro.local ~/W/B/test $ php --version
PHP 5.6.14 (cli) (built: Oct  3 2015 14:54:13) 
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies
    with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2015, by Zend Technologies
    with Xdebug v2.3.3, Copyright (c) 2002-2015, by Derick Rethans
Ingwie@Ingwies-Macbook-Pro.local ~/W/B/test $ php LoadYamlConfig.php 
--- Data: YAML ---
Group:
    owner: Ingwie Phoenix
    id: 0

---
YAML was parsed, but not returned as object. Got: array

It seems that the documented objectSupport option is not being taken into consideration.

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