1--TEST-- 2iterable type#001 3--FILE-- 4<?php 5 6function test(iterable $iterable) { 7 var_dump($iterable); 8} 9 10function gen() { 11 yield 1; 12 yield 2; 13 yield 3; 14}; 15 16test([1, 2, 3]); 17test(gen()); 18test(new ArrayIterator([1, 2, 3])); 19 20try { 21 test(1); 22} catch (Throwable $e) { 23 echo $e->getMessage(); 24} 25--EXPECTF-- 26array(3) { 27 [0]=> 28 int(1) 29 [1]=> 30 int(2) 31 [2]=> 32 int(3) 33} 34object(Generator)#1 (0) { 35} 36object(ArrayIterator)#1 (1) { 37 ["storage":"ArrayIterator":private]=> 38 array(3) { 39 [0]=> 40 int(1) 41 [1]=> 42 int(2) 43 [2]=> 44 int(3) 45 } 46} 47Argument 1 passed to test() must be iterable, int given, called in %s on line %d 48