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 Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
34 - 24 = ?
Subscribe to this entry?

 
 [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-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 01:01:28 2024 UTC