3v4l.org

run code in 300+ PHP versions simultaneously
<?php class C { private $myCodeCapsule; public function store($context) { $this->myCodeCapsule = $context; } public function execute() { $this->myCodeCapsule->__invoke(); } } $obj = new C; $x = null; $obj->store(function () use (&$x) { $x = 1; }); $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/IabOf
function name:  (null)
number of ops:  16
compiled vars:  !0 = $obj, !1 = $x
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   NEW                                              $2      'C'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $2
   18     3        ASSIGN                                                   !1, null
   19     4        INIT_METHOD_CALL                                         !0, 'store'
          5        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FIabOf%3A19%240'
          6        BIND_LEXICAL                                             ~6, !1
   21     7        SEND_VAL_EX                                              ~6
          8        DO_FCALL                                      0          
   22     9        ASSIGN                                                   !1, 0
   23    10        INIT_METHOD_CALL                                         !0, 'execute'
         11        DO_FCALL                                      0          
   24    12        INIT_FCALL                                               'var_dump'
         13        SEND_VAR                                                 !1
         14        DO_ICALL                                                 
         15      > RETURN                                                   1

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

End of function %00%7Bclosure%7D%2Fin%2FIabOf%3A19%240

Class C:
Function store:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/IabOf
function name:  store
number of ops:  4
compiled vars:  !0 = $context
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    7     0  E >   RECV                                             !0      
    8     1        ASSIGN_OBJ                                               'myCodeCapsule'
          2        OP_DATA                                                  !0
    9     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/IabOf
function name:  execute
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   FETCH_OBJ_R                                      ~0      'myCodeCapsule'
          1        INIT_METHOD_CALL                                         ~0, '__invoke'
          2        DO_FCALL                                      0          
   14     3      > RETURN                                                   null

End of function execute

End of class C.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
163.56 ms | 1396 KiB | 15 Q