Hi everyone,
There is one unresolved issue with the current patch that the RFC
doesn't address, so I'll ask about it here.
As part of supporting exponent notation in all remaining integer
operations (casts, operators), I would like to have intval() support it,
to match the `(int)` cast.
For strings, intval() doesn't use the normal zval-to-long conversion
functions (zval_get_long/convert_to_long), but instead uses strtol
directly. This is so it can support multiple bases, e.g. intval("10",
12) results in 12.
In order for intval() to support exponent notation, I'd have to change
it to now call zval_get_long, but that function doesn't support
non-decimal bases, nor does is_numeric_string_ex, which underlies it.
So, we'd either have to make intval() only support exponent notation for
base 10, an unfortunate inconsistency, or we could not touch intval(),
but then intval($a, 10) would no longer act the same as (int)$a.
I'm leaning towards the first choice, but I'd like to hear what the
mailing list thinks. Either way we have a new inconsistency. But then,
intval() has unfortunate behaviour with its base parameter anyway, in
that ignores the base for non-string input. That means that intval(123,
8) and intval("123", 8) aren't equivalent, a violation of weak typing.
Anyway, please tell me your thoughts.
Thanks.
--
Andrea Faulds
https://ajf.me/
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php