Hi
On 6/15/26 03:22, Seifeddine Gmati wrote:
I'd like to start the discussion on a new RFC adding literal scalar
types to PHP.
- RFC: https://wiki.php.net/rfc/literal_scalar_types
- Implementation: https://github.com/php/php-src/pull/22314
I have given the RFC a quick first review pass and would suggest to
leave out support for float literals. From a conceptual perspective
floats are much closer to being continuous values than they are to
discrete values and picking individual values from a continuous range is
typically not all that useful.
Support for floats is also going to invite the usual confusion about
implicit rounding:
function tenths(
0.0|0.1|0.2|0.3|0.4|0.5|0.6|0.7|0.8|0.9 $tenth
): void { var_dump($tenth); }
where `tenths(0.1 + 0.2)` will result in a TypeError. The RFC is also
unclear what values are valid floating point literals. As an example, is
`4e3` a valid float literal? Is NAN a valid float literal?
Best regards
Tim Düsterhus