3v4l.org

run code in 300+ PHP versions simultaneously
<?php final class DbConnection { private $dsn; private $initialized = false; public function __construct($dsn) { $this->dsn = $dsn; } private function init() { $this->initialized = true; // socket stuff happens here, much like with PDO } public function query($queryString) { $this->initialized || $this->init(); // irrelevant from here on return ['query' => $queryString, 'dsn' => $this->dsn]; } } $db_conn = new DbConnection('mysql://something'); var_dump( $db_conn, $db_conn->query('SELECT * FROM foo'), $db_conn->query('SELECT * FROM bar') );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PaqqZ
function name:  (null)
number of ops:  16
compiled vars:  !0 = $db_conn
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   NEW                                              $1      'DbConnection'
          1        SEND_VAL_EX                                              'mysql%3A%2F%2Fsomething'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $1
   28     4        INIT_FCALL                                               'var_dump'
   29     5        SEND_VAR                                                 !0
   30     6        INIT_METHOD_CALL                                         !0, 'query'
          7        SEND_VAL_EX                                              'SELECT+%2A+FROM+foo'
          8        DO_FCALL                                      0  $4      
          9        SEND_VAR                                                 $4
   31    10        INIT_METHOD_CALL                                         !0, 'query'
         11        SEND_VAL_EX                                              'SELECT+%2A+FROM+bar'
         12        DO_FCALL                                      0  $5      
         13        SEND_VAR                                                 $5
         14        DO_ICALL                                                 
   32    15      > RETURN                                                   1

Class DbConnection:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PaqqZ
function name:  __construct
number of ops:  4
compiled vars:  !0 = $dsn
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
   10     1        ASSIGN_OBJ                                               'dsn'
          2        OP_DATA                                                  !0
   11     3      > RETURN                                                   null

End of function __construct

Function init:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PaqqZ
function name:  init
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   14     0  E >   ASSIGN_OBJ                                               'initialized'
          1        OP_DATA                                                  <true>
   16     2      > RETURN                                                   null

End of function init

Function query:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 3, Position 2 = 6
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
filename:       /in/PaqqZ
function name:  query
number of ops:  11
compiled vars:  !0 = $queryString
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   RECV                                             !0      
   19     1        FETCH_OBJ_R                                      ~1      'initialized'
          2      > JMPNZ_EX                                         ~1      ~1, ->6
          3    >   INIT_METHOD_CALL                                         'init'
          4        DO_FCALL                                      0  $2      
          5        BOOL                                             ~1      $2
   22     6    >   INIT_ARRAY                                       ~3      !0, 'query'
          7        FETCH_OBJ_R                                      ~4      'dsn'
          8        ADD_ARRAY_ELEMENT                                ~3      ~4, 'dsn'
          9      > RETURN                                                   ~3
   23    10*     > RETURN                                                   null

End of function query

End of class DbConnection.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
146.09 ms | 1400 KiB | 15 Q