8000 Serialization broken with doctrine enum attribute · Issue #45028 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content
Serialization broken with doctrine enum attribute #45028
Closed
@GRodrigoSM

Description

@GRodrigoSM

Symfony version(s) affected

5.4

Description

Updated Doctrine 2.11 and tried to use the backed enums.
https://www.doctrine-project.org/2022/01/11/orm-2.11.html

There is a problem in the deserialization process, symfony doesn't recognize that the enum field 'type' is an enum and that the enum entity should be constructed with the passed integer.
When i remove the ORM annotation, the serialization process works as intended.

How to reproduce

Person.php -

#[ORM\Column(type: 'integer', enumType: Type::class)]
private Type $type,`

Type

<?php

declare(strict_types=1);

namespace App\Entity\Enum;

enum Type: int
{
    case PARENT = 0;

    case CHILD = 1;
}

Possible Solution

No response

Additional Context

Exception: App\Entity\Person::__construct(): Argument #2 ($type) must be of type App\Entity\Enum\Type, int given

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

      0