Skip to content

Some, but not all, PropertyCaster Attributes target the property as well as the parameter. #81

Open
@cooperaj

Description

@cooperaj

When using constructor promotion on a hydrated object the parameters of the constructor are also properties. This works fine in the ObjectHydrator code base but as soon as you start using other libraries that observe Attributes it can cause breakages.

Class Targets
MapFrom Both
CastListToType Both
CastToDateTimeImmutable Parameter

In particular laminas-form can use an attribute builder to build out forms from objects but it's code naively looks at the properties of a class. If it comes across an Attribute it instantiates it but this fails if the Attribute is only registered as TARGET_PARAMETER.

It's a difficult one. Laminas-form shouldn't be so naive about what an attribute targets but also, in a property promotion world those targets will always be both a parameter AND a property so a library like this should also work with that.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions