Hi Rowan, On Thu, May 14, 2015 at 6:19 PM, Rowan Collins <rowan.coll...@gmail.com> wrote:
> Yasuo Ohgaki wrote on 14/05/2015 06:19: > >> I guess DbC will not prevent users from abusing type hints, though. >> > > They'll only "abuse" them in exactly the same way they currently "abuse" > existing checks and casts. > > e.g. $id = intval($_GET['id']); looks perfectly reasonable to most people, > but if you want to use a 64-bit ID on a 32-bit system, you will consider > that a bug. If someone uses an int typehint for the same purpose then it > is, equally, a bug. > > The result of one will probably be retrieving the wrong data, and thus > potential leak or corruption; the result of the other will probably be a > fatal error, which at least stops the broken code in its tracks. I saw such buggy casts too many times in my code auditing experience. Since strict_types=1 requires "certain type", I'm expecting more buggy casts with it. We need safe validation functions so that we can advocate users do proper validation rather than buggy casts. IMHO. There was one attempt https://wiki.php.net/rfc/safe_cast but it failed. We need new one. Regards, -- Yasuo Ohgaki yohg...@ohgaki.net