php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #61244 Translitrator __construct should be like create
Submitted: 2012-03-02 14:02 UTC Modified: 2012-03-02 21:44 UTC
From: jinmoku at hotmail dot com Assigned:
Status: Wont fix Package: I18N and L10N related
PHP Version: 5.4.0 OS: Windows 7
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.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: jinmoku at hotmail dot com
New email:
PHP Version: OS:

 

 [2012-03-02 14:02 UTC] jinmoku at hotmail dot com
Description:
------------
Translitrator __construct should be like create


Test script:
---------------
$trans = new Transliterator('NFD; [:Nonspacing Mark:] Remove; NFC');
echo $trans->transliterate('hé');

Expected result:
----------------
he

Actual result:
--------------
Fatal error: Call to private Transliterator::__construct() from invalid context in D:\www\test\index.php on line 4

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-03-02 21:44 UTC] cataphract@php.net
The reason for not exposing a public constructor is that this gives a little more latitude for building, in the future, a proper inheritance interface.

Factory methods are more versatile than constructors because they can return different class types. In the future, we may want to expose subclasses of Transliterator. Let's say that the transliterator 'NFD' has, in ICU, a specific C++ type (class) with more methods. With a factory method we can return a PHP class that exposes these additional C++ methods, while with a constructor we couldn't.
 [2012-03-02 21:44 UTC] cataphract@php.net
-Status: Open +Status: Wont fix
 [2012-03-02 22:11 UTC] jinmoku at hotmail dot com
I understand, but you should change the documentation
 [2012-03-03 15:08 UTC] cataphract@php.net
Automatic comment from SVN on behalf of cataphract
Revision: http://svn.php.net/viewvc/?view=revision&revision=323851
Log: - Documented Transliterator::__construct. See bug #61244.
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Sat Aug 24 02:01:27 2019 UTC