3v4l.org

run code in 300+ PHP versions simultaneously
<?php namespace One { trait foo { static $bar = []; public static function a() { echo "Hello World"; } } } namespace Two { use One\foo as OneFoo; trait foo { use OneFoo; public static function a() { self::$bar = ["foo"]; echo "Goodbye Moon"; } } } namespace Three { class qux { use \One\foo; public static function a() { \Two\foo::a(); } } class bing extends qux { use \Two\foo; public static function a() { \Two\foo::a(); var_dump(self::$bar); } } } namespace { \Three\bing::a(); }
Output for 8.1.0 - 8.1.28, 8.2.0 - 8.2.19, 8.3.0 - 8.3.7
Deprecated: Calling static trait method Two\foo::a is deprecated, it should only be called on a class using the trait in /in/fv5iY on line 39 Deprecated: Accessing static trait property Two\foo::$bar is deprecated, it should only be accessed on a class using the trait in /in/fv5iY on line 19 Goodbye Moonarray(0) { }
Output for 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.2 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30
Goodbye Moonarray(0) { }
Output for 7.2.0 - 7.2.1
Fatal error: Three\qux and Two\foo define the same property ($bar) in the composition of Three\bing. However, the definition differs and is considered incompatible. Class was composed in /in/fv5iY on line 35
Process exited with code 255.
Output for 5.6.0 - 5.6.40
Strict Standards: Three\qux and Two\foo define the same property ($bar) in the composition of Three\bing. This might be incompatible, to improve maintainability consider using accessor methods in traits instead. Class was composed in /in/fv5iY on line 42 Goodbye Moonarray(0) { }
Output for 5.4.0 - 5.4.45, 5.5.0 - 5.5.38
Fatal error: Three\qux and Two\foo define the same property ($bar) in the composition of Three\bing. However, the definition differs and is considered incompatible. Class was composed in /in/fv5iY on line 42
Process exited with code 255.

preferences:
238.6 ms | 402 KiB | 378 Q