PHP Normalize: Use float instead of double

I came across this in the PHP track docs:

  • Casts (float) and (real) are normalized to (double)

Was there a discussion about that anywhere? Because double is not seen by PHP as a type, it is seen as an alias for float only:

(double) and (real) are aliases of the (float) cast. These casts do not use the canonical type name and are not recommended.

Througout the PHP documentation float is used as the type for floating point numbers.

See:

@homersimpsons

  • Casts (float) and (real) are normalized to (double)

Was there a discussion about that anywhere? Because double is not seen by PHP as a type, it is seen as an alias for float only:

No there was not. I’m not entirerly sure why I did choose (double) over (float), maybe it was because PHP-Parser defaults to this or because their size is dependent of the platform and now most of the platform are 64-bits and in C float means 32-bits precision while double means 64-bits precision.

Technically speaking it is rather straightforward to change Blaming php-representer/src/NormalizeNodeVisitor.php at d55173c8a8e80e4576da70783795b7aee9d4d9fb · exercism/php-representer · GitHub but this will require a new run for the representater, else the “new cast” won’t match the “old cast”.

Also, if I’m right, the representation is not shown to any user but is just used to compare similar codes.

Maybe we can note that somewhere in case (double) is dropped from PHP / php-parser. (real) got deprecated with PHP8.0, and the php-parser Node type of floating point values is now Float_ instead of DNumber.