3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Foo { protected function y() { echo 'Foo called' . PHP_EOL; var_dump( func_get_args()); } } class Bar extends Foo { public function __call($name, $args) { echo 'Bar called' . PHP_EOL; /** This works, but arg[0] is the name of the method called and [1] is the args call_user_func_array( 'parent::' . $name, func_get_args() ); */ forward_static_call( ['parent', $name], func_get_args()[1] ); } } $bar = (new Bar)->y(4,2);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Q90bk
function name:  (null)
number of ops:  8
compiled vars:  !0 = $bar
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   29     0  E >   NEW                                              $1      'Bar'
          1        DO_FCALL                                      0          
          2        INIT_METHOD_CALL                                         $1, 'y'
          3        SEND_VAL_EX                                              4
          4        SEND_VAL_EX                                              2
          5        DO_FCALL                                      0  $3      
          6        ASSIGN                                                   !0, $3
          7      > RETURN                                                   1

Class Foo:
Function y:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Q90bk
function name:  y
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   ECHO                                                     'Foo+called%0A'
    5     1        INIT_FCALL                                               'var_dump'
          2        FUNC_GET_ARGS                                    ~0      
          3        SEND_VAL                                                 ~0
          4        DO_ICALL                                                 
    6     5      > RETURN                                                   null

End of function y

End of class Foo.

Class Bar:
Function __call:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Q90bk
function name:  __call
number of ops:  12
compiled vars:  !0 = $name, !1 = $args
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   12     2        ECHO                                                     'Bar+called%0A'
   21     3        INIT_FCALL                                               'forward_static_call'
   22     4        INIT_ARRAY                                       ~2      'parent'
          5        ADD_ARRAY_ELEMENT                                ~2      !0
          6        SEND_VAL                                                 ~2
   23     7        FUNC_GET_ARGS                                    ~3      
          8        FETCH_DIM_R                                      ~4      ~3, 1
          9        SEND_VAL                                                 ~4
         10        DO_ICALL                                                 
   26    11      > RETURN                                                   null

End of function __call

Function y:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Q90bk
function name:  y
number of ops:  6
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   ECHO                                                     'Foo+called%0A'
    5     1        INIT_FCALL                                               'var_dump'
          2        FUNC_GET_ARGS                                    ~0      
          3        SEND_VAL                                                 ~0
          4        DO_ICALL                                                 
    6     5      > RETURN                                                   null

End of function y

End of class Bar.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
164.83 ms | 1400 KiB | 17 Q