3v4l.org

run code in 300+ PHP versions simultaneously
<?php trait Eq { abstract public function equiv(Eq $lhs, Eq $rhs): bool; } class Tuple2 { use Eq; public function __construct(public Eq $key, public Eq $value) {} public function equiv(Eq $lhs, Eq $rhs): bool { return $lhs->key->equiv($lhs->key, $rhs->key) && $lhs->value->equiv($lhs->value, $rhs->value); } } class Tuple3 { use Eq; public function __construct(public Eq $key, public Eq $value, public Eq $column) {} public function equiv(Eq $lhs, Eq $rhs): bool { return $lhs->key->equiv($lhs->key, $rhs->key) && $lhs->value->equiv($lhs->value, $rhs->value) && $lhs->column->equiv($lhs->column, $rhs->column); } } function check_equiv(Eq $lhs, Eq $rhs) { return $lhs->equiv($lhs, $rhs); } var_dump(check_equiv( new Tuple3(new Tuple2(1, 2), new Tuple2(3, 4), new Tuple2(5, 6)), new Tuple3(new Tuple2(1, 2), new Tuple2(3, 4), new Tuple2(5, 6)) ));
Output for git.master, git.master_jit, rfc.property-hooks
Fatal error: Uncaught TypeError: Tuple2::__construct(): Argument #1 ($key) must be of type Eq, int given, called in /in/Hdmot on line 35 and defined in /in/Hdmot:10 Stack trace: #0 /in/Hdmot(35): Tuple2->__construct(1, 2) #1 {main} thrown in /in/Hdmot on line 10
Process exited with code 255.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
39.9 ms | 401 KiB | 8 Q