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

Doctrine's array of enums not supported #150

Open
ThomasLandauer opened this issue Dec 13, 2023 · 0 comments
Open

Doctrine's array of enums not supported #150

ThomasLandauer opened this issue Dec 13, 2023 · 0 comments

Comments

@ThomasLandauer
Copy link

doctrine/orm 2.12.0 supports arrays of enums, see doctrine/orm#9497

This is the syntax:

#[ORM\Column(type: Types::SIMPLE_ARRAY, length: 255, nullable: true, enumType: Foo::class)]
private array $foo = [];

With the setter/getter set up like this:

/**
 * @return array<int,Foo>
 */
public function getFoo(): array
{
    return $this->foo;
}

/**
 * @param array<int,Foo> $foo
 */
public function setFoo(array $foo): self
{
    $this->foo = $foo;
    return $this;
}

... psalm is reporting:

ERROR: MixedReturnTypeCoercion - The declared return type 'array<int, Foo>' for Entity::getFoo is more specific than the inferred return type 'array<array-key, mixed>' (see https://psalm.dev/197)
     * @return array<int, Foo>


ERROR: MixedReturnTypeCoercion - The type 'array<array-key, mixed>' is more general than the declared return type 'array<int, Foo>' for Entity::getFoo (see https://psalm.dev/197)
        return $this->foo;
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