Giter VIP home page Giter VIP logo

doctrine-entities-generator-bundle's Issues

Wrong typehint for DateTime

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.

readonly properties should not have setters

It is possible that entity can have readonly properties. Example cases:

  • entity data comes from materialized view
  • field value comes from generated column
  • field value set elsewhere outside entity, e.g. with custom UPDATE queries, or from other app sharing this db
  • property is set in constructor for a new entity and persisted forever in that state

A readonly access modifier becomes useful here to enforce that no modifications are allowed. But with it, generated setter methods are invalid.

Generator should omit setter methods for fields, embeddeds and to-one associations, if a property is readonly.

Support Embeddables

#[ORM\Embedded]
protected MyEmbed $obj;

Results in:

In EntityGenerator.php line 114:
Warning: Undefined array key "obj"

It seems that embeddables are not supported currently, but neither are they skipped, and it fails here:

if ($metadata->hasField($property)) {
$this->addField($request, $metadata->fieldMappings[$property]);
} elseif ($metadata->hasAssociation($property)) {

because hasField is:
return isset($this->fieldMappings[$fieldName]) || isset($this->embeddedClasses[$fieldName])

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.