On Tue, Jul 29, 2025, at 7:52 AM, Alexandre Daubois wrote:
> Hi internals,
>
> I would like to present the RFC to add the
> "is_representable_as_float()" and "is_representable_as_int()"
> functions. These functions provide developers with a way to check
> whether values can be losslessly converted between integer and
> floating-point representations.
>
> https://wiki.php.net/rfc/is-representable-as-float-int
>
> Best,
> Alexandre Daubois

This looks lovely.

Since only int, float, and string can ever be true, does it make sense to type 
the function parameters as `int|float|string` rather than `mixed`, to 
automatically exclude arrays, objects, and null?  (All of which would always be 
false.)

(I could probably argue either way on it, but my first inclination is yes; push 
the initial validation upstream.  You should always know if a variable is a 
primitive or not, at the very least.)

--Larry Garfield

Reply via email to