Hi all,
Following the earlier discussion of adding decrement for strings to complement the existing alphanumeric increment feature, I've written a proposal to normalize the behaviour across boolean and null values.
https://wiki.php.net/rfc/normalize_inc_dec
Based on some earlier comments, boolean and null values can be treated in two distinct way, both of which are demonstrated in the rfc; I'm hoping that before voting takes place we can eliminate one voting option altogether.
It also aims to deprecate string-based increments using ++; instead, it would introduce str_inc() and str_dec() as a regular function.
Let me know your thoughts.
--
Tjerk
Quoted text · 5 lines
Following the earlier discussion of adding decrement for strings to complement the existing alphanumeric increment feature, I've written a proposal to normalize the behaviour across boolean and null values.
https://wiki.php.net/rfc/normalize_inc_dec
Based on some earlier comments, boolean and null values can be treated in two distinct way, both of which are demonstrated in the rfc; I'm hoping that before voting takes place we can eliminate one voting option altogether.
It also aims to deprecate string-based increments using
++; instead, it would introducestr_inc()andstr_dec()as a regular function.Let me know your thoughts.
I actually already wrote a patch for removing alphanumeric increment and decrement, if you're interested:
https://github.com/TazeTSchnitzel/php-src/tree/AlphanumericIncrement
Personally, I think the sanest solution is to increment number-looking strings as if they were numbers ("0" becomes 1), increment numbers (obviously), and throw a warning and do nothing for everything else.
Though it would be best if the $a++ behaviour matches $a += 1 and $a = $a + 1. So, while I'd prefer the strict approach I just mentioned, we should actually make it function identically to the other ways of incrementing.
--
Andrea Faulds
http://ajf.me/