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 ListᐸDateTimeᐳ extends ListᐸTᐳ {} $list = new ListᐸDateTimeᐳ(); $list->add(new DateTime('now'));
based on jL7hr
Output for 7.0.0 - 7.2.6
Fatal error: Uncaught TypeError: Argument 1 passed to ListᐸTᐳ::add() must be an instance of T, instance of DateTime given, called in /in/jio44 on line 17 and defined in /in/jio44:7 Stack trace: #0 /in/jio44(17): ListᐸTᐳ->add(Object(DateTime)) #1 {main} thrown in /in/jio44 on line 7
Process exited with code 255.
Output for hhvm-3.15.4
Fatal error: Uncaught TypeError: Argument 1 passed to ListᐸTᐳ::add() must be an instance of T, DateTime given in /in/jio44:10 Stack trace: #0 /in/jio44(17): ListᐸTᐳ->add() #1 {main}
Process exited with code 255.
Output for 5.6.0 - 5.6.30
Catchable fatal error: Argument 1 passed to ListᐸTᐳ::add() must be an instance of T, instance of DateTime given, called in /in/jio44 on line 17 and defined in /in/jio44 on line 7
Process exited with code 255.