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
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
20 - 2 = ?
Subscribe to this entry?

 
 [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

Add a Patch

Pull Requests

Pull requests:

Add a Pull Request

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 Mar 29 15:01:28 2024 UTC