freescout-calendar-module/vendor/dallgoot/yaml/documentation/coherence.md
2024-09-10 16:29:40 +02:00

620 B

Sometimes the handling of dataypes in other libraries can be confusing

Example from Symfony Yaml

$object = new \stdClass();
$object->foo = 'bar';

$dumped = Yaml::dump(['data' => $object], 2, 4, Yaml::DUMP_OBJECT_AS_MAP);
// $dumped = "data:\n    foo: bar"

Dallgoot\Yaml removes this ambiguity by matching a specific PHP data types with its YAML counterpart like so :

  • PHP standard objects -> YAML mapping
  • PHP standard array -> YAML sequence
  • Dallgoot\Types\Compact -> YAML mapping or sequence according to content
  • Dallgoot\Types\YamlObject -> YAML mapping or sequence according to content