3v4l.org

run code in 300+ PHP versions simultaneously
<?php function call($o, $args, $refe, $context) { if (is_array($o)) { $ref = new ReflectionMethod($o[0], $o[1]); } else { $ref = new ReflectionMethod($o, '__invoke'); } $ref->setAccessible(true); return $ref->invokeArgs(is_array($o) ? $o[0] : $o, $args); } class Foo_630ce62de0a20b75afc96e69c78fe466 { private function foo() { return 'foo'; } public function __invoke() { $a = array($this, 'foo'); return call($a, array(), array(), isset($this) ? $this : null); } } $a = new Foo_630ce62de0a20b75afc96e69c78fe466(); echo call($a, array(), array(), isset($this) ? $this : null);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 12
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vWDbn
function name:  (null)
number of ops:  17
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   NEW                                              $1      'Foo_630ce62de0a20b75afc96e69c78fe466'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   27     3        INIT_FCALL                                               'call'
          4        SEND_VAR                                                 !0
          5        SEND_VAL                                                 <array>
          6        SEND_VAL                                                 <array>
          7        ISSET_ISEMPTY_THIS                               ~4      
          8      > JMPZ                                                     ~4, ->12
          9    >   FETCH_THIS                                       ~5      
         10        QM_ASSIGN                                        ~6      ~5
         11      > JMP                                                      ->13
         12    >   QM_ASSIGN                                        ~6      null
         13    >   SEND_VAL                                                 ~6
         14        DO_FCALL                                      0  $7      
         15        ECHO                                                     $7
         16      > RETURN                                                   1

Function call:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 16
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
2 jumps found. (Code = 43) Position 1 = 27, Position 2 = 30
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 31
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
2 jumps found. (Code = 43) Position 1 = 27, Position 2 = 30
Branch analysis from position: 27
Branch analysis from position: 30
filename:       /in/vWDbn
function name:  call
number of ops:  36
compiled vars:  !0 = $o, !1 = $args, !2 = $refe, !3 = $context, !4 = $ref
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
          3        RECV                                             !3      
    4     4        TYPE_CHECK                                  128          !0
          5      > JMPZ                                                     ~5, ->16
    5     6    >   NEW                                              $6      'ReflectionMethod'
          7        CHECK_FUNC_ARG                                           
          8        FETCH_DIM_FUNC_ARG                               $7      !0, 0
          9        SEND_FUNC_ARG                                            $7
         10        CHECK_FUNC_ARG                                           
         11        FETCH_DIM_FUNC_ARG                               $8      !0, 1
         12        SEND_FUNC_ARG                                            $8
         13        DO_FCALL                                      0          
         14        ASSIGN                                                   !4, $6
         15      > JMP                                                      ->21
    7    16    >   NEW                                              $11     'ReflectionMethod'
         17        SEND_VAR_EX                                              !0
         18        SEND_VAL_EX                                              '__invoke'
         19        DO_FCALL                                      0          
         20        ASSIGN                                                   !4, $11
    9    21    >   INIT_METHOD_CALL                                         !4, 'setAccessible'
         22        SEND_VAL_EX                                              <true>
         23        DO_FCALL                                      0          
   11    24        INIT_METHOD_CALL                                         !4, 'invokeArgs'
         25        TYPE_CHECK                                  128          !0
         26      > JMPZ                                                     ~15, ->30
         27    >   FETCH_DIM_R                                      ~16     !0, 0
         28        QM_ASSIGN                                        ~17     ~16
         29      > JMP                                                      ->31
         30    >   QM_ASSIGN                                        ~17     !0
         31    >   SEND_VAL_EX                                              ~17
         32        SEND_VAR_EX                                              !1
         33        DO_FCALL                                      0  $18     
         34      > RETURN                                                   $18
   12    35*     > RETURN                                                   null

End of function call

Class Foo_630ce62de0a20b75afc96e69c78fe466:
Function foo:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vWDbn
function name:  foo
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E > > RETURN                                                   'foo'
   19     1*     > RETURN                                                   null

End of function foo

Function __invoke:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 13
Branch analysis from position: 10
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/vWDbn
function name:  __invoke
number of ops:  18
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   FETCH_THIS                                       ~1      
          1        INIT_ARRAY                                       ~2      ~1
          2        ADD_ARRAY_ELEMENT                                ~2      'foo'
          3        ASSIGN                                                   !0, ~2
   23     4        INIT_FCALL                                               'call'
          5        SEND_VAR                                                 !0
          6        SEND_VAL                                                 <array>
          7        SEND_VAL                                                 <array>
          8        ISSET_ISEMPTY_THIS                               ~4      
          9      > JMPZ                                                     ~4, ->13
         10    >   FETCH_THIS                                       ~5      
         11        QM_ASSIGN                                        ~6      ~5
         12      > JMP                                                      ->14
         13    >   QM_ASSIGN                                        ~6      null
         14    >   SEND_VAL                                                 ~6
         15        DO_FCALL                                      0  $7      
         16      > RETURN                                                   $7
   24    17*     > RETURN                                                   null

End of function __invoke

End of class Foo_630ce62de0a20b75afc96e69c78fe466.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
164.75 ms | 1407 KiB | 15 Q