Skip to content

Array of enums as Json array not supported #628

Open
@maximecolin

Description

@maximecolin

With Doctrine, we can define an array of enum as a json array column using Types::JSON with enumType option.

/** @var Foobar[] $foobars */
#[ORM\Column(type: Types::JSON, enumType: Foobar::class, options: ['default' => '[]'])]
private array $foobars = [];

This result in the following phpstan error:

Property App\Entity\User::$foobars type mapping mismatch: backing type string of enum App\Enums\Foobar does not match value type mixed of the database type array|bool|float|int|JsonSerializable|stdClass|string|null.
🪪 doctrine.enumType

If I switch to Types::SIMPLE_ARRAY, no error anymore.

I guess the rule does not handle json array yet.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions