3v4l.org

run code in 300+ PHP versions simultaneously
<?php trait T { static $arr = []; public static function a() { self::$arr[] = 'Tx'; static::$arr[] = 'Ty'; } } 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'; } } T::a(); // make no sense 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']);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ThcGX
function name:  (null)
number of ops:  43
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   DECLARE_CLASS                                            'c'
   25     1        DECLARE_CLASS                                            'd'
   36     2        INIT_STATIC_METHOD_CALL                                  'T', 'a'
          3        DO_FCALL                                      0          
   38     4        INIT_STATIC_METHOD_CALL                                  'C', 'a'
          5        DO_FCALL                                      0          
   39     6        INIT_STATIC_METHOD_CALL                                  'C', 'b'
          7        DO_FCALL                                      0          
   41     8        INIT_STATIC_METHOD_CALL                                  'D', 'a'
          9        DO_FCALL                                      0          
   42    10        INIT_STATIC_METHOD_CALL                                  'D', 'b'
         11        DO_FCALL                                      0          
   44    12        ASSERT_CHECK                                             
         13        INIT_FCALL                                               'assert'
         14        FETCH_STATIC_PROP_R          unknown             ~5      'arr'
         15        IS_IDENTICAL                                     ~6      ~5, <array>
         16        SEND_VAL                                                 ~6
         17        SEND_VAL                                                 'assert%28C%3A%3A%24arr+%3D%3D%3D+%5B%27Tx%27%2C+%27Ty%27%2C+%27Cx%27%2C+%27Cy%27%5D%29'
         18        DO_ICALL                                                 
   45    19        ASSERT_CHECK                                             
         20        INIT_FCALL                                               'assert'
         21        FETCH_STATIC_PROP_R          unknown             ~8      'arr'
         22        IS_IDENTICAL                                     ~9      ~8, <array>
         23        SEND_VAL                                                 ~9
         24        SEND_VAL                                                 'assert%28D%3A%3A%24arr+%3D%3D%3D+%5B%27Tx%27%2C+%27Ty%27%2C+%27Dx%27%2C+%27Dy%27%5D%29'
         25        DO_ICALL                                                 
   47    26        INIT_STATIC_METHOD_CALL                                  'T', 'a'
         27        DO_FCALL                                      0          
   48    28        ASSERT_CHECK                                             
         29        INIT_FCALL                                               'assert'
         30        FETCH_STATIC_PROP_R          unknown             ~12     'arr'
         31        IS_IDENTICAL                                     ~13     ~12, <array>
         32        SEND_VAL                                                 ~13
         33        SEND_VAL                                                 'assert%28C%3A%3A%24arr+%3D%3D%3D+%5B%27Tx%27%2C+%27Ty%27%2C+%27Cx%27%2C+%27Cy%27%5D%29'
         34        DO_ICALL                                                 
   49    35        ASSERT_CHECK                                             
         36        INIT_FCALL                                               'assert'
         37        FETCH_STATIC_PROP_R          unknown             ~15     'arr'
         38        IS_IDENTICAL                                     ~16     ~15, <array>
         39        SEND_VAL                                                 ~16
         40        SEND_VAL                                                 'assert%28D%3A%3A%24arr+%3D%3D%3D+%5B%27Tx%27%2C+%27Ty%27%2C+%27Dx%27%2C+%27Dy%27%5D%29'
         41        DO_ICALL                                                 
         42      > RETURN                                                   1

Class T:
Function a:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ThcGX
function name:  a
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   FETCH_STATIC_PROP_W          global              $0      'arr'
          1        ASSIGN_DIM                                               $0
          2        OP_DATA                                                  'Tx'
    9     3        FETCH_STATIC_PROP_W          unknown             $2      'arr'
          4        ASSIGN_DIM                                               $2
          5        OP_DATA                                                  'Ty'
   10     6      > RETURN                                                   null

End of function a

End of class T.

Class C:
Function b:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ThcGX
function name:  b
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   FETCH_STATIC_PROP_W          global              $0      'arr'
          1        ASSIGN_DIM                                               $0
          2        OP_DATA                                                  'Cx'
   20     3        FETCH_STATIC_PROP_W          unknown             $2      'arr'
          4        ASSIGN_DIM                                               $2
          5        OP_DATA                                                  'Cy'
   21     6      > RETURN                                                   null

End of function b

End of class C.

Class D:
Function b:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ThcGX
function name:  b
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   31     0  E >   FETCH_STATIC_PROP_W          global              $0      'arr'
          1        ASSIGN_DIM                                               $0
          2        OP_DATA                                                  'Dx'
   32     3        FETCH_STATIC_PROP_W          unknown             $2      'arr'
          4        ASSIGN_DIM                                               $2
          5        OP_DATA                                                  'Dy'
   33     6      > RETURN                                                   null

End of function b

End of class D.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.9 ms | 1400 KiB | 15 Q