php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #70454 IntlChar::forDigit second parameter should be optional
Submitted: 2015-09-07 20:48 UTC Modified: 2015-09-08 00:26 UTC
From: colinodell@php.net Assigned: cmb (profile)
Status: Closed Package: intl (PECL)
PHP Version: 7.0.0RC2 OS:
Private report: No CVE-ID: None
 [2015-09-07 20:48 UTC] colinodell@php.net
Description:
------------
According to line 473, the second parameter of IntlChar::forDigit() should be optional and default to 10.  However, PHP is requiring that I provide a value for this second parameter.

Test script:
---------------
See https://3v4l.org/sOcGh or run this yourself:

<?php
var_dump(IntlChar::forDigit(0));
var_dump(IntlChar::forDigit(3));
var_dump(IntlChar::forDigit(3, 10));
var_dump(IntlChar::forDigit(10));
var_dump(IntlChar::forDigit(10, 16));
?>

Expected result:
----------------
int(48)
int(51)
int(51)
int(0)
int(97)

Actual result:
--------------
Warning: IntlChar::forDigit() expects exactly 2 parameters, 1 given in /in/sOcGh on line 2
NULL

Warning: IntlChar::forDigit() expects exactly 2 parameters, 1 given in /in/sOcGh on line 3
NULL
int(51)

Warning: IntlChar::forDigit() expects exactly 2 parameters, 1 given in /in/sOcGh on line 5
NULL
int(97)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-09-07 20:48 UTC] colinodell@php.net
Sorry, forgot to link the relevant source code I referenced: https://github.com/php/php-src/blob/master/ext/intl/uchar/uchar.c#L473
 [2015-09-07 21:41 UTC] cmb@php.net
-Status: Open +Status: Analyzed -Assigned To: +Assigned To: cmb
 [2015-09-07 21:41 UTC] cmb@php.net
Yes, that is apparently more a typo than a bug (instead of "ll" a
few lines below, it should be "l|l").
 [2015-09-07 21:54 UTC] cmb@php.net
-Status: Analyzed +Status: Closed
 [2015-09-07 21:54 UTC] cmb@php.net
The fix for this bug has been committed:
<http://git.php.net/?p=php-src.git;a=commit;h=1c902e2e630a6ed61983804994a4e312853008b4>.
 [2015-09-08 00:17 UTC] stas@php.net
I think this can also be merged to 5.6, it looks like an obvious bug.
 [2015-09-08 00:26 UTC] cmb@php.net
The IntlChar class has been introduced with PHP 7 only, if I'm not
mistaken.
 [2015-09-15 12:13 UTC] ab@php.net
Automatic comment on behalf of cmb
Revision: http://git.php.net/?p=php-src.git;a=commit;h=1c902e2e630a6ed61983804994a4e312853008b4
Log: Fix #70454: IntlChar::forDigit second parameter should be optional
 [2016-07-20 11:36 UTC] davey@php.net
Automatic comment on behalf of cmb
Revision: http://git.php.net/?p=php-src.git;a=commit;h=1c902e2e630a6ed61983804994a4e312853008b4
Log: Fix #70454: IntlChar::forDigit second parameter should be optional
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 09:01:32 2024 UTC