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> $vec) { $vec->add(new B()); } function bar(A<C> $vec) { foo($vec); } $v = new A<C>(); bar($v);
Output for 5.3.0 - 5.4.32
<?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> $vec) { $vec->add(new B()); } function bar(A<C> $vec) { foo($vec); } $v = new A<C>(); bar($v);