Bug->Doc #65163 [Asn]: Collator::__construct inconsistency between doc and implementation
| From: | stas@php.net | Date: | Sun, 08 Jun 2014 23:06:05 +0000 |
| Subject: | Bug->Doc #65163 [Asn]: Collator::__construct inconsistency between doc and implementation | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-11267@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=65163&edit=1
ID: 65163
Updated by: stas@php.net
Reported by: poinsot dot julien at gmail dot co
Summary: Collator::__construct inconsistency between doc and
implementation
Status: Assigned
-Type: Bug
+Type: Documentation Problem
Package: I18N and L10N related
PHP Version: Irrelevant
Assigned To: stas
Block user comment: N
Private report: N
New Comment:
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.
Previous Comments:
------------------------------------------------------------------------
[2013-06-28 21:13:04] poinsot dot julien at gmail dot co
Description:
------------
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('');
var_dump(
$coll->getLocale(Locale::VALID_LOCALE)
);
Expected result:
----------------
string(4) "root"
Actual result:
--------------
string(5) "fr_FR"
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=65163&edit=1