On Sat, Mar 11, 2017 at 3:34 PM, Rowan Collins <rowan.coll...@gmail.com> wrote:
> On 11 March 2017 13:23:16 GMT+00:00, Andrey Andreev <n...@devilix.net> wrote:
>>Ironically enough, the following code executes silently:
>>
>>    $array = ['a', 'b', 'c'];
>>    sort($array, '2234234324');
>>
>>If you don't see the problem with that, I guess it does make "no sense
>>at all" from your POV. Just agree to disagree.
>
>
> I see a problem with that, but I see exactly the same problem with this:
>
> $array = ['a', 'b', 'c'];
> sort($array, 2234234324);
>
> The fact is, "int" is far too loose a type constraint to meaningfully 
> validate that parameter. The solution to that is not to be more strict in 
> rejecting strings, but to create richer types of constraint: enums, unions, 
> domains, etc.
>

I don't disagree with that in general, but strictly rejecting strings
and other non-integer values would alleviate the problem for a
majority of cases; i.e. would solve the 90% problem.

What I strongly disagree on is that I should be happy with coercion,
and the almost religious resistance against (non-overridable) strict
scalar typing.

Cheers,
Andrey.

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

Reply via email to