3v4l.org

run code in 300+ PHP versions simultaneously
<?php function userland_call_user_func($function, ...$args) { if (! is_array($function)) { return $function(...$args); } $object = reset($function); if (is_object($object)) { return Closure::bind(function () use ($args, $function) { return $function(...$args); }, $object, get_class($object))->__invoke(); } return $function(...$args); } class Test { private function foo() { echo new Exception; } public function callFoo($callfunc) { $new=new self; $callfunc(array($new, 'foo')); } } $o = new Test; $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/Xg7C5
function name:  (null)
number of ops:  10
compiled vars:  !0 = $o
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   NEW                                              $1      'Test'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   27     3        INIT_METHOD_CALL                                         !0, 'callFoo'
          4        SEND_VAL_EX                                              'userland_call_user_func'
          5        DO_FCALL                                      0          
   28     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 = 5, Position 2 = 10
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 28
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 28
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Xg7C5
function name:  userland_call_user_func
number of ops:  34
compiled vars:  !0 = $function, !1 = $args, !2 = $object
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV_VARIADIC                                    !1      
    4     2        TYPE_CHECK                                  128  ~3      !0
          3        BOOL_NOT                                         ~4      ~3
          4      > JMPZ                                                     ~4, ->10
    5     5    >   INIT_DYNAMIC_CALL                                        !0
          6        SEND_UNPACK                                              !1
          7        CHECK_UNDEF_ARGS                                         
          8        DO_FCALL                                      1  $5      
          9      > RETURN                                                   $5
    8    10    >   INIT_FCALL                                               'reset'
         11        SEND_REF                                                 !0
         12        DO_ICALL                                         $6      
         13        ASSIGN                                                   !2, $6
   10    14        TYPE_CHECK                                  256          !2
         15      > JMPZ                                                     ~8, ->28
   11    16    >   INIT_STATIC_METHOD_CALL                                  'Closure', 'bind'
         17        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FXg7C5%3A11%240'
         18        BIND_LEXICAL                                             ~9, !1
         19        BIND_LEXICAL                                             ~9, !0
   13    20        SEND_VAL                                                 ~9
         21        SEND_VAR                                                 !2
         22        GET_CLASS                                        ~10     !2
         23        SEND_VAL                                                 ~10
         24        DO_FCALL                                      0  $11     
         25        INIT_METHOD_CALL                                         $11, '__invoke'
         26        DO_FCALL                                      0  $12     
         27      > RETURN                                                   $12
   16    28    >   INIT_DYNAMIC_CALL                                        !0
         29        SEND_UNPACK                                              !1
         30        CHECK_UNDEF_ARGS                                         
         31        DO_FCALL                                      1  $13     
         32      > RETURN                                                   $13
   17    33*     > RETURN                                                   null

End of function userland_call_user_func

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

End of function %00%7Bclosure%7D%2Fin%2FXg7C5%3A11%240

Class Test:
Function foo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/Xg7C5
function name:  foo
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     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/Xg7C5
function name:  callFoo
number of ops:  10
compiled vars:  !0 = $callfunc, !1 = $new
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   RECV                                             !0      
          1        NEW                          self                $2      
          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 Test.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
258.99 ms | 1400 KiB | 16 Q