3v4l.org

run code in 300+ PHP versions simultaneously
<?php trait P1 { public $x; } trait P2 { use P1; public $y; } trait P3 { use P2; public $z; } class A { use P1; } class B { use P2; } class C { use P2; use P3; } $c = new C; $c->x = 42; $c->y = 37; $c->z = 23; var_dump($c);
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, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.7
object(C)#1 (3) { ["y"]=> int(37) ["x"]=> int(42) ["z"]=> int(23) }
Output for 5.4.11 - 5.4.45, 5.5.24 - 5.5.35, 5.6.7 - 5.6.28
Strict Standards: P2 and P3 define the same property ($y) in the composition of C. This might be incompatible, to improve maintainability consider using accessor methods in traits instead. Class was composed in /in/4AlZT on line 23 Strict Standards: P2 and P3 define the same property ($x) in the composition of C. This might be incompatible, to improve maintainability consider using accessor methods in traits instead. Class was composed in /in/4AlZT on line 23 object(C)#1 (3) { ["y"]=> int(37) ["x"]=> int(42) ["z"]=> int(23) }
Output for 5.4.2 - 5.4.10
Strict Standards: P2 and P3 define the same property ($y) in the composition of C. This might be incompatible, to improve maintainability consider using accessor methods in traits instead. Class was composed in /in/4AlZT on line 23 Strict Standards: P2 and P3 define the same property ($x) in the composition of C. This might be incompatible, to improve maintainability consider using accessor methods in traits instead. Class was composed in /in/4AlZT on line 23 object(C)#1 (3) { ["z"]=> int(23) ["y"]=> int(37) ["x"]=> int(42) }

preferences:
194.4 ms | 402 KiB | 243 Q