|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #72271 Collator::getSortKey() doc page is out of date, incomplete, inaccurate
Submitted: 2016-05-26 20:29 UTC Modified: -
From: pleasestand at live dot com Assigned:
Status: Open Package: intl (PECL)
PHP Version: master-Git-2016-05-26 (Git) OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: pleasestand at live dot com
New email:
PHP Version: OS:


 [2016-05-26 20:29 UTC] pleasestand at live dot com
I noticed some problems with the documentation for Collator::getSortKey() and collator_get_sort_key() at <>:

1. The function was not added in 5.3.11 but rather in 5.3.2, according to the changelog.

2. Example #1 shows a URL-encoded return value of "71%3F%3FE%01%09%01%8F%08%00". According to <>, there is no stability guarantee for sort keys. Recent ICU versions return a different value, so it is not necessarily true that "The above example will output" that value. Instead, the implementation-specific nature of sort keys should be noted.

For example, the "Return Values" section could state, "Collation keys can be compared directly instead of strings, though are implementation specific and change between ICU library versions." Then the Example #1 section could state, "The above example will output (for ICU x.x):", where x.x is the version of ICU matching the example output (which can be changed). The version of ICU is available as INTL_ICU_VERSION (currently not documented at <>).

3. Any version of PHP 5.3.15 or newer, or 5.4.5 or newer, or PECL intl 2.0.1 or newer, is not going to output that exact value, even when used with the same old version of ICU. The null byte at the end was the result of bug #62070, which was fixed in those PHP versions. The "%00" should be removed from the example output, and the behavior change introduced by the bug fix should be noted: now, returned sort keys will not contain *any* null bytes.

While at it, it may also make sense to change from urlencode() to bin2hex().

4. The "Return Values" section, in addition to the existing warning, should note that FALSE is returned if an error occurred.

5. For Example #1, there should be a space between the ")" and "example", and whitespace appears to be used inconsistently in the code.


Add a Patch

Pull Requests

Add a Pull Request

PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Mon Apr 06 13:01:25 2020 UTC