php / php-src

The PHP Interpreter
https://www.php.net
Other
38.22k stars 7.75k forks source link

MessageFormatter throws error on unused datetime value #16814

Open naturefund-falk opened 3 hours ago

naturefund-falk commented 3 hours ago

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

devnexen commented 2 hours ago

I ll have a look into this, your report makes sense tough.