php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #65055 new Operator shuld never return a NULL new ResourceBundle
Submitted: 2013-06-18 07:59 UTC Modified: 2015-12-11 20:10 UTC
Votes:2
Avg. Score:5.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (50.0%)
From: goetas at lignano dot it Assigned: danack (profile)
Status: Closed Package: I18N and L10N related
PHP Version: 5.4.16 OS: ubuntu 12.04
Private report: No CVE-ID: None
 [2013-06-18 07:59 UTC] goetas at lignano dot it
Description:
------------
sapi/cli/php -v
PHP 5.4.16 (cli) (built: Jun 18 2013 09:34:40) 
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies


Instantiating ResourceBundle class, a "new" operator should never return null.

http://php.net/manual/en/language.oop5.basic.php#language.oop5.basic.new

"To create an instance of a class, the new keyword must be used. An object will always be created unless the object has a constructor defined that throws an exception on error."

This behaviour it's also verified by Symfony team https://github.com/symfony/Intl/blob/master/ResourceBundle/Reader/BinaryBundleReader.php


Test script:
---------------
sapi/cli/php -r 'var_dump(new \ResourceBundle("ANY WRONG PATH", "it"));'



Expected result:
----------------
Thrown some exception

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

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-06-24 03:14 UTC] felipe@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: stas
 [2013-06-24 03:14 UTC] felipe@php.net
Seems it is not the only class which has such behavior.
 [2013-06-25 07:06 UTC] goetas at lignano dot it
Similar behaviour has been verified with NumberFormatter class
 [2013-06-25 10:36 UTC] laruence@php.net
hmm, there are also some similar cases in file info
 [2015-03-23 18:52 UTC] cmb@php.net
-Assigned To: stas +Assigned To: danack
 [2015-03-23 18:52 UTC] cmb@php.net
There is a respective RFC[1], which is likely to pass, in which
case this bug can be closed.

[1] <https://wiki.php.net/rfc/internal_constructor_behaviour>
 [2015-12-11 20:10 UTC] danack@php.net
-Status: Assigned +Status: Closed
 [2015-12-11 20:10 UTC] danack@php.net
This is implemented in PHP 7, where all constructors now either succeed or throw an exception.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 26 19:01:30 2024 UTC