3v4l.org

run code in 500+ PHP versions simultaneously
<?php trait Foo { function test() { var_dump( $this->whatever() ); } } class A { use Foo; public function whatever() { return 42; } } class B { use Foo; private function whatever() { return 'hello'; } } class C { use Foo; } (new A)->test(); (new B)->test(); (new C)->test();
Output for 8.2.31 - 8.2.32, 8.3.0 - 8.3.32, 8.4.1 - 8.4.23, 8.5.0 - 8.5.8
int(42) string(5) "hello" Fatal error: Uncaught Error: Call to undefined method C::whatever() in /in/QIPsL:5 Stack trace: #0 /in/QIPsL(29): C->test() #1 {main} thrown in /in/QIPsL on line 5
Process exited with code 255.

preferences:
41.66 ms | 777 KiB | 4 Q