3v4l.org

run code in 500+ PHP versions simultaneously
<?php interface I {} class A implements I {} class B implements I {} $a = new A(); function doWork(I $i) { $carry = []; // from array_reduce, not relevant [$key, $value] = match (true) { $i instanceof A => ['a', []], // default is not handled //true => ['oops', []], }; $carry[$key] = $value; return $carry; } var_dump(doWork($a));

preferences:
20.29 ms | 474 KiB | 4 Q