Skip to content

[make:entity] addGetter on boolean field that starts with "is" #1492

@ClemRiviere

Description

@ClemRiviere

Hi devs,

Context

Here is an exemple of an Entity created with a "isFooProp" boolean field :

> symfony console make:entity Test
 created: src/Entity/Test.php
 created: src/Repository/TestRepository.php
 
 Entity generated! Now let's add some fields!
 You can always add more fields later manually or by re-running this command.

 New property name (press <return> to stop adding fields):
 > isFooProp

 Field type (enter ? to see all types) [boolean]:
 > 

 Can this field be null in the database (nullable) (yes/no) [no]:
 > 

 updated: src/Entity/Test.php

Current behavior

This is the resulting entity :

#[ORM\Entity(repositoryClass: TestRepository::class)]
class Test
{
   ...
    #[ORM\Column]
    private ?bool $isFooProp = null;
    ...

    public function isIsFooProp(): ?bool
    {
        return $this->isFooProp;
    }

    public function setIsFooProp(bool $isFooProp): static
    ...
}

Proposed behavior

#[ORM\Entity(repositoryClass: TestRepository::class)]
class Test
{
   ...
    #[ORM\Column]
    private ?bool $isFooProp = null;
    ...

    public function isFooProp(): ?bool
    {
        return $this->isFooProp;
    }

    public function setIsFooProp(bool $isFooProp): static
    ...
}

I already worked on this modification and should be able to propose a PR, I just wanted to have your feedback on this topic before. All comments are welcome :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions