[RFC] Remove hex support in numeric strings

php.internals

Nikita Popov

11 years ago
Hi internals! I'd like to propose removing support for hexadecimal strings in the is_numeric_string() function, in order to achieve consistency with ordinary integer and float casts: https://wiki.php.net/rfc/remove_hex_support_in_numeric_strings This change drops a WTF in our conversion semantics and should have low BC impact. Thanks, Nikita

Sara Golemon

11 years ago
On Sat, Jan 3, 2015 at 11:55 AM, Nikita Popov <nikita.ppv@gmail.com> wrote:
> I'd like to propose removing support for hexadecimal strings in the > is_numeric_string() function, in order to achieve consistency with ordinary > integer and float casts: > > https://wiki.php.net/rfc/remove_hex_support_in_numeric_strings > > This change drops a WTF in our conversion semantics and should have low BC > impact. >
+1, this was always a weird inconsistency and as you note, there's a robust solution for explicitly saying that you want hex numbers to be parsed. Would vote yes again. -Sara

Stas Malyshev

11 years ago
Hi!
> I'd like to propose removing support for hexadecimal strings in the > is_numeric_string() function, in order to achieve consistency with ordinary > integer and float casts: > > https://wiki.php.net/rfc/remove_hex_support_in_numeric_strings > > This change drops a WTF in our conversion semantics and should have low BC > impact.
While I'm usually all for preserving BC in this case I think removing the inconsistency is better and the use case is weird enough that it makes little sense to implicitly support it. Given that we have options with both filter and hexdec _and_ casts do not support it, I think this RFC would do the right thing.
-- Stas Malyshev smalyshev@gmail.com

Pierre Joye

11 years ago
On Jan 4, 2015 2:56 AM, "Nikita Popov" <nikita.ppv@gmail.com> wrote:
> > Hi internals! > > I'd like to propose removing support for hexadecimal strings in the > is_numeric_string() function, in order to achieve consistency with
ordinary
> integer and float casts: > > https://wiki.php.net/rfc/remove_hex_support_in_numeric_strings > > This change drops a WTF in our conversion semantics and should have low BC
I fully agree with you here.

Mike Willbanks

11 years ago
On Sat, Jan 3, 2015 at 1:55 PM, Nikita Popov <nikita.ppv@gmail.com> wrote:
> Hi internals! > > I'd like to propose removing support for hexadecimal strings in the > is_numeric_string() function, in order to achieve consistency with ordinary > integer and float casts: > > https://wiki.php.net/rfc/remove_hex_support_in_numeric_strings > > This change drops a WTF in our conversion semantics and should have low BC > impact. > >
HUGE +1 here. We commonly run into this WTF and becomes a cause for all sorts of logic errors :)