Typed Properties and default column/association types #6356

Open
opened 2026-01-22 15:31:39 +01:00 by admin · 0 comments
Owner

Originally created by @beberlei on GitHub (Dec 1, 2019).

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.

Originally created by @beberlei on GitHub (Dec 1, 2019). ### 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. ```php 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.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#6356