3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { public static $data = ['a']; public static function getData() { $classes = class_parents($class); $classes[] = get_called_class(); return call_user_func_array('array_merge', array_map( function($class) { return $class::$data; }, $classes ) ); } } class B extends A { public static $data = ['b']; } class C extends B { public static $data = ['c']; } class D extends C { public static $data = ['d']; } var_dump(A::getData()); var_dump(B::getData()); var_dump(C::getData()); var_dump(D::getData());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9gfps
function name:  (null)
number of ops:  21
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   37     0  E >   INIT_FCALL                                               'var_dump'
          1        INIT_STATIC_METHOD_CALL                                  'A', 'getData'
          2        DO_FCALL                                      0  $0      
          3        SEND_VAR                                                 $0
          4        DO_ICALL                                                 
   38     5        INIT_FCALL                                               'var_dump'
          6        INIT_STATIC_METHOD_CALL                                  'B', 'getData'
          7        DO_FCALL                                      0  $2      
          8        SEND_VAR                                                 $2
          9        DO_ICALL                                                 
   39    10        INIT_FCALL                                               'var_dump'
         11        INIT_STATIC_METHOD_CALL                                  'C', 'getData'
         12        DO_FCALL                                      0  $4      
         13        SEND_VAR                                                 $4
         14        DO_ICALL                                                 
   40    15        INIT_FCALL                                               'var_dump'
         16        INIT_STATIC_METHOD_CALL                                  'D', 'getData'
         17        DO_FCALL                                      0  $6      
         18        SEND_VAR                                                 $6
         19        DO_ICALL                                                 
         20      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2F9gfps%3A13%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9gfps
function name:  {closure}
number of ops:  5
compiled vars:  !0 = $class
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
   14     1        FETCH_CLASS                                   0  $1      !0
          2        FETCH_STATIC_PROP_R          unknown             ~2      'data'
          3      > RETURN                                                   ~2
   15     4*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2F9gfps%3A13%240

Class A:
Function getdata:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9gfps
function name:  getData
number of ops:  18
compiled vars:  !0 = $classes, !1 = $class
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   INIT_FCALL                                               'class_parents'
          1        SEND_VAR                                                 !1
          2        DO_ICALL                                         $2      
          3        ASSIGN                                                   !0, $2
   10     4        GET_CALLED_CLASS                                 ~5      
          5        ASSIGN_DIM                                               !0
          6        OP_DATA                                                  ~5
   11     7        INIT_FCALL                                               'array_merge'
   12     8        INIT_FCALL                                               'array_map'
   13     9        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F9gfps%3A13%240'
   15    10        SEND_VAL                                                 ~6
   16    11        SEND_VAR                                                 !0
         12        DO_ICALL                                         $7      
         13        SEND_ARRAY                                               $7
         14        CHECK_UNDEF_ARGS                                         
         15        DO_FCALL                                      0  $8      
         16      > RETURN                                                   $8
   19    17*     > RETURN                                                   null

End of function getdata

End of class A.

Class B:
Function getdata:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9gfps
function name:  getData
number of ops:  18
compiled vars:  !0 = $classes, !1 = $class
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   INIT_FCALL                                               'class_parents'
          1        SEND_VAR                                                 !1
          2        DO_ICALL                                         $2      
          3        ASSIGN                                                   !0, $2
   10     4        GET_CALLED_CLASS                                 ~5      
          5        ASSIGN_DIM                                               !0
          6        OP_DATA                                                  ~5
   11     7        INIT_FCALL                                               'array_merge'
   12     8        INIT_FCALL                                               'array_map'
   13     9        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F9gfps%3A13%240'
   15    10        SEND_VAL                                                 ~6
   16    11        SEND_VAR                                                 !0
         12        DO_ICALL                                         $7      
         13        SEND_ARRAY                                               $7
         14        CHECK_UNDEF_ARGS                                         
         15        DO_FCALL                                      0  $8      
         16      > RETURN                                                   $8
   19    17*     > RETURN                                                   null

End of function getdata

End of class B.

Class C:
Function getdata:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9gfps
function name:  getData
number of ops:  18
compiled vars:  !0 = $classes, !1 = $class
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   INIT_FCALL                                               'class_parents'
          1        SEND_VAR                                                 !1
          2        DO_ICALL                                         $2      
          3        ASSIGN                                                   !0, $2
   10     4        GET_CALLED_CLASS                                 ~5      
          5        ASSIGN_DIM                                               !0
          6        OP_DATA                                                  ~5
   11     7        INIT_FCALL                                               'array_merge'
   12     8        INIT_FCALL                                               'array_map'
   13     9        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F9gfps%3A13%240'
   15    10        SEND_VAL                                                 ~6
   16    11        SEND_VAR                                                 !0
         12        DO_ICALL                                         $7      
         13        SEND_ARRAY                                               $7
         14        CHECK_UNDEF_ARGS                                         
         15        DO_FCALL                                      0  $8      
         16      > RETURN                                                   $8
   19    17*     > RETURN                                                   null

End of function getdata

End of class C.

Class D:
Function getdata:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9gfps
function name:  getData
number of ops:  18
compiled vars:  !0 = $classes, !1 = $class
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   INIT_FCALL                                               'class_parents'
          1        SEND_VAR                                                 !1
          2        DO_ICALL                                         $2      
          3        ASSIGN                                                   !0, $2
   10     4        GET_CALLED_CLASS                                 ~5      
          5        ASSIGN_DIM                                               !0
          6        OP_DATA                                                  ~5
   11     7        INIT_FCALL                                               'array_merge'
   12     8        INIT_FCALL                                               'array_map'
   13     9        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F9gfps%3A13%240'
   15    10        SEND_VAL                                                 ~6
   16    11        SEND_VAR                                                 !0
         12        DO_ICALL                                         $7      
         13        SEND_ARRAY                                               $7
         14        CHECK_UNDEF_ARGS                                         
         15        DO_FCALL                                      0  $8      
         16      > RETURN                                                   $8
   19    17*     > RETURN                                                   null

End of function getdata

End of class D.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
144.27 ms | 1409 KiB | 21 Q