Hi, On 26.09.23 12:39, Marc Bennewitz wrote:
Based on the discussion I see two groups. The one that would like to change this behavior without message (bug fix) and others that see a to big BC break never willing to touch it at all.Hi internalsI'd like to put a new RFC under discussion: https://wiki.php.net/rfc/integer-rounding Best, Marc
On the same time my current approach of finding a compromise by introducing an upcoming behavior change as deprecation message doesn't make anyone happy.
This makes me go back and collect other ideas: 1. Argument $force_float* $force_float=true in PHP 8.4 + deprecation on passing int and omitting this new argument
* $force_float=false in PHP 9.0This allows to opt-in new behavior asap, warns about upcoming behavior change on passing integers and allows a clean way to fix the deprecation.
But do we would like to keep this argument forever? If not it requires another deprecation phase forcing people again to fix deprecation messages.
Would it be more logical for `$force_float=false` to return the best possible mathematical correct value instead of trying to keep the input type if possible? Means a float input could also be cast to int if int is a better fit in this case.
2. Integer specific function * round_int This also would allow opt-in proposed behavior without BC break. But this comes with a couple of downsides: * Does not improve out-of-the-box behavior* Requires type-checks before opt-in and goes against PHP as a loosely typed language * New inconsistency on function naming `round` vs. `round_int` - or just another alias * New questionable behavior - Why does `round_int` return a float in some cases? Or should this be an error now? * No logical ceil/floor variant - using these requires type-checks to not loose integer precision
For me this is a no-go, I wouldn't vote for it and obviously wouldn't propose this in my own RFC.
3. Any other ideas for making all happy? Best, Marc
OpenPGP_0x3936ABF753BC88CE.asc
Description: OpenPGP public key
OpenPGP_signature.asc
Description: OpenPGP digital signature