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 Listᐸstringᐳ extends ListᐸTᐳ {} $list = new Listᐸstringᐳ(); $list->add('Foo');
based on D1Qih
Output for 7.0.0 - 7.3.0rc3
Fatal error: Uncaught TypeError: Argument 1 passed to ListᐸTᐳ::add() must be an instance of T, string given, called in /in/Gg4IZ on line 16 and defined in /in/Gg4IZ:7 Stack trace: #0 /in/Gg4IZ(16): ListᐸTᐳ->add('Foo') #1 {main} thrown in /in/Gg4IZ 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, string given in /in/Gg4IZ:10 Stack trace: #0 /in/Gg4IZ(16): 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, string given, called in /in/Gg4IZ on line 16 and defined in /in/Gg4IZ on line 7
Process exited with code 255.