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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: colinodell@php.net
New email:
PHP Version: OS:

 

 [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-2021 The PHP Group
All rights reserved.
Last updated: Sat Jul 24 07:01:24 2021 UTC