3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?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(); }
based on DnbCv
Output for 7.2.0
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 7.0.0 - 7.1.10
Goodbye Moonarray(0) { }
Output for hhvm-3.11.1, hhvm-3.13.2, hhvm-3.17.3
Fatal error: Uncaught Error: trait declaration of property 'bar' is incompatible with previous declaration in /in/fv5iY:35 Stack trace: #0 {main}
Process exited with code 255.
Output for hhvm-3.12.14, hhvm-3.15.4

Process exited with code 137.
Output for hhvm-3.10.1
Fatal error: trait declaration of property 'bar' is incompatible with previous declaration in /in/fv5iY on line 35
Process exited with code 255.
Output for 5.6.0 - 5.6.30
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.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.