3v4l.org

run code in 300+ PHP versions simultaneously
<?php class B { public function method() { echo "BBB"; } } class A { public function method() { echo "I'not suppose to"; } } class TestParentClass extends A { public function method() { print_r('Parent method'); print "\n"; } } trait TestTrait { public function method() { print_r('Trait method'); print "\n"; } } class TestChildClass extends TestParentClass { use TestTrait { A::method as mth; /* TestTrait::method as methodAlias; TestParentClass::method insteadof TestTrait; */ } } (new TestChildClass)->mth(); (new TestChildClass)->method(); (new TestChildClass)->method(); (new TestChildClass)->methodAlias();

preferences:
33.86 ms | 402 KiB | 5 Q