3v4l.org

run code in 300+ PHP versions simultaneously
<?php $generator = (function (): iterable { yield 5; throw new \Exception(sprintf('%f', microtime(true))); })(); try { foreach ($generator as $val) {} } catch (\Throwable $e) { $reflection = new \ReflectionGenerator($generator); var_dump($reflection->getTrace()); }
Output for 8.4.1 - 8.4.7
Fatal error: Uncaught ReflectionException: Cannot fetch information from a closed Generator in /in/iPCem:12 Stack trace: #0 /in/iPCem(12): ReflectionGenerator->getTrace() #1 {main} thrown in /in/iPCem on line 12
Process exited with code 255.
Output for 8.2.0 - 8.2.28, 8.3.0 - 8.3.21
Fatal error: Uncaught ReflectionException: Cannot create ReflectionGenerator based on a terminated Generator in /in/iPCem:11 Stack trace: #0 /in/iPCem(11): ReflectionGenerator->__construct(Object(Generator)) #1 {main} thrown in /in/iPCem on line 11
Process exited with code 255.

preferences:
67.18 ms | 408 KiB | 5 Q