php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #49161 Got null upon the MessageFormatter() class instantiation with empty pattern.
Submitted: 2009-08-05 00:29 UTC Modified: 2015-06-16 11:37 UTC
From: maximgb at yandex dot ru Assigned: stas (profile)
Status: Closed Package: *Languages/Translation
PHP Version: 5.*, 6 (2009-08-05) OS: *
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:
28 - 6 = ?
Subscribe to this entry?

 
 [2009-08-05 00:29 UTC] maximgb at yandex dot ru
Description:
------------
I've tryed to create the MessageFormatter class, from intl extension, 
passing an empty string for the constructor's second argument and I was 
pretty surprised to get NULL instead of object instance :)

Reproduce code:
---------------
$f = new MessageFormatter(Locale::getDefault(), '');
var_dump($f, is_object($f));

$f = MessageFormatter::create(Locale::getDefault(), '');
var_dump($f, is_object($f));


Expected result:
----------------
object(MessageFormatter)#1 (0) {
}
bool(true)
object(MessageFormatter)#2 (0) {
}
bool(true)

Actual result:
--------------
NULL
bool(false)
NULL
bool(false)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-08-05 07:48 UTC] jani@php.net
Apparently you must pass it at least 1 char pattern. Empty string isn't one. Not sure if this is intentional, Stas?
 [2009-08-10 17:20 UTC] stas@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

ICU considers empty patterns to be invalid, so we do so too. 
 [2009-08-10 17:21 UTC] stas@php.net
BTW, you can use intl_get_error_message() to see what's wrong.
 [2009-08-10 18:40 UTC] maximgb at yandex dot ru
That's of course for you to decide, but as for me getting NULL as new 
operator result is a bug.
 [2015-06-16 11:37 UTC] danack@php.net
-Status: Not a bug +Status: Closed
 [2015-06-16 11:37 UTC] danack@php.net
This is fixed in PHP 7.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 09:01:28 2024 UTC