File tree Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -355,6 +355,26 @@ and the special ``!php/enum`` syntax to parse them as proper PHP enums::
355355 // the value of the 'foo' key is a string because it missed the `!php/enum` syntax
356356 // $parameters = ['foo' => 'FooEnum::Foo', 'bar' => 'foo'];
357357
358+ You can also use ``!php/enum `` to get all the enumeration cases by only
359+ giving the enumeration FQCN::
360+
361+ enum FooEnum: string
362+ {
363+ case Foo = 'foo';
364+ case Bar = 'bar';
365+ }
366+
367+ // ...
368+
369+ $yaml = '{ bar: !php/enum FooEnum }';
370+ $parameters = Yaml::parse($yaml, Yaml::PARSE_CONSTANT);
371+ // $parameters = ['bar' => ['foo', 'bar']];
372+
373+ .. versionadded :: 7.1
374+
375+ The support for using the enum FQCN without specifying a case
376+ was introduced in Symfony 7.1.
377+
358378Parsing and Dumping of Binary Data
359379~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
360380
Original file line number Diff line number Diff line change @@ -346,6 +346,19 @@ official YAML specification but are useful in Symfony applications:
346346 # ... or you can also use "->value" to directly use the value of a BackedEnum case
347347 operator_type : !php/enum App\Operator\Enum\Type::Or->value
348348
349+ This tag allows to omit the enum case and only provide the enum FQCN
350+ to return an array of all available enum cases:
351+
352+ .. code-block :: yaml
353+
354+ data :
355+ operator_types : !php/enum App\Operator\Enum\Type
356+
357+ .. versionadded :: 7.1
358+
359+ The support for using the enum FQCN without specifying a case
360+ was introduced in Symfony 7.1.
361+
349362Unsupported YAML Features
350363~~~~~~~~~~~~~~~~~~~~~~~~~
351364
You can’t perform that action at this time.
0 commit comments