Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Array of enums as Json array not supported #628

Open
maximecolin opened this issue Nov 13, 2024 · 0 comments
Open

Array of enums as Json array not supported #628

maximecolin opened this issue Nov 13, 2024 · 0 comments

Comments

@maximecolin
Copy link

maximecolin commented Nov 13, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant