Skip to content

Accept DateTimeInterface in date_span instead of only DateTime #44

Description

@javihgil

Problem

date_span() currently type-hints DateTime.

That excludes DateTimeImmutable, even though immutable date objects are common in modern Symfony applications.

Current evidence

  • src/Twig/Extension/DateSpanExtension.php accepts DateTime $dateTime
  • the helper logic only needs a standard PHP date-time interface, not the mutable implementation specifically

Expected behavior

The filter should work with standard PHP date objects, including DateTimeImmutable.

Suggested work

  • change the accepted type to DateTimeInterface
  • add tests covering immutable date instances
  • update documentation and feature definitions so the supported input types are explicit

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions