3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?hh class A<T> { protected T $value; public function set(T $value) { $this->value = $value; } } class B { public function doB() : string { return "b"; } } class C extends B { public function doC() : string { return "c"; } } function foo(A<B> $a) { $a->set(new B()); } function bar(A<C> $a) { foo($a); } $v = new A<C>(); bar($v);
Output for hhvm-3.10.0 - 3.12.0
Output for 5.4.0 - 5.4.28
Parse error: syntax error, unexpected 'class' (T_CLASS) in /in/p6qr9 on line 3
Process exited with code 255.
Output for 5.3.0 - 5.3.29
<?hh class A<T> { protected T $value; public function set(T $value) { $this->value = $value; } } class B { public function doB() : string { return "b"; } } class C extends B { public function doC() : string { return "c"; } } function foo(A<B> $a) { $a->set(new B()); } function bar(A<C> $a) { foo($a); } $v = new A<C>(); bar($v);