3v4l.org

run code in 300+ PHP versions simultaneously
<?php class C { function store($block) { $this->my_code_capsule = $block; } function execute() { $fnc = $this->my_code_capsule; $fnc(); } } $obj = new C; $obj->store(function() use(&$X) { $X = 1; }); $X = 0; $obj->execute(); echo $X;
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZOgmi
function name:  (null)
number of ops:  13
compiled vars:  !0 = $obj, !1 = $X
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   NEW                                              $2      'C'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $2
   17     3        INIT_METHOD_CALL                                         !0, 'store'
          4        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FZOgmi%3A17%240'
          5        BIND_LEXICAL                                             ~5, !1
          6        SEND_VAL_EX                                              ~5
          7        DO_FCALL                                      0          
   18     8        ASSIGN                                                   !1, 0
   19     9        INIT_METHOD_CALL                                         !0, 'execute'
         10        DO_FCALL                                      0          
   20    11        ECHO                                                     !1
         12      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FZOgmi%3A17%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZOgmi
function name:  {closure}
number of ops:  3
compiled vars:  !0 = $X
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   BIND_STATIC                                              !0
          1        ASSIGN                                                   !0, 1
          2      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FZOgmi%3A17%240

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

End of function store

Function execute:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/ZOgmi
function name:  execute
number of ops:  5
compiled vars:  !0 = $fnc
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   FETCH_OBJ_R                                      ~1      'my_code_capsule'
          1        ASSIGN                                                   !0, ~1
   11     2        INIT_DYNAMIC_CALL                                        !0
          3        DO_FCALL                                      0          
   12     4      > RETURN                                                   null

End of function execute

End of class C.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.72 ms | 1395 KiB | 13 Q