Re: [RFC] Safe Casting Functions

From: Date: Thu, 23 Oct 2014 19:40:40 +0000
Subject: Re: [RFC] Safe Casting Functions
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-78278@lists.php.net to get a copy of this message
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/ > > > > >

« previous php.internals (#78278) next »