Thouse who are asking about type hinting for function args are right. It is
logical to implement return type hinting with arg type hinting.
They should work either independantly (you can specify any on them or all
together) or if you declare return type - declare arg types too (then we
should have 'mixed' type too, some functions can return array or false on
error, ect).

Why we need type hinting?
Here is an example


array function myQuery(int $id){
    $result = mysql_query('SELECT * FROM table WHERE id = '.$id);
    // Make a array from result
    return $array;
}
$id = '192b46';
$data = myQuery($id);

If some checks are implemented about what is passed, then this will be an
error (or exception witch can be cathed). And type conversion to int isn't
good, because you will get 192 instead if 19246. It's like array and object
type hinting now implemented. And i can be sure I will get an array as a
result.
Maybe it is good idea to make type conversions on function args, then we
don't need to make "id = '.(int)$id" ourselfs.

Reply via email to