3v4l.org

run code in 300+ PHP versions simultaneously
<?php function userland_call_user_func($function, ...$args) { $class = isset(debug_backtrace()[1]['class']) ? debug_backtrace()[1]['class'] : null; return Closure::bind(function () use ($args, $function) { return $function(...$args); }, null, $class)->__invoke(); } class Test1 { private function foo() { echo new Exception; } public function callFoo($callfunc) { $new=new Test2; $callfunc(array($new, 'foo')); } } class Test2 { private function foo() { echo new Exception; } } $o = new Test1; $o->callFoo('userland_call_user_func'); $o->callFoo('call_user_func');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6IKKl
function name:  (null)
number of ops:  10
compiled vars:  !0 = $o
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   NEW                                              $1      'Test1'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   21     3        INIT_METHOD_CALL                                         !0, 'callFoo'
          4        SEND_VAL_EX                                              'userland_call_user_func'
          5        DO_FCALL                                      0          
   22     6        INIT_METHOD_CALL                                         !0, 'callFoo'
          7        SEND_VAL_EX                                              'call_user_func'
          8        DO_FCALL                                      0          
          9      > RETURN                                                   1

Function userland_call_user_func:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 13
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6IKKl
function name:  userland_call_user_func
number of ops:  27
compiled vars:  !0 = $function, !1 = $args, !2 = $class
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV_VARIADIC                                    !1      
    4     2        INIT_FCALL                                               'debug_backtrace'
          3        DO_ICALL                                         $3      
          4        FETCH_DIM_IS                                     ~4      $3, 1
          5        ISSET_ISEMPTY_DIM_OBJ                         0          ~4, 'class'
          6      > JMPZ                                                     ~5, ->13
          7    >   INIT_FCALL                                               'debug_backtrace'
          8        DO_ICALL                                         $6      
          9        FETCH_DIM_R                                      ~7      $6, 1
         10        FETCH_DIM_R                                      ~8      ~7, 'class'
         11        QM_ASSIGN                                        ~9      ~8
         12      > JMP                                                      ->14
         13    >   QM_ASSIGN                                        ~9      null
         14    >   ASSIGN                                                   !2, ~9
    6    15        INIT_STATIC_METHOD_CALL                                  'Closure', 'bind'
         16        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F6IKKl%3A6%240'
         17        BIND_LEXICAL                                             ~11, !1
         18        BIND_LEXICAL                                             ~11, !0
    8    19        SEND_VAL                                                 ~11
         20        SEND_VAL                                                 null
         21        SEND_VAR                                                 !2
         22        DO_FCALL                                      0  $12     
         23        INIT_METHOD_CALL                                         $12, '__invoke'
         24        DO_FCALL                                      0  $13     
         25      > RETURN                                                   $13
    9    26*     > RETURN                                                   null

End of function userland_call_user_func

Function %00%7Bclosure%7D%2Fin%2F6IKKl%3A6%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6IKKl
function name:  {closure}
number of ops:  8
compiled vars:  !0 = $args, !1 = $function
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   BIND_STATIC                                              !0
          1        BIND_STATIC                                              !1
    7     2        INIT_DYNAMIC_CALL                                        !1
          3        SEND_UNPACK                                              !0
          4        CHECK_UNDEF_ARGS                                         
          5        DO_FCALL                                      1  $2      
          6      > RETURN                                                   $2
    8     7*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2F6IKKl%3A6%240

Class Test1:
Function foo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6IKKl
function name:  foo
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   NEW                                              $0      'Exception'
          1        DO_FCALL                                      0          
          2        ECHO                                                     $0
          3      > RETURN                                                   null

End of function foo

Function callfoo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6IKKl
function name:  callFoo
number of ops:  10
compiled vars:  !0 = $callfunc, !1 = $new
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
          1        NEW                                              $2      'Test2'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $2
          4        INIT_DYNAMIC_CALL                                        !0
          5        INIT_ARRAY                                       ~5      !1
          6        ADD_ARRAY_ELEMENT                                ~5      'foo'
          7        SEND_VAL_EX                                              ~5
          8        DO_FCALL                                      0          
          9      > RETURN                                                   null

End of function callfoo

End of class Test1.

Class Test2:
Function foo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/6IKKl
function name:  foo
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   NEW                                              $0      'Exception'
          1        DO_FCALL                                      0          
          2        ECHO                                                     $0
          3      > RETURN                                                   null

End of function foo

End of class Test2.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.89 ms | 1400 KiB | 15 Q