php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #80148 ctype_* functions silently return false for unsupported types
Submitted: 2020-09-25 09:27 UTC Modified: 2020-09-30 12:10 UTC
From: d dot penning at stroeermediabrands dot de Assigned: cmb (profile)
Status: Closed Package: Unknown/Other Function
PHP Version: 7.2.33 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.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: d dot penning at stroeermediabrands dot de
New email:
PHP Version: OS:

 

 [2020-09-25 09:27 UTC] d dot penning at stroeermediabrands dot de
Description:
------------
According to the documentation the ctype functions only accept strings as arguments. Passing any type that is not supported only returns false and does not throw any warning or TypeError. Setting declare(strict_types = 1); also has no effect on this.

Test script:
---------------
ctype_digit(1);

Expected result:
----------------
A warning or error hinting that an unsupported type was passed to a ctype function.

Actual result:
--------------
false

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-09-25 09:40 UTC] cmb@php.net
-Status: Open +Status: Verified -Type: Bug +Type: Documentation Problem
 [2020-09-25 09:40 UTC] cmb@php.net
That's actually a documentation issue: there is special support
for int arguments:
<https://github.com/php/php-src/blob/php-7.3.22/ext/ctype/ctype.c#L150-L159>.
 [2020-09-25 10:07 UTC] nikic@php.net
@cmb: The docs do already mention this in a note:

> If an integer between -128 and 255 inclusive is provided, it is interpreted as the ASCII value of a single character (negative values have 256 added in order to allow characters in the Extended ASCII range). Any other integer is interpreted as a string containing the decimal digits of the integer.

Possibly this needs to be more prominent?
 [2020-09-30 12:10 UTC] cmb@php.net
-Assigned To: +Assigned To: cmb
 [2020-09-30 12:10 UTC] cmb@php.net
Ah, indeed, better move that note up into the param description.
 [2020-09-30 12:14 UTC] phpdocbot@php.net
Automatic comment on behalf of cmb
Revision: http://git.php.net/?p=doc/en.git;a=commit;h=866a2e7e5480190de90771aef58a43324e596132
Log: Fix #80148: ctype_* functions silently return false for unsupported types
 [2020-09-30 12:14 UTC] phpdocbot@php.net
-Status: Verified +Status: Closed
 [2020-10-01 08:00 UTC] phpdocbot@php.net
Automatic comment on behalf of mumumu
Revision: http://git.php.net/?p=doc/ja.git;a=commit;h=7ed1767ea9140378f8dbd2be1749d8289477fc42
Log: Fix #80148: ctype_* functions silently return false for unsupported types
 [2020-12-30 11:58 UTC] nikic@php.net
Automatic comment on behalf of mumumu
Revision: http://git.php.net/?p=doc/ja.git;a=commit;h=2283abdfdc780ed0caccd65ccd8b721a04500e8b
Log: Fix #80148: ctype_* functions silently return false for unsupported types
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 10:01:31 2024 UTC