3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { public static $data = ['a']; public static function getData() { $classes = [get_called_class()]; $classes += class_parents($classes[0]); 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/jsZqE
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%2FjsZqE%3A13%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jsZqE
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%2FjsZqE%3A13%240

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

End of function getdata

End of class D.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
171.48 ms | 1404 KiB | 21 Q