3v4l.org

run code in 300+ PHP versions simultaneously
<?php class test { private $f; public function __construct(&$f) { $this->f = &$f; } public function __destruct() { $this->f = function() {}; } } $f = function () use (&$f) { $t = new test($f); print "After this line it the Closure should be destroyed...\n"; }; $f(); $f(); var_dump($f);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/BXLgQ
function name:  (null)
number of ops:  11
compiled vars:  !0 = $f
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FBXLgQ%3A15%241'
          1        BIND_LEXICAL                                             ~1, !0
          2        ASSIGN                                                   !0, ~1
   20     3        INIT_DYNAMIC_CALL                                        !0
          4        DO_FCALL                                      0          
   21     5        INIT_DYNAMIC_CALL                                        !0
          6        DO_FCALL                                      0          
   22     7        INIT_FCALL                                               'var_dump'
          8        SEND_VAR                                                 !0
          9        DO_ICALL                                                 
         10      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FBXLgQ%3A11%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/BXLgQ
function name:  {closure}
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E > > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FBXLgQ%3A11%240

Function %00%7Bclosure%7D%2Fin%2FBXLgQ%3A15%241:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/BXLgQ
function name:  {closure}
number of ops:  7
compiled vars:  !0 = $f, !1 = $t
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   BIND_STATIC                                              !0
   16     1        NEW                                              $2      'test'
          2        SEND_VAR_EX                                              !0
          3        DO_FCALL                                      0          
          4        ASSIGN                                                   !1, $2
   17     5        ECHO                                                     'After+this+line+it+the+Closure+should+be+destroyed...%0A'
   18     6      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FBXLgQ%3A15%241

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

End of function __construct

Function __destruct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/BXLgQ
function name:  __destruct
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FBXLgQ%3A11%240'
          1        ASSIGN_OBJ                                               'f'
          2        OP_DATA                                                  ~1
   12     3      > RETURN                                                   null

End of function __destruct

End of class test.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
169.03 ms | 1400 KiB | 15 Q