|  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.
Block user comment
Status: Assign to:
Bug Type:
From: jinmoku at hotmail dot com
New email:
PHP Version: OS:


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

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

Expected result:

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


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2012-03-02 21:44 UTC]
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]
-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]
Automatic comment from SVN on behalf of cataphract
Log: - Documented Transliterator::__construct. See bug #61244.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Jul 22 01:01:29 2024 UTC