3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Singleton { private function __construct(){} private function __clone(){} private function __sleep(){} private function __wakeup(){} private static $instance; public static function getInstance() { if ( ! self::$instance) { self::$instance = new static(); } return self::$instance; } } $obj1 = Singleton::getInstance(); $obj2 = Singleton::getInstance(); var_dump(spl_object_hash($obj1) == spl_object_hash($obj2));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YiZol
function name:  (null)
number of ops:  17
compiled vars:  !0 = $obj1, !1 = $obj2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   INIT_STATIC_METHOD_CALL                                  'Singleton', 'getInstance'
          1        DO_FCALL                                      0  $2      
          2        ASSIGN                                                   !0, $2
   26     3        INIT_STATIC_METHOD_CALL                                  'Singleton', 'getInstance'
          4        DO_FCALL                                      0  $4      
          5        ASSIGN                                                   !1, $4
   27     6        INIT_FCALL                                               'var_dump'
          7        INIT_FCALL                                               'spl_object_hash'
          8        SEND_VAR                                                 !0
          9        DO_ICALL                                         $6      
         10        INIT_FCALL                                               'spl_object_hash'
         11        SEND_VAR                                                 !1
         12        DO_ICALL                                         $7      
         13        IS_EQUAL                                         ~8      $6, $7
         14        SEND_VAL                                                 ~8
         15        DO_ICALL                                                 
         16      > RETURN                                                   1

Class Singleton:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/YiZol
function name:  __construct
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     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/YiZol
function name:  __clone
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E > > RETURN                                                   null

End of function __clone

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

End of function __sleep

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

End of function __wakeup

Function getinstance:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 7
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
filename:       /in/YiZol
function name:  getInstance
number of ops:  10
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   FETCH_STATIC_PROP_R          unknown             ~0      'instance'
          1        BOOL_NOT                                         ~1      ~0
          2      > JMPZ                                                     ~1, ->7
   17     3    >   NEW                          static              $3      
          4        DO_FCALL                                      0          
          5        ASSIGN_STATIC_PROP                                       'instance'
          6        OP_DATA                                                  $3
   19     7    >   FETCH_STATIC_PROP_R          unknown             ~5      'instance'
          8      > RETURN                                                   ~5
   20     9*     > RETURN                                                   null

End of function getinstance

End of class Singleton.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
159.08 ms | 1400 KiB | 17 Q