Re: [RFC] Scalar Type Hinting With Casts (re-opening)
| From: | Andrea Faulds | Date: | Mon, 14 Jul 2014 14:57:32 +0000 |
| Subject: | Re: [RFC] Scalar Type Hinting With Casts (re-opening) | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-75468@lists.php.net to get a copy of this message | ||
On 14 Jul 2014, at 15:54, Derick Rethans <derick@php.net> wrote:
> A compromise by adding more inconsistencies.
>
> I can buy the cast of scalars vs hint--of-complex types, but definitely
> not the introduction of a new group of casting rules. Keep it simple.
It doesn’t change the casting rules; write an error handler that ignores E_RECOVERABLE_ERROR and
you get exactly the same result as a manual cast inside the function. Rather, it simply adds
validation. The casting works like casting does everywhere else, but there’s strict lossless
validation on the type hint, similar to the non-scalar type hints except more lenient as it allows
equivalent values of other types.
--
Andrea Faulds
http://ajf.me/