3v4l.org

run code in 300+ PHP versions simultaneously
<?php trait A { function sayHello() { print "hello"; } } class X { use A; } function useTrait(A $a) { $a->sayHello(); } useTrait(new X()); ?>
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
Fatal error: Uncaught TypeError: useTrait(): Argument #1 ($a) must be of type A, X given, called in /in/0jADg on line 17 and defined in /in/0jADg:13 Stack trace: #0 /in/0jADg(17): useTrait(Object(X)) #1 {main} thrown in /in/0jADg on line 13
Process exited with code 255.
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33
Fatal error: Uncaught TypeError: Argument 1 passed to useTrait() must be an instance of A, instance of X given, called in /in/0jADg on line 17 and defined in /in/0jADg:13 Stack trace: #0 /in/0jADg(17): useTrait(Object(X)) #1 {main} thrown in /in/0jADg on line 13
Process exited with code 255.

preferences:
183.41 ms | 402 KiB | 183 Q