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

 [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-2018 The PHP Group
All rights reserved.
Last updated: Fri Jun 22 17:01:44 2018 UTC