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
Fabien Potencier 689cf99c4e bug #13262 [Yaml] Improve YAML boolean escaping (petert82, larowlan)
This PR was merged into the 2.3 branch.

Discussion
----------

[Yaml] Improve YAML boolean escaping

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

This PR ensures that PHP [values which would be interpreted as booleans][1] in older versions of the YAML spec are escaped with single quotes when dumped by the Dumper.

For example, dumping this:

```php
array(
    'country_code' => 'no',
    'speaks_norwegian' => 'y',
    'heating' => 'on',
)
```

Will produce this YAML:

```yaml
country_code: 'no'
speaks_norwegian: 'y'
heating: 'on'
```

[1]: http://yaml.org/type/bool.html

Commits
-------

8fa056b Inline private 'is quoting required' methods in Escaper
afe827a Merge pull request #2 from larowlan/patch-2
a0ec0fe Add comment as requested
1e0633e Merge pull request #1 from larowlan/patch-1
81a8090 Remove duplicate 'require'
3760e67 [Yaml] Improve YAML boolean escaping
2015-01-16 14:53:48 +01:00
..
Exception Docblock fixes 2014-11-30 13:33:44 +00:00
Tests bug #13262 [Yaml] Improve YAML boolean escaping (petert82, larowlan) 2015-01-16 14:53:48 +01: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 the branch alias in composer files 2013-01-31 22:39:01 +01:00
Dumper.php Docblock fixes 2014-11-30 13:33:44 +00:00
Escaper.php Inline private 'is quoting required' methods in Escaper 2015-01-16 14:15:13 +01:00
Inline.php [Yaml] Improve YAML boolean escaping 2015-01-05 12:50:08 +01:00
LICENSE Updated copyright to 2015 2015-01-01 13:56:52 +01:00
Parser.php [Yaml] Fixed #10597: Improved Yaml directive parsing 2015-01-09 15:23:46 +01:00
phpunit.xml.dist [Tests] Silenced all deprecations in tests for 2.3 2014-12-18 20:00:19 +01:00
README.md [Yaml] Update README.md 2015-01-03 11:53:56 +01:00
Unescaper.php [2.3] CS And DocBlock Fixes 2014-12-22 16:58:09 +01:00
Yaml.php Docblock fixes 2014-11-30 13:33:44 +00:00

Yaml Component

YAML implements most of the YAML 1.2 specification.

use Symfony\Component\Yaml\Yaml;

$array = Yaml::parse(file_get_contents(filename));

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