3v4l.org

run code in 300+ PHP versions simultaneously
<?php trait FooTrait { } class Foo { use FooTrait; } function bar(FooTrait $foo): void { } bar(new Foo());
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.31, 8.2.0 - 8.2.26, 8.3.0 - 8.3.14, 8.4.1 - 8.4.2
Fatal error: Uncaught TypeError: bar(): Argument #1 ($foo) must be of type FooTrait, Foo given, called in /in/Ifr2J on line 20 and defined in /in/Ifr2J:15 Stack trace: #0 /in/Ifr2J(20): bar(Object(Foo)) #1 {main} thrown in /in/Ifr2J on line 15
Process exited with code 255.
Output for 7.2.0 - 7.2.34, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
Fatal error: Uncaught TypeError: Argument 1 passed to bar() must be an instance of FooTrait, instance of Foo given, called in /in/Ifr2J on line 20 and defined in /in/Ifr2J:15 Stack trace: #0 /in/Ifr2J(20): bar(Object(Foo)) #1 {main} thrown in /in/Ifr2J on line 15
Process exited with code 255.

preferences:
62.63 ms | 408 KiB | 5 Q