|  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
Have you experienced this issue?
Rate the importance of this bug to you:

 [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: Sun Jul 21 03:01:29 2024 UTC