On Thu, Apr 14, 2016 at 5:12 PM, Derick Rethans <der...@php.net> wrote:

> I think what I am missing in the RFC is behaviour with scalar (weak)
> typehints, and which type the variable in a class would be converted to.
> Take for example:
>
> function foo(int|bool $var) { echo get_type( $var ), "\n"; }
>
> foo(5);     I guess int(5)
> foo(false); I guess bool(false)
> foo(0.5);   It could be either int(1) or bool(true)
>
> And what if the hint would be "bool|int" ?
>

I think type conversion shouldn't be done internally, implicitly.

Implicit conversion leads more confusion in the language. when you pass
variables, you have to remember these conversion rules.

type conversion should be done in the caller, that's why typed language
like C or C++ ask you to convert the type manually before you pass the
variable into a function.




-- 
Best Regards,

Yo-An Lin

Reply via email to