Re: [POC - Patch] Scalar Type Hinting - A-La zend_parse_parameters

From: Date: Mon, 12 Mar 2012 19:41:59 +0000
Subject: Re: [POC - Patch] Scalar Type Hinting - A-La zend_parse_parameters
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-58885@lists.php.net to get a copy of this message
On Fri, March 9, 2012 2:51 am, Nikita Popov wrote: > On Fri, Mar 9, 2012 at 3:58 AM, Ilia Alshanetsky <ilia@prohost.org> > wrote: >> Anthony, >> >> My concern with this type of patch is that what you are proposing >> are >> not really hints, they are forced casts. As such they modify the >> data >> potentially leading to data loss. > This patch specifically tries to overcome this problem of the previous > version. It will not accept input which will lead to a data loss on > cast. The only exception is passing "123abc" to an int hint, which > will cast to 123 and throw a notice. This is also my only point of > critique: I'd prefer to be stricter here and go all the way to a > recoverable fatal error. So what happens to (int) "1233553463645747675685685" Does it cast and then cause an overflow, which PHP pretty much ignores and wraps to a negative number? Or does it error out as you can't convert without mangling the data? Will it behave differently on 32-bit versus 64-bit hardware for values that are in-range of 64 but no 32? -- brain cancer update: http://richardlynch.blogspot.com/search/label/brain%20tumor Donate: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=FS9NLTNEEKWBE

« previous php.internals (#58885) next »