2015-02-02 21:12 GMT+02:00 Andrea Faulds <a...@ajf.me>:
> Hi Dmitry,
>
>> On 2 Feb 2015, at 18:22, Dmitry Stogov <dmi...@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/
>
>
>
>
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>

Strict type checking, has its advantages.

We all external data convert to native PHP types.
The database we use option MYSQLI_OPT_INT_AND_FLOAT_NATIVE.
Inputs are validated and converted to native PHP types.
In Redis data are stored as serialize string.

In our API we may require strict adherence to type because the integer
as strings $id = "123" to impossible, i need catch these as logical
error.

But I also fully endorse, cast without loss of accuracy, because it
gives you more options and less of a problem for those who do not have
the conversion of external data.

Not to discuss endlessly two options, it is reasonable send to voting
the Strict type checking, voting will be fail :), then will be easier
to discuss technical issues as do korektno cast without losing data,
good luck!

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to