php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #70452 string IntlChar::charName() can sometimes return bool(false)
Submitted: 2015-09-07 16:02 UTC Modified: 2016-04-08 13:33 UTC
From: colinodell@php.net Assigned: ab (profile)
Status: Closed Package: intl (PECL)
PHP Version: 7.0.0RC2 OS:
Private report: No CVE-ID: None
 [2015-09-07 16:02 UTC] colinodell@php.net
Description:
------------
The IntlChar::charName() method returns bool(false) when an invalid second parameter is given.  According to the method signature, only string values should be returned.

HHVM returns null in these cases, and I think PHP should too.

Also see related issue #70451.

Test script:
---------------
See https://3v4l.org/YXeEg or run the following:

<?php
// Rely on the default value for the second parameter
var_dump(IntlChar::charName("A"));
// Provide a valid option for the second parameter
var_dump(IntlChar::charName("A", IntlChar::UNICODE_CHAR_NAME));
// Another valid option, but with no corresponding name for that given option
// This properly returns an empty string, as expected
var_dump(IntlChar::charName("A", IntlChar::UNICODE_10_CHAR_NAME));
// Provide an invalid value for the second parameter
var_dump(IntlChar::charName("A", 12345));

Expected result:
----------------
string(22) "LATIN CAPITAL LETTER A"
string(22) "LATIN CAPITAL LETTER A"
string(0) ""
NULL

Actual result:
--------------
string(22) "LATIN CAPITAL LETTER A"
string(22) "LATIN CAPITAL LETTER A"
string(0) ""
bool(false)

Patches

Pull Requests

Pull requests:

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-04-08 13:33 UTC] ab@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: ab
 [2016-04-08 13:33 UTC] ab@php.net
PR is merged into 7.0

Thanks.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Oct 11 09:01:26 2024 UTC