Re: [RFC] Deprecations for PHP 8.5
| From: | Gina P. Banyard | Date: | Thu, 10 Jul 2025 11:18:40 +0000 |
| Subject: | Re: [RFC] Deprecations for PHP 8.5 | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-127991@lists.php.net to get a copy of this message | ||
On Wednesday, 9 July 2025 at 22:26, Claude Pache <claude.pache@gmail.com> wrote:
> Hi,
>
> A possible reason for wanting to use the non-canonical names in settype(), is that those names
> are returned by gettype(). Fictional example (not intended to be reasonable, only illustrative):
>
> ```php
> function settype_from(&$a, &b) {
> return settype($a, gettype($b));
> }
> ```
>
> Personally, I have used "integer", etc. instead of "int", etc., in
> settype() in the past, because those were the “canonical” (as I perceived) forms returned by
> gettype(). I have slowly fallen out of that habit in the years after I began to use scalar type
> declarations (introduced in PHP 7).
We are well aware of this "issue" and get_debug_type() was introduced in PHP 8 as a
replacement for gettype() that returns the canonical names.
The one difference is that objects return the class name rather than "object".
I can add a deprecation of gettype() to nudge people to use get_debug_type() instead, if you think
that's reasonable.
Best regards,
Gina P. Banyard