3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<? class ListᐸTᐳ { private $items = []; public function add(T $item) { $this->items[] = $item; } } class T extends \DateTime {} class DateTime extends T {} class ListᐸDateTimeᐳ extends ListᐸTᐳ {} $list = new ListᐸDateTimeᐳ(); $list->add(new DateTime('now'));
based on jio44
Output for 7.0.0 - 7.1.7
Fatal error: Cannot declare class DateTime, because the name is already in use in /in/Qp9jl on line 14
Process exited with code 255.
Output for hhvm-3.15.4
Fatal error: Uncaught Error: Class already declared: DateTime in /in/Qp9jl:14 Stack trace: #0 {main}
Process exited with code 255.
Output for 5.6.0 - 5.6.30
Fatal error: Cannot redeclare class DateTime in /in/Qp9jl on line 14
Process exited with code 255.