3v4l.org

run code in 300+ PHP versions simultaneously
<?php class C { private $myCodeCapsule; public function store(&$value) { $initialValue = $value; $this->myCodeCapsule = function () use (&$value, $initialValue) { $value = $initialValue; }; } public function execute() { $this->myCodeCapsule->__invoke(); } } $obj = new C; $x=1; $obj->store($x); $x=0; $obj->execute(); var_dump($x);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GD1hU
function name:  (null)
number of ops:  14
compiled vars:  !0 = $obj, !1 = $x
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   20     0  E >   NEW                                              $2      'C'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $2
   21     3        ASSIGN                                                   !1, 1
   22     4        INIT_METHOD_CALL                                         !0, 'store'
          5        SEND_VAR_EX                                              !1
          6        DO_FCALL                                      0          
   23     7        ASSIGN                                                   !1, 0
   24     8        INIT_METHOD_CALL                                         !0, 'execute'
          9        DO_FCALL                                      0          
   25    10        INIT_FCALL                                               'var_dump'
         11        SEND_VAR                                                 !1
         12        DO_ICALL                                                 
         13      > RETURN                                                   1

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

End of function %00%7Bclosure%7D%2Fin%2FGD1hU%3A9%240

Class C:
Function store:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GD1hU
function name:  store
number of ops:  8
compiled vars:  !0 = $value, !1 = $initialValue
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
    8     1        ASSIGN                                                   !1, !0
    9     2        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FGD1hU%3A9%240'
          3        BIND_LEXICAL                                             ~4, !0
          4        BIND_LEXICAL                                             ~4, !1
          5        ASSIGN_OBJ                                               'myCodeCapsule'
   11     6        OP_DATA                                                  ~4
   12     7      > 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/GD1hU
function name:  execute
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   FETCH_OBJ_R                                      ~0      'myCodeCapsule'
          1        INIT_METHOD_CALL                                         ~0, '__invoke'
          2        DO_FCALL                                      0          
   17     3      > RETURN                                                   null

End of function execute

End of class C.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.22 ms | 1400 KiB | 15 Q