Skip to content

Commit 67e021a

Browse files
committed
Minor reword
1 parent 9afd9fd commit 67e021a

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

components/yaml.rst

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -338,13 +338,12 @@ syntax to parse them as proper PHP constants::
338338
$parameters = Yaml::parse($yaml, Yaml::PARSE_CONSTANT);
339339
// $parameters = ['foo' => 'PHP_INT_SIZE', 'bar' => 8];
340340

341-
Parsing Unit and Backed Enumerations
342-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
341+
Parsing PHP Enumerations
342+
~~~~~~~~~~~~~~~~~~~~~~~~
343343

344-
Unit and backed enumerations can be parsed by the YAML parser thanks to the
345-
special ``!php/enum`` syntax and the ``PARSE_CONSTANT`` flag. Depending if
346-
you need the concrete enumeration case or the actual value of the case when
347-
dealing with backed enumerations, both syntax are available::
344+
The YAML parser supports `PHP enumerations`_, both unit and backed enums.
345+
By default, they are parsed as regular strings. Use the ``PARSE_CONSTANT`` flag
346+
and the special ``!php/enum`` syntax to parse them as proper PHP enums::
348347

349348
enum FooEnum: string
350349
{
@@ -356,12 +355,18 @@ dealing with backed enumerations, both syntax are available::
356355

357356
$yaml = '{ foo: FooEnum::Foo, bar: !php/enum FooEnum::Foo }';
358357
$parameters = Yaml::parse($yaml, Yaml::PARSE_CONSTANT);
358+
// the value of the 'foo' key is a string because it missed the `!php/enum` syntax
359359
// $parameters = ['foo' => 'FooEnum::Foo', 'bar' => FooEnum::Foo];
360360

361361
$yaml = '{ foo: FooEnum::Foo, bar: !php/enum FooEnum::Foo->value }';
362362
$parameters = Yaml::parse($yaml, Yaml::PARSE_CONSTANT);
363+
// the value of the 'foo' key is a string because it missed the `!php/enum` syntax
363364
// $parameters = ['foo' => 'FooEnum::Foo', 'bar' => 'foo'];
364365

366+
.. versionadded:: 6.2
367+
368+
The support for PHP enumerations was introduced in Symfony 6.2.
369+
365370
Parsing and Dumping of Binary Data
366371
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
367372

@@ -484,3 +489,4 @@ Learn More
484489
.. _`YAML`: https://yaml.org/
485490
.. _`YAML 1.2 version specification`: https://yaml.org/spec/1.2/spec.html
486491
.. _`ISO-8601`: https://www.iso.org/iso-8601-date-and-time-format.html
492+
.. _`PHP enumerations`: https://www.php.net/manual/en/language.types.enumerations.php

0 commit comments

Comments
 (0)