3v4l.org

run code in 300+ PHP versions simultaneously
<?php interface MultitonInterface { public static function getInstance(string $key); } trait MultitonTrait { private static array $instance = []; public static function getInstance(string $key): self { if (!array_key_exists($key, self::$instance)) { self::$instance[$key] = new self; } return self::$instance[$key]; } } class Database implements MultitonInterface { use MultitonTrait; private function __construct(){} private function __clone(){} public function __wakeup(){} public function connect() { echo "..."; } } $db = Database::getInstance('mysql'); $db->connect();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/CfuF7
function name:  (null)
number of ops:  8
compiled vars:  !0 = $db
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   DECLARE_CLASS                                            'database'
   35     1        INIT_STATIC_METHOD_CALL                                  'Database', 'getInstance'
          2        SEND_VAL_EX                                              'mysql'
          3        DO_FCALL                                      0  $1      
          4        ASSIGN                                                   !0, $1
   36     5        INIT_METHOD_CALL                                         !0, 'connect'
          6        DO_FCALL                                      0          
          7      > RETURN                                                   1

Class MultitonInterface:
Function getinstance:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/CfuF7
function name:  getInstance
number of ops:  2
compiled vars:  !0 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
          1      > RETURN                                                   null

End of function getinstance

End of class MultitonInterface.

Class MultitonTrait:
Function getinstance:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 10
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
filename:       /in/CfuF7
function name:  getInstance
number of ops:  16
compiled vars:  !0 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   RECV                                             !0      
   13     1        FETCH_STATIC_PROP_R          unknown             ~1      'instance'
          2        ARRAY_KEY_EXISTS                                 ~2      !0, ~1
          3        BOOL_NOT                                         ~3      ~2
          4      > JMPZ                                                     ~3, ->10
   14     5    >   NEW                          self                $6      
          6        DO_FCALL                                      0          
          7        FETCH_STATIC_PROP_W          unknown             $4      'instance'
          8        ASSIGN_DIM                                               $4, !0
          9        OP_DATA                                                  $6
   17    10    >   FETCH_STATIC_PROP_R          unknown             ~8      'instance'
         11        FETCH_DIM_R                                      ~9      ~8, !0
         12        VERIFY_RETURN_TYPE                                       ~9
         13      > RETURN                                                   ~9
   18    14*       VERIFY_RETURN_TYPE                                       
         15*     > RETURN                                                   null

End of function getinstance

End of class MultitonTrait.

Class Database:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/CfuF7
function name:  __construct
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E > > RETURN                                                   null

End of function __construct

Function __clone:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/CfuF7
function name:  __clone
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E > > RETURN                                                   null

End of function __clone

Function __wakeup:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/CfuF7
function name:  __wakeup
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   27     0  E > > RETURN                                                   null

End of function __wakeup

Function connect:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/CfuF7
function name:  connect
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   31     0  E >   ECHO                                                     '...'
   32     1      > RETURN                                                   null

End of function connect

End of class Database.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
125.14 ms | 1403 KiB | 13 Q