Skip to content

[Form] Support \DateTimeImmutable #9508

Closed
@stof

Description

@stof

These form types should support a way to use the DateTimeImmutable class of PHP 5.5 (only on PHP 5.5+ obviously) for applications using it.

This involves accepting them as input and returning an immutable datetime as model data after the transformation.

The easiest implementation is probably to add a new value for the input option and add a transformer converting the immutable date into a mutable one (so that the norm data stays a DateTime class).

If a new major version of Symfony bumps the requirement to PHP 5.5+, the normalized data could then be switched to the DateTimeImmutable class to simplify the logic (which is currently cloning the DateTime to avoid modifying the original one.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions