PHP Traversable type hint

前端 未结 4 1646
-上瘾入骨i
-上瘾入骨i 2021-01-03 23:15

I have a relatively simple function which uses a foreach

function foo($t) {
     $result;
     foreach($t as $val) {
         $result = dosometh         


        
4条回答
  •  梦谈多话
    2021-01-04 00:06

    The problem is, that arrays are no objects, so they can't implement an interface. So you can't type hint both, array and Traversable.

提交回复
热议问题