3v4l.org

run code in 300+ PHP versions simultaneously
<?php interface Foo { public function bar(string $stuff): Generator; } class Baz { public function bar(string $stuff): Array { yield $stuff; return []; // breaks } } $baz = new Baz; $g = $baz->bar("Hello PHP!"); foreach ($g as $value) { var_dump($value); }
Output for 7.1.0 - 7.1.17, 7.2.0 - 7.2.7
Fatal error: Generators may only declare a return type of Generator, Iterator, Traversable, or iterable, array is not permitted in /in/LMYCV on line 10
Process exited with code 255.

preferences:
141.13 ms | 1194 KiB | 6 Q