Skip to content

Detect field type with property type #2661

Open
@GromNaN

Description

@GromNaN

Feature Request

Q A
New Feature yes
RFC yes
BC Break no

Summary

In metadata, the default type of fields is string, regardless of the type of field property. I propose to inspect the property types when the field type is not defined. The would only support simple types (maybe with extension point):

property field
int int
string string
float float
DateTime date
DateTimeInterface date_immutable
DateTimeImmutable date_immutable
ObjectId object_id

Benefit: no need to declare the field type.

Usage

#[Document]
class User
{
    #[Id]
    public string $id;

    #[Field]
    public string $name;

    #[Field]
    public DateTimeImmutable $createdAt;

    #[Field]
    public int $level;
}

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