> The main flaw in type conversion hinting is that it's nearly pointless.
> Why convert the type at function call? PHP will automatically juggle the
> type depending on the variable's destination, really no point in
> converting it one more time when calling the function
Well that is not entirely true. There is a point, because inside the
function the type information is "static". Therefore intra functional
analysis of optimizers and static source code scanners is still able to
use this information.
However you loose the extra juice where calling a function with a type
hint (int) also gives you information about the type in the calling
function. You loose this information if you auto convert.
You also loose the ability to decide on byte code level if code is broken.

But yes, because everything can be casted to a number/string the
userland feature to detect wrong types passed to functions is gone...

Imagine

function doStuff(string $x)
{
    ...
}

doStuff(md5($_GET['xxx']));

When you cast you don't realise that this code is broken....
md5(array()); returns NULL; which is autocasted and doStuff() accepts it...

Stefan Esser

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

Reply via email to