> -----Original Message----- > From: Andrea Faulds [mailto:a...@ajf.me] > Sent: Monday, July 14, 2014 6:12 PM > To: Zeev Suraski > Cc: Derick Rethans; PHP internals > Subject: Re: [PHP-DEV] [RFC] Scalar Type Hinting With Casts (re-opening) > > > On 14 Jul 2014, at 16:07, Zeev Suraski <z...@zend.com> wrote: > > > It does, as it creates an error (recoverable or not), and it doesn't > > allow "13abc" to easily turn into 13 (int), even if you implement an > > error handler that ignores E_RECOVERABLE_ERROR. > > Actually, you're right. In the current patch, if you run this: > > set_error_handler(function () { return true; }); > function foo(int $a) { var_dump($a); } > foo("13abc"); > > You would get this: > > int(0) > > However, that could easily be fixed so the error case uses the normal casting > behaviour.
Perhaps (I think it's more difficult than you think but perhaps I'm missing something); Either way, it's the wrong way to do it IMHO regardless. Having this as either a notice or a special E_CAST has no meaningful drawbacks, only advantages, and will also enable us to implement these warnings in regular casts for even greater consistency (a recoverable error is out of the question for those, of course, as it's a huge BC break). Zeev -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php