|  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
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 Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: kermodebear at gmail dot com
New email:
PHP Version: OS:


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

Reproduce code:
$example = new MessageFormatter('en_US', '{0,oops}');

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:


Add a Patch

Pull Requests

Add a Pull Request


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: 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]
-Status: Open +Status: Wont fix
 [2012-04-21 10:33 UTC]
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-2020 The PHP Group
All rights reserved.
Last updated: Wed Dec 02 10:01:24 2020 UTC