3v4l.org

run code in 300+ PHP versions simultaneously
<?php function call($o, $a, $r, $context) { $ref = new ReflectionFunction($o); return $ref->invokeArgs($a); } class A { protected $a = 5; public function __invoke() { $f = function () { return $this->a; }; return call($f, array(), array(), isset($this) ? $this : null); } } $a = new A; var_dump($a->foo());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/rHk28
function name:  (null)
number of ops:  9
compiled vars:  !0 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   NEW                                              $1      'A'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   22     3        INIT_FCALL                                               'var_dump'
          4        INIT_METHOD_CALL                                         !0, 'foo'
          5        DO_FCALL                                      0  $4      
          6        SEND_VAR                                                 $4
          7        DO_ICALL                                                 
          8      > RETURN                                                   1

Function call:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/rHk28
function name:  call
number of ops:  13
compiled vars:  !0 = $o, !1 = $a, !2 = $r, !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        NEW                                              $5      'ReflectionFunction'
          5        SEND_VAR_EX                                              !0
          6        DO_FCALL                                      0          
          7        ASSIGN                                                   !4, $5
    6     8        INIT_METHOD_CALL                                         !4, 'invokeArgs'
          9        SEND_VAR_EX                                              !1
         10        DO_FCALL                                      0  $8      
         11      > RETURN                                                   $8
    7    12*     > RETURN                                                   null

End of function call

Function %00%7Bclosure%7D%2Fin%2FrHk28%3A14%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/rHk28
function name:  {closure}
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   FETCH_THIS                                       $0      
          1        FETCH_OBJ_R                                      ~1      $0, 'a'
          2      > RETURN                                                   ~1
   16     3*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FrHk28%3A14%240

Class A:
Function __invoke:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 11
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/rHk28
function name:  __invoke
number of ops:  16
compiled vars:  !0 = $f
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FrHk28%3A14%240'
          1        ASSIGN                                                   !0, ~1
   17     2        INIT_FCALL                                               'call'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 <array>
          5        SEND_VAL                                                 <array>
          6        ISSET_ISEMPTY_THIS                               ~3      
          7      > JMPZ                                                     ~3, ->11
          8    >   FETCH_THIS                                       ~4      
          9        QM_ASSIGN                                        ~5      ~4
         10      > JMP                                                      ->12
         11    >   QM_ASSIGN                                        ~5      null
         12    >   SEND_VAL                                                 ~5
         13        DO_FCALL                                      0  $6      
         14      > RETURN                                                   $6
   18    15*     > RETURN                                                   null

End of function __invoke

End of class A.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.67 ms | 1394 KiB | 16 Q