3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?hh abstract class P { public abstract function foo(): string; }; class C1 extends P { public function foo(): string { return "C1"; } }; class C2 extends P { public function foo(): string { return "C2"; } }; $v1 = Vector { new C1(), new C1(), }; $v2 = Vector { new C2(), new C2(), }; function bC1(Vector<C1> $vec) { bP($vec); }; function bC2(Vector<C2> $vec) { bP($vec); }; function bP(Vector<P> $vec) { print_r($vec); }; bC1($v1); bC2($v2);
based on Te3jg
Output for hhvm-3.10.0 - 3.12.0
HH\Vector Object ( [0] => C1 Object ( ) [1] => C1 Object ( ) ) HH\Vector Object ( [0] => C2 Object ( ) [1] => C2 Object ( ) )
Output for 5.4.0 - 5.4.32
<?hh abstract class P { public abstract function foo(): string; }; class C1 extends P { public function foo(): string { return "C1"; } }; class C2 extends P { public function foo(): string { return "C2"; } }; $v1 = Vector { new C1(), new C1(), }; $v2 = Vector { new C2(), new C2(), }; function bC1(Vector<C1> $vec) { bP($vec); }; function bC2(Vector<C2> $vec) { bP($vec); }; function bP(Vector<P> $vec) { print_r($vec); }; bC1($v1); bC2($v2);