php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #66463 MessageFormatter::parse() dont output named array indices
Submitted: 2014-01-11 11:01 UTC Modified: 2016-04-12 13:15 UTC
From: gmblar+php at gmail dot com Assigned:
Status: Not a bug Package: intl (PECL)
PHP Version: 5.5.8 OS: MacOSX 10.9.1
Private report: No CVE-ID: None
 [2014-01-11 11:01 UTC] gmblar+php at gmail dot com
Description:
------------
MessageFormatter::format() accepted named arguments to create strings, but MessageFormatter::parse() dont output named array indices.

Test script:
---------------
$messageFormatter = new MessageFormatter(NULL, 'foo {0}, bar {1}');
$output = $messageFormatter->format(array(
    23,
    42
));
var_dump($output);
var_dump($messageFormatter->parse($output));


$messageFormatter = new MessageFormatter(NULL, 'foo {foo}, bar {bar}');
$output = $messageFormatter->format(array(
    'foo' => 23,
    'bar' => 42
));
var_dump($output);
var_dump($messageFormatter->parse($output));


Expected result:
----------------
string(14) "foo 23, bar 42"
array(2) {
  [0]=>
  string(2) "23"
  [1]=>
  string(2) "42"
}

string(14) "foo 23, bar 42"
array(2) {
  [foo]=>
  string(2) "23"
  [bar]=>
  string(2) "42"
}


Actual result:
--------------
string(14) "foo 23, bar 42"
array(2) {
  [0]=>
  string(2) "23"
  [1]=>
  string(2) "42"
}

string(14) "foo 23, bar 42"
bool(false)


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-04-12 13:15 UTC] ab@php.net
-Status: Open +Status: Not a bug
 [2016-04-12 13:15 UTC] ab@php.net
Thanks for the report. This behavior is conditioned by the underlying implementation http://www.icu-project.org/apiref/icu4c/classicu_1_1MessageFormat.html#a17e56db0a75a94483872a9994efd156d which doesn't support named arguments.

Thanks.
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Fri Jun 05 23:01:24 2020 UTC