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
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: gmblar+php at gmail dot com
New email:
PHP Version: OS:

 

 [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

Pull Requests

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-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 06:01:30 2024 UTC