3v4l.org

run code in 300+ PHP versions simultaneously
<?php trait T { static $arr = []; public static function a() { self::$arr[] = 'Tx'; static::$arr[] = 'Ty'; } } T::a(); // make no sense if (TRUE) { class C { use T; public static function b() { self::$arr[] = 'Cx'; static::$arr[] = 'Cy'; } } class D { use T; public static function b() { self::$arr[] = 'Dx'; static::$arr[] = 'Dy'; } } } C::a(); C::b(); D::a(); D::b(); assert(C::$arr === ['Tx', 'Ty', 'Cx', 'Cy']); assert(D::$arr === ['Tx', 'Ty', 'Dx', 'Dy']); T::a(); // make no sense assert(C::$arr === ['Tx', 'Ty', 'Cx', 'Cy']); assert(D::$arr === ['Tx', 'Ty', 'Dx', 'Dy']);
Output for git.master, git.master_jit, rfc.property-hooks
Deprecated: Calling static trait method T::a is deprecated, it should only be called on a class using the trait in /in/PUXoR on line 13 Deprecated: Accessing static trait property T::$arr is deprecated, it should only be accessed on a class using the trait in /in/PUXoR on line 8 Deprecated: Accessing static trait property T::$arr is deprecated, it should only be accessed on a class using the trait in /in/PUXoR on line 9 Deprecated: Calling static trait method T::a is deprecated, it should only be called on a class using the trait in /in/PUXoR on line 50 Deprecated: Accessing static trait property T::$arr is deprecated, it should only be accessed on a class using the trait in /in/PUXoR on line 8 Deprecated: Accessing static trait property T::$arr is deprecated, it should only be accessed on a class using the trait in /in/PUXoR on line 9

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
49.2 ms | 402 KiB | 8 Q