3v4l.org

run code in 300+ PHP versions simultaneously
<?php class c1 { public function test() { echo 'c1<br />'; return [1]; } } trait t1 { public function rules() { return [2]; } } trait t2 { public function rules() { return [3]; } } class c2 extends c1 { use t1, t2 { t1::rules as t1Rules; t2::rules as t2Rules; } public function test() { echo 'c2<br />'; return array_merge(parent::test(), t1Rules(), t2Rules(), [4]); } } $obj = new c2(); echo '<pre>'; print_r($obj->test());
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.19, 8.3.0 - 8.3.7
Fatal error: Trait method t2::rules has not been applied as c2::rules, because of collision with t1::rules in /in/4Gu5l on line 21
Process exited with code 255.
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.20, 7.2.0 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33
Fatal error: Trait method rules has not been applied, because there are collisions with other trait methods on c2 in /in/4Gu5l on line 21
Process exited with code 255.
Output for 5.4.2 - 5.4.45, 5.5.24 - 5.5.35, 5.6.7 - 5.6.28
Fatal error: Trait method rules has not been applied, because there are collisions with other trait methods on c2 in /in/4Gu5l on line 31
Process exited with code 255.

preferences:
191.23 ms | 402 KiB | 229 Q