Hi all,

PHP 8.5 has deprecated the following type names:
- integer
- double
- boolean
- binary

But the gettype() function still returns integer, double and boolean
instead of int, float and bool.

This inconsistency is quite confusing for new developers (and even older
ones).

I understand that changing the return of gettype might break a lot of
existing code, so maybe it's not a good idea (yet).

But maybe we could add a parameter to gettype, for example:

gettype(mixed $value, bool $strict = false): string

If true, then it would return the "new" canonical names. And then in
the next version emit a depreciation notice if $strict is not supplied.

And then in PHP 9 maybe change the default return of gettype, but still
allow to pass $strict = false, so that upgrading the existing code base
would just be a matter of doing a regexp replace of gettype(...) to
gettype(..., false).

Adding a depreciation notice if $strict is not supplied would make
things just painful for everyone I think though.

It's a small thing but it seems like having the same canonical names
everywhere would make things more consistent.

Or the cheap solution would be to just add the $strict parameter
and update the gettype documentation to say that the types returned
by default are not the "new" scalar and passing $strict is needed in
order to match what "new" PHP is using.

Cheers everyone.

Reply via email to