php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #58631 MessageFormatter Constructor Returns Null
Submitted: 2009-04-14 11:04 UTC Modified: 2012-04-21 10:33 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: kermodebear at gmail dot com Assigned:
Status: Wont fix Package: intl (PECL)
PHP Version: 5.2.8 OS: Linux 2.6.9
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: kermodebear at gmail dot com
New email:
PHP Version: OS:

 

 [2009-04-14 11:04 UTC] kermodebear at gmail dot com
Description:
------------
The MessageFormatter constructor returns null when using an invalid format string.

Reproduce code:
---------------
<?php
$example = new MessageFormatter('en_US', '{0,oops}');
var_dump($example);
?>

Expected result:
----------------
I expected to receive a MessageFormatter object. The output of the script above should be:

object(MessageFormatter)#1 (0) {
}

An invalid token in the format string should be ignored, possibly with an a error triggered, and a valid object returned. 

Alternately, an InvalidArgumentException exception could be thrown.

Actual result:
--------------
NULL

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-03-18 20:56 UTC] will dot skates at ntlworld dot com
The list of valid patterns can be found here: http://icu-project.org/apiref/icu4j/com/ibm/icu/text/MessageFormat.html. Check that your pattern is valid before attempting to create the object. 

You are correct however that a catchable exception should be thrown when you attempt to create it, could someone please write a patch for this?
 [2012-04-21 10:33 UTC] cataphract@php.net
-Status: Open +Status: Wont fix
 [2012-04-21 10:33 UTC] cataphract@php.net
The current standard behavior in intl is returning NULL on constructor errors. This may change in the future, but I don't see a strong need for such change in behavior.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 13:01:31 2024 UTC