Doc #80148 [Ver]: ctype_* functions silently return false for unsupported types

From: Date: Wed, 30 Sep 2020 12:10:20 +0000
Subject: Doc #80148 [Ver]: ctype_* functions silently return false for unsupported types
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-17926@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=80148&edit=1 ID: 80148 Updated by: cmb@php.net Reported by: d dot penning at stroeermediabrands dot de Summary: ctype_* functions silently return false for unsupported types Status: Verified Type: Documentation Problem Package: Unknown/Other Function PHP Version: 7.2.33 -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: Ah, indeed, better move that note up into the param description. Previous Comments: ------------------------------------------------------------------------ [2020-09-25 10:07:17] 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-25 09:40:36] 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 09:27:42] 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 ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=80148&edit=1

« previous php.doc.bugs (#17926) next »