Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Yaml] Dumper for enums return !php/const instead of !php/enum #53636

Closed
@cobyl

Description

@cobyl

Symfony version(s) affected

7.0.0

Description

Dumper for enums return !php/const instead of !php/enum

How to reproduce

        $dump  = Yaml::dump(Level::Debug, 256);
        var_dump($dump);

gives:

       "!php/const Monolog\Level::Debug"

Possible Solution

The yaml component properly evolves php/const in such situations and returns an enum anyway, but this is confusing.

Replace in Inline.php this line

            case $value instanceof \UnitEnum:
                return sprintf('!php/const %s::%s', $value::class, $value->name);

and corresponding tests

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions