Re: [RFC] Scalar Type Hints v0.2
| From: | Andrea Faulds | Date: | Mon, 02 Feb 2015 19:12:36 +0000 |
| Subject: | Re: [RFC] Scalar Type Hints v0.2 | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-81631@lists.php.net to get a copy of this message | ||
Hi Dmitry,
> On 2 Feb 2015, at 18:22, Dmitry Stogov <dmitry@zend.com> wrote:
>
> So, one of the advantages of strict type hinting is the ability to catch potential errors.
> For example when we pass 67 to setBody(string $message).
Yes, that sort of thing is easily caught by strict type checks. They’re also able to catch things
that are sometimes okay for weak hints, sometimes not. For example, some *but not all* strings are
accepted for integer and float parameters, and some *but not all* floats are accepted for integer
parameters. Strict checks make this much simpler and not dependant on the value: either some type is
accepted, or it isn’t.
Because of that, strict types can actually be effectively analysed ahead-of-time by static
analysers, IDEs and so on, and so you can catch some types of errors while editing your code,
without even needing to run it. This is quite a powerful feature. Nikita might have more to say on
that.
Thanks.
--
Andrea Faulds
http://ajf.me/