1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
--TEST-- Generators can't be counted --FILE-- <?php function gen() { yield; } $gen = gen(); try { count($gen); } catch (\TypeError $e) { echo $e->getMessage(), PHP_EOL; } ?> --EXPECT-- count(): Argument #1 ($var) must be of type Countable|array, Generator given