[php-src] Issue #8364: MessageFormatter fails with U_ILLEGAL_ARGUMENT_ERROR

From: Date: Wed, 13 Apr 2022 14:43:01 +0000
Subject: [php-src] Issue #8364: MessageFormatter fails with U_ILLEGAL_ARGUMENT_ERROR
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-240932@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/8364 Author: hhofstaetter ### Description The following code: ```php <?php $formatter = new MessageFormatter('en', 'translate {0}'); $args = ['string', 'string']; foreach ($args as &$arg) { // do nothing; } $result = $formatter->format($args); var_dump($result); var_dump(intl_get_error_message()); ``` Resulted in this output: ``` bool(false) string(107) "No strategy to convert the value given for the argument with key '1' is available: U_ILLEGAL_ARGUMENT_ERROR" ``` But I expected this output instead: ``` string(11) "translate 8" string(12) "U_ZERO_ERROR" ``` The error happens only if arguments are used in the foreach by reference and only if the number of arguments in the array and in the translation string are different. The code works fine in 5.6, it fails in 7.0 and newer versions. ### PHP Version 8.0.17, 8.1.4 ### Operating System _No response_

« previous php.bugs (#240932) next »