1--TEST-- 2Valid generator return types 3--FILE-- 4<?php 5function test1() : Generator { 6 yield 1; 7} 8 9function test2() : Iterator { 10 yield 2; 11} 12 13function test3() : Traversable { 14 yield 3; 15} 16 17function test4() : mixed { 18 yield 4; 19} 20 21function test5() : object { 22 yield 5; 23} 24 25function test6() : object|callable { 26 yield 6; 27} 28 29function test7() : iterable { 30 yield 7; 31} 32 33var_dump( 34 test1(), 35 test2(), 36 test3(), 37 test4(), 38 test5(), 39 test6(), 40 test7(), 41); 42?> 43--EXPECTF-- 44object(Generator)#%d (%d) { 45 ["function"]=> 46 string(5) "test1" 47} 48object(Generator)#%d (%d) { 49 ["function"]=> 50 string(5) "test2" 51} 52object(Generator)#%d (%d) { 53 ["function"]=> 54 string(5) "test3" 55} 56object(Generator)#%d (%d) { 57 ["function"]=> 58 string(5) "test4" 59} 60object(Generator)#%d (%d) { 61 ["function"]=> 62 string(5) "test5" 63} 64object(Generator)#%d (%d) { 65 ["function"]=> 66 string(5) "test6" 67} 68object(Generator)#%d (%d) { 69 ["function"]=> 70 string(5) "test7" 71} 72