3v4l.org

run code in 300+ PHP versions simultaneously
<?php interface Foo { public function doSomething(string $param1); } class Bar implements Foo { public function doSomething(string $param1) { echo "Bar: " . $param1; } } class Baz implements Foo { // Using a named parameter different from Foo's signature public function doSomething(string $paramName) { echo "Baz: " . $paramName; } } function processFoo(Foo $foo) { $foo->doSomething(param1: "Test"); } $bar = new Bar(); $baz = new Baz(); processFoo($bar); // Works fine processFoo($baz); // Fatal error:
Output for 8.1.0 - 8.1.30, 8.2.0 - 8.2.25, 8.3.0 - 8.3.13
Bar: Test Fatal error: Uncaught Error: Unknown named parameter $param1 in /in/L1Ki3:21 Stack trace: #0 /in/L1Ki3(28): processFoo(Object(Baz)) #1 {main} thrown in /in/L1Ki3 on line 21
Process exited with code 255.

preferences:
59.82 ms | 406 KiB | 5 Q