You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
DateParserTransformer fails with a TypeError on a \DateTimeImmutable input #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().
$ bin/console cleverage:process:execute demo.date.date_parser
CRITICAL [cleverage_process] Critical process failure ["error" => "Process demo.date.date_parser has failed during process parse_immutable with message: 'Transformation 'date_parser' have failed: DateTime::createFromFormat(): Argument #2 ($datetime) must be of type string, DateTimeImmutable given'."]
if (!$value || $valueinstanceof \DateTime) {
return$value;
}
$date = \DateTime::createFromFormat($options['format'], $value); // TypeError for a \DateTimeImmutable
The Notes section of docs/reference/transformers/date_parser_transformer.md currently documents this failure.
Proposed fix
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).
Requirements
Documentation updates
Reference
Cookbooks
Changelog
Unit tests
Breaking changes
None: a \DateTimeImmutable input currently always fails.
Activity
Merge pull request #209 from cleverage/198
Merge pull request #52 from cleverage/process-bundle-198