|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #65163 Collator::__construct inconsistency between doc and implementation
Submitted: 2013-06-28 21:13 UTC Modified: 2014-06-08 23:24 UTC
Avg. Score:4.5 ± 0.9
Reproduced:4 of 4 (100.0%)
Same Version:3 (75.0%)
Same OS:3 (75.0%)
From: poinsot dot julien at gmail dot co Assigned: stas (profile)
Status: Closed Package: I18N and L10N related
PHP Version: Irrelevant OS:
Private report: No CVE-ID: None
 [2013-06-28 21:13 UTC] poinsot dot julien at gmail dot co
There is an inconsistency between current PHP implemention and the documentation about Collator::__construct, Collator::create and collator_create.

It says:

Special values for locales can be passed in - if null is passed for the locale, the default locale collation rules will be used. If empty string ("") or "root" are passed, UCA rules will be used.

But actual implementation of collator_ctor in ext/intl/collator/collator_create.c does not check type of its parameter:

if( zend_parse_parameters( ZEND_NUM_ARGS() TSRMLS_CC, "s", &locale, &locale_len ) == FAILURE )
/* ... */
if(locale_len == 0) {
    locale = intl_locale_get_default(TSRMLS_C);

So, for PHP, a NULL value as an empty string imply the default locale.

Test script:
ini_set('intl.default_locale', fr_CA);

$coll = new Collator('');

Expected result:
string(4) "root"

Actual result:
string(5) "fr_FR"


collator_create (last revision 2013-06-28 21:14 UTC by poinsot dot julien at gmail dot co)

Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2013-07-15 00:38 UTC]
-Status: Open +Status: Assigned -Package: intl +Package: I18N and L10N related -Assigned To: +Assigned To: stas
 [2014-06-08 23:06 UTC]
-Type: Bug +Type: Documentation Problem
 [2014-06-08 23:06 UTC]
I think, given how long it has been the case, and that all other classes see "" and null as the same, it's better to fix the docs to state "" and null are the same and "root" is UCA rules. This would not remove any functionality - "root" still works - but would make intl more consistent.
 [2014-06-08 23:24 UTC]
Automatic comment from SVN on behalf of stas
Log: Fix bug #65163: match the docs to the code
 [2014-06-08 23:24 UTC]
-Status: Assigned +Status: Closed
 [2014-06-08 23:24 UTC]
The fix for this bug has been committed.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at

 For Windows:
Thank you for the report, and for helping us make PHP better.

 [2020-02-07 06:08 UTC]
Automatic comment on behalf of stas
Log: Fix bug #65163: match the docs to the code
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Tue Dec 06 01:05:53 2022 UTC