3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php trait A { function sayHello() { print "hello"; } } class X { use A; } function useTrait(A $a) { $a->sayHello(); } useTrait(new X()); ?>
based on DVAqT
Output for 7.0.0 - 7.3.0alpha1
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.
Output for hhvm-3.15.4
Fatal error: Uncaught TypeError: Argument 1 passed to useTrait() must be an instance of A, X given in /in/0jADg:15 Stack trace: #0 /in/0jADg(17): useTrait() #1 {main}
Process exited with code 255.
Output for 5.6.0 - 5.6.30
Catchable fatal error: 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 on line 13
Process exited with code 255.