Skip to content

[Yaml] Quoting of dumped strings that would be considered boolean by YAML <1.2 #13209

@petert82

Description

@petert82

I understand the Yaml component partially implements YAML 1.2, and as such does not quote PHP strings containing values that would be considered as boolean values by parsers implementing older versions of the YAML spec.

For example, dumping this PHP array:

array('country_code' => 'no');

Would output yaml like:

country_code: no

And not:

country_code: 'no'

This makes using yaml files dumped by the Yaml component in environments where they will be parsed by non-1.2 compliant parsers interesting.

Would it be desirable to change the behaviour of the Dumper so that it quotes possibly-boolean-per-the-older-spec strings ('yes', 'no', 'on', 'off', etc)? Obviously this extra quoting is not required for YAML 1.2 compliance, but I don't think this change would have any harmful side-effects.

It looks like implementing this would be a simple change in the Yaml\Inline class - and I'd be happy to do it (1st time contributer, please be gentle :D) - but I don't really want to try patching this in if it's decided this is a stupid/impossible idea.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions