Skip to content

make:entity wrong setter for non nullable fields #198

Open
@sbruev

Description

@sbruev

Hi!
It's a minor syntax mistake, but right now generated setters allow to pass the null value to non nullable fields, if they are ManyToOne relationship.

    /**
     * @ORM\ManyToOne(targetEntity="App\Entity\AnotherEntity")
     * @ORM\JoinColumn(nullable=false)
     */
    private $anotherEntity;

    //...

    public function setAnotherEntity(?AnotherEntity $anotherEntity): self
    {
        $this->anotherEntity = $anotherEntity;

        return $this;
    }

The arg should be AnotherEntity not ?AnotherEntity

Cheers!

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugBug Fix

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions