3v4l.org

run code in 300+ PHP versions simultaneously
<?php class fakePDO { } class DatabaseConnection { protected $connection; public function __construct() { $connection = new fakePDO(); } public function __destruct() { unset($this->connection); } } class Database { static $connections = array(); public static function open($key) { self::$connections[$key] = new DatabaseConnection(); } public static function close($key) { unset(self::$connections[$key]); gc_collect_cycles(); } } Database::open('a'); Database::open('b'); Database::close('a'); debug_zval_dump(Database::$connections);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/1vSZY
function name:  (null)
number of ops:  14
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   39     0  E >   INIT_STATIC_METHOD_CALL                                  'Database', 'open'
          1        SEND_VAL                                                 'a'
          2        DO_FCALL                                      0          
   41     3        INIT_STATIC_METHOD_CALL                                  'Database', 'open'
          4        SEND_VAL                                                 'b'
          5        DO_FCALL                                      0          
   43     6        INIT_STATIC_METHOD_CALL                                  'Database', 'close'
          7        SEND_VAL                                                 'a'
          8        DO_FCALL                                      0          
   45     9        INIT_FCALL                                               'debug_zval_dump'
         10        FETCH_STATIC_PROP_R          unknown             ~3      'connections'
         11        SEND_VAL                                                 ~3
         12        DO_ICALL                                                 
         13      > RETURN                                                   1

Class fakePDO: [no user functions]
Class DatabaseConnection:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/1vSZY
function name:  __construct
number of ops:  4
compiled vars:  !0 = $connection
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   12     0  E >   NEW                                              $1      'fakePDO'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   13     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/1vSZY
function name:  __destruct
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   16     0  E >   UNSET_OBJ                                                'connection'
   17     1      > RETURN                                                   null

End of function __destruct

End of class DatabaseConnection.

Class Database:
Function open:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/1vSZY
function name:  open
number of ops:  7
compiled vars:  !0 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   RECV                                             !0      
   26     1        NEW                                              $3      'DatabaseConnection'
          2        DO_FCALL                                      0          
          3        FETCH_STATIC_PROP_W          global              $1      'connections'
          4        ASSIGN_DIM                                               $1, !0
          5        OP_DATA                                                  $3
   28     6      > RETURN                                                   null

End of function open

Function close:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/1vSZY
function name:  close
number of ops:  6
compiled vars:  !0 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   30     0  E >   RECV                                             !0      
   32     1        FETCH_STATIC_PROP_UNSET                          $1      'connections'
          2        UNSET_DIM                                                $1, !0
   34     3        INIT_FCALL                                               'gc_collect_cycles'
          4        DO_ICALL                                                 
   35     5      > RETURN                                                   null

End of function close

End of class Database.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
143.39 ms | 1405 KiB | 17 Q