I have a relatively simple function which uses a foreach
function foo($t) {
$result;
foreach($t as $val) {
$result = dosomething($result, $val);
}
return $result;
}
I would like to type hint, and Traversable
seems to be the exact type hint I need
function foo(Traversable $t) {
However this gives a E_RECOVERABLE_ERROR
when using an array (which is of course usable in a foreach
): example
Argument 1 passed to foo() must implement interface Traversable, array given
Is there a way to type hint or is this not possible?