Re: [RFC] Scalar Type Hinting With Casts (re-opening)
| From: | Andrea Faulds | Date: | Mon, 14 Jul 2014 15:49:24 +0000 |
| Subject: | Re: [RFC] Scalar Type Hinting With Casts (re-opening) | ||
| References: | 1 2 3 4 5 6 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-75479@lists.php.net to get a copy of this message | ||
On 14 Jul 2014, at 16:46, Zeev Suraski <zeev@zend.com> wrote:
> Actually there's a pretty simple way that's not strict type hints:
>
> 5) Add type hints using existing syntax, which are casts; Change casts
> (both existing and these new ones) to emit a new E_CAST in case of data
> loss or 'bogus' conversions.
How is emitting a new E_CAST useful? Most people are not going to write error handlers that will act
on it, so it’ll just be an E_WARNING so far as most people care, and we’ll just end up with
casts, which you can already do:
function foo($a) {
$a = (int)$a;
}
--
Andrea Faulds
http://ajf.me/