3v4l.org

run code in 500+ PHP versions simultaneously
<?php class c1 { private $callback; public function setFun($callback) { $this->callback = $callback; } public function fun() { ($this->callback)(); } } $n = new c1(); $n->setFun(function () { var_dump('this callback'); }); $n->fun();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4iFbZ
function name:  (null)
number of ops:  10
compiled vars:  !0 = $n
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   15     0  E >   NEW                                                  $1      'c1'
          1        DO_FCALL                                          0          
          2        ASSIGN                                                       !0, $1
   16     3        INIT_METHOD_CALL                                             !0, 'setFun'
          4        DECLARE_LAMBDA_FUNCTION                              ~4      [0]
   18     5        SEND_VAL_EX                                                  ~4
   16     6        DO_FCALL                                          0          
   20     7        INIT_METHOD_CALL                                             !0, 'fun'
          8        DO_FCALL                                          0          
          9      > RETURN                                                       1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4iFbZ
function name:  {closure:/in/4iFbZ:16}
number of ops:  4
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   17     0  E >   INIT_FCALL                                                   'var_dump'
          1        SEND_VAL                                                     'this+callback'
          2        DO_ICALL                                                     
   18     3      > RETURN                                                       null

End of Dynamic Function 0

Class c1:
Function setfun:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4iFbZ
function name:  setFun
number of ops:  4
compiled vars:  !0 = $callback
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    5     0  E >   RECV                                                 !0      
    7     1        ASSIGN_OBJ                                                   'callback'
          2        OP_DATA                                                      !0
    8     3      > RETURN                                                       null

End of function setfun

Function fun:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4iFbZ
function name:  fun
number of ops:  4
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   11     0  E >   FETCH_OBJ_R                                          ~0      'callback'
          1        INIT_DYNAMIC_CALL                                            ~0
          2        DO_FCALL                                          0          
   12     3      > RETURN                                                       null

End of function fun

End of class c1.

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
144.51 ms | 1883 KiB | 14 Q