Orm: Typed Properties and default column/association types

Created on 1 Dec 2019  路  1Comment  路  Source: doctrine/orm

Feature Request

| Q | A
|------------ | ------
| New Feature | yes
| RFC | no
| BC Break | no

Summary

When declaring a type on a property, this should act as a default for field type or ManyToOne/OneToOne targetEntity.

class User
{
    /** @ORM\Column */
    public int $id; // defaults to type="integer"

   /** @ORM\ManyToOne */
   public Email $email; // defaults to targetEntity=Email::class
}

The relevant code would be in ClassMetadataInfo::mapField, mapManyToOne and mapOneToOne. Whenever type or targetEntity is missing, it could look this up in reflection property instead if it has a type.

Most helpful comment

Could we expect it'll also detect nullable properties?

/** @ORM\Column */
public ?string $name;

>All comments

Could we expect it'll also detect nullable properties?

/** @ORM\Column */
public ?string $name;
Was this page helpful?
0 / 5 - 0 ratings