Skip to content

MessageFormatter throws error on unused datetime value #16814

@naturefund-falk

Description

@naturefund-falk

Description

The following code:

<?php
$fmt = new MessageFormatter('de', 'Beispiel ohne Benutzung');

echo $fmt->format(['payed' => new DateTimeImmutable()]);

Resulted in this output:

PHP Fatal error:  Uncaught Error: Object of class DateTimeImmutable could not be converted to string in /home/development/fst/src/tests/messageFormatter.php:5

But I expected this output instead:

No error, because value not used. No reason to convert the datetime value to a string

Intl data

Internationalization support => enabled
ICU version => 72.1
ICU Data version => 72.1
ICU TZData version => 2022e
ICU Unicode version => 15.0

PHP Version

PHP 8.2.24

Operating System

Debian 12

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions