Skip to content

#198 - Fix DateParserTransformer - #209

Merged
njoubert-cleverage merged 1 commit into
mainfrom
198
Sep 28, 2026
Merged

njoubert-cleverage merged 1 commit into
mainfrom
198

Conversation

@njoubert-cleverage

Copy link
Copy Markdown
Member

Description

Fixes #198.

DateParserTransformer fails with a TypeError when its input is a \DateTimeImmutable: only \DateTime objects are returned as-is, any other value is passed to \DateTime::createFromFormat().

This PR:

  • convert a \DateTimeImmutable input to a \DateTime with \DateTime::createFromImmutable() (same date, time and timezone), so that the transformer keeps its contract of always outputting a \DateTime;
  • add a unit test;
  • update docs/reference/transformers/date_parser_transformer.md (Accepted inputs, remove the Notes entry).

The new regression tests fail on main and pass with this fix. PHPUnit, PHPStan, PHP-CS-Fixer and Rector pass.

Requirements

  • Documentation updates
    • Reference
    • Cookbooks
    • Changelog
  • Unit tests

Breaking changes

None: a \DateTimeImmutable input currently always fails.

🤖 Generated with Claude Code

…e` input is converted to a `\DateTime` instead of throwing a `TypeError`. Update documentation, add tests.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@njoubert-cleverage njoubert-cleverage self-assigned this Sep 28, 2026
@njoubert-cleverage
njoubert-cleverage merged commit d139690 into main Sep 28, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DateParserTransformer fails with a TypeError on a \DateTimeImmutable input

1 participant