Bug #65163 [Opn->Asn]: Collator::__construct inconsistency between doc and implementation

From: Date: Mon, 15 Jul 2013 00:38:27 +0000
Subject: Bug #65163 [Opn->Asn]: Collator::__construct inconsistency between doc and implementation
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-180262@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:         felipe@php.net
 Reported by:        poinsot dot julien at gmail dot co
 Summary:            Collator::__construct inconsistency between doc and
                     implementation
-Status:             Open
+Status:             Assigned
 Type:               Bug
-Package:            intl
+Package:            I18N and L10N related
 PHP Version:        Irrelevant
-Assigned To:        
+Assigned To:        stas
 Block user comment: N
 Private report:     N



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


Thread (1 message)

  • felipe@php.net
  • Unknown Message
    • felipe@php.net
« previous php.bugs (#180262) next »