Skip to content

Wrong typehint for DateTime #1

@klkvsk

Description

@klkvsk

Given the following property

    #[ORM\Column(type: 'datetimetz_immutable', nullable: false)]
    protected ?DateTimeInterface $date;

generated output will be:

    public function setDate(?\DateTimeImmutable $date): self
    {
        $this->date = $date;

        return $this;
    }

    public function getDate(): ?\DateTimeImmutable
    {
        return $this->date;
    }

(note that typehint is \DateTimeImmutable, not \DateTimeInterface)

While this is technically correct from Doctrine's point of view, it will be better to prefer interface as typehint, especially when it is explicitly used in property's type.

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