Re: [RFC] Deprecations for PHP 8.6
| From: | Tim Düsterhus | Date: | Thu, 25 Jun 2026 11:39:44 +0000 |
| Subject: | Re: [RFC] Deprecations for PHP 8.6 | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-131532@lists.php.net to get a copy of this message | ||
Hi
Am 2026-06-25 00:58, schrieb Morgan:
It's a different category of problem (and a lot more difficult than just swapping out an alias), but gettype() returns "double" and "integer" for floats and ints (and "boolean" for bools). A change would require users to write a translator wrapper around gettype that continues to output the old names and call that until they're able to replace all their uses of them: $t = gettype($v); return $t === 'integer' ? 'int' : ($t === 'double' ? 'float' : $t);There already is
get_debug_type() as a replacement that is documented to:
[differ] from gettype() in that it returns type names that are more consistent with actual usage, rather than those present for historical reasonsAnd the documentation page for
gettype() also mentions that:
For type checking, use is_* functions.meaning that
gettype() is not supposed to be used for actual type *checking* (e.g. with a switch(gettype($var))). If it's not intended for this use, then “human readable output” remains as a possible use case, which is already better solved by get_debug_type() which outputs the canonical names and also class names instead of just object.
Given the replacement already being available since PHP 8.0 (and polyfillable, see https://github.com/symfony/polyfill/blob/a9a8687879dfea232e90d38ba949f65c3ece4456/src/Php80/Php80.php#L28-L58), the correct action would be not to adjust the function any more and to deprecate it with a reference to get_debug_type().
Best regards
Tim Düsterhus