Hi!

> The hole point (at least for me) for being against `function bar(int
> $num){}` to achieve type coercion is that the syntactic equivalent
> code `function bar(array $numbers){}` won't do any coercion - (array)
> $numbers - because BC break would be too big to handle.
> 
> Having `int|integer|bool|float|real|string` as coercive type hints
> while `array` is "strict" looks like an ugly hack (no pun intended).

That's how all internal functions work. It looks like you didn't
actually read my argument but just repeated "I want my use case". I know
you want strict typing. I even proposed the option for it. But if you
read "function bar(int $num)" in the PHP manual, coercive typing is
exactly what it means. That's how it has been since forever.

It has nothing to do with arrays, because - repeating it in like 10000th
time in this discussion - arrays are not scalars and PHP does not coerce
non-scalars, only scalars. You can make scalars work like non-scalars -
that would mean turning PHP into strongly typed language, like Python.
-- 
Stas Malyshev
smalys...@gmail.com

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

Reply via email to