I really like the strictness of this casting rules except of "010" will
be a valid integer / float.
As of you don't allow "0x" and trailing white spaces as valid numbers
and don't allow floating like syntax as integers even if it result in
mathematical integer.

Allowing prefixed "0" as valid numbers results in a small data loss
("010" !== to_string(to_int("010"))),
is simple to address in user land with ltrim("010", "0") (Same argument
as trailing whitespace)
and collides with octal notation (010 !== to_int("010"))

Marc

On 21.10.2014 00:57, Andrea Faulds wrote:
> Good evening,
>
> I am presenting a new RFC to add a set of three functions to do validated 
> casts for scalar types:
>
> https://wiki.php.net/rfc/safe_cast
>
> Please read it.
>
> Thanks!
> --
> Andrea Faulds
> http://ajf.me/
>
>
>
>
>


-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to