I think this is a big step in the wrong direction to one of the most common auto-conversion use cases out there (HTTP input variables). See my note to Nikita...
This RFC is a huge deal, I suggest we let more people voice their opinion in before changing it in each direction :) Zeev > -----Original Message----- > From: Andrea Faulds [mailto:a...@ajf.me] > Sent: Sunday, July 13, 2014 5:21 PM > To: Nikita Popov > Cc: PHP internals > Subject: Re: [PHP-DEV] [RFC] Scalar Type Hinting With Casts (re-opening) > > > On 13 Jul 2014, at 13:09, Nikita Popov <nikita....@gmail.com> wrote: > > > I haven't yet closely reviewed the details of what is and isn't > > allowed, but one things I would strongly recommend against is > > introducing any "accept but throw a notice" cases. Either a value is allowed > or it isn't. > > "12foo" to an int/float argument should throw a recoverable fatal > > error, like everything else. (I'd change that in zpp as well, but > > that's a different discussion). > > I've changed this case in the RFC and my patch. Previously, "12foo" would just > throw an E_NOTICE, but now it is not accepted: > > Integer hints: > > function foo(int $a) { > var_dump($a); > } > foo(1); // int(1) > foo("1"); // int(1) > foo(1.0); // int(1) > foo("1a"); // E_RECOVERABLE_ERROR > foo("a"); // E_RECOVERABLE_ERROR > foo(999999999999999999999999999999999999); // > E_RECOVERABLE_ERROR (since it's not exactly representable by an int) > foo(1.5); // E_RECOVERABLE_ERROR > > Float hints: > > function foo(float $a) { > var_dump($a); > } > foo(1); // float(1) > foo("1"); // float(1) > foo(1.0); // float(1) > foo("1a"); // E_RECOVERABLE_ERROR > foo("a"); // E_RECOVERABLE_ERROR > foo(1.5); // float(1.5) > > -- > Andrea Faulds > http://ajf.me/ > > > > > > -- > PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: > http://www.php.net/unsub.php -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php