This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
symfony/src/Symfony/Component/Yaml
sun 951acca387 Fixed YAML Parser does not ignore duplicate keys, violating YAML spec.
The current [YAML 1.2] specification clearly states:

> JSON's RFC4627 requires that mappings keys merely “SHOULD” be unique, while YAML insists they “MUST” be.

The outdated [YAML 1.1] spec contained a crystal clear note on how the error of duplicate keys is to be handled by parsers, which is (sadly) no longer contained in the latest 1.2 spec (only leaving the requirement):

> It is an error for two equal keys to appear in the same mapping node.  In such a case the YAML processor may continue, ignoring the second `key: value` pair and issuing an appropriate warning.  This strategy preserves a consistent information model for one-pass and random access applications.

[YAML 1.2]: http://yaml.org/spec/1.2/spec.html#id2759572
[YAML 1.1]: http://yaml.org/spec/1.1/#id932806
2014-05-16 16:25:18 +02:00
..
Exception fixed types in phpdocs 2014-04-16 12:30:19 +02:00
Tests Fixed YAML Parser does not ignore duplicate keys, violating YAML spec. 2014-05-16 16:25:18 +02:00
.gitignore Added missing files .gitignore 2013-07-21 14:12:18 +02:00
CHANGELOG.md [Yaml] added CHANGELOG 2012-04-26 19:44:03 +02:00
composer.json updated version to 2.5 2013-11-24 21:17:07 +01:00
Dumper.php fixed types in phpdocs 2014-04-16 12:30:19 +02:00
Escaper.php fixed types in phpdocs 2014-04-16 12:30:19 +02:00
Inline.php Fixed YAML Parser does not ignore duplicate keys, violating YAML spec. 2014-05-16 16:25:18 +02:00
LICENSE update year on licenses 2014-01-07 08:19:25 -05:00
Parser.php Fixed YAML Parser does not ignore duplicate keys, violating YAML spec. 2014-05-16 16:25:18 +02:00
phpunit.xml.dist made usage of Composer autoloader for subtree-split unit tests 2012-11-09 14:10:06 +01:00
README.md updated the composer install command to reflect changes in Composer 2013-09-18 09:27:26 +02:00
Unescaper.php Lower mbstring dep, remove it for Yaml and CssSelector components 2014-05-12 11:13:35 +02:00
Yaml.php made phpdoc types consistent with those defined in Hack 2014-04-15 07:41:45 +02:00

Yaml Component

YAML implements most of the YAML 1.2 specification.

use Symfony\Component\Yaml\Yaml;

$array = Yaml::parse($file);

print Yaml::dump($array);

Resources

You can run the unit tests with the following command:

$ cd path/to/Symfony/Component/Yaml/
$ composer.phar install
$ phpunit