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)); $cloner = function(){ return new Closure(); }; $obj3 = null; $obj3 = $cloner::bindTo($obj1)->__invoke(); var_dump(spl_object_hash($obj1) == spl_object_hash($obj3));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4I9W2
function name:  (null)
number of ops:  37
compiled vars:  !0 = $obj1, !1 = $obj2, !2 = $cloner, !3 = $obj3
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   INIT_STATIC_METHOD_CALL                                  'Singleton', 'getInstance'
          1        DO_FCALL                                      0  $4      
          2        ASSIGN                                                   !0, $4
   26     3        INIT_STATIC_METHOD_CALL                                  'Singleton', 'getInstance'
          4        DO_FCALL                                      0  $6      
          5        ASSIGN                                                   !1, $6
   27     6        INIT_FCALL                                               'var_dump'
          7        INIT_FCALL                                               'spl_object_hash'
          8        SEND_VAR                                                 !0
          9        DO_ICALL                                         $8      
         10        INIT_FCALL                                               'spl_object_hash'
         11        SEND_VAR                                                 !1
         12        DO_ICALL                                         $9      
         13        IS_EQUAL                                         ~10     $8, $9
         14        SEND_VAL                                                 ~10
         15        DO_ICALL                                                 
   30    16        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F4I9W2%3A30%240'
         17        ASSIGN                                                   !2, ~12
   37    18        ASSIGN                                                   !3, null
   38    19        FETCH_CLASS                                   0  $15     !2
         20        INIT_STATIC_METHOD_CALL                                  $15, 'bindTo'
         21        SEND_VAR_EX                                              !0
         22        DO_FCALL                                      0  $16     
         23        INIT_METHOD_CALL                                         $16, '__invoke'
         24        DO_FCALL                                      0  $17     
         25        ASSIGN                                                   !3, $17
   40    26        INIT_FCALL                                               'var_dump'
         27        INIT_FCALL                                               'spl_object_hash'
         28        SEND_VAR                                                 !0
         29        DO_ICALL                                         $19     
         30        INIT_FCALL                                               'spl_object_hash'
         31        SEND_VAR                                                 !3
         32        DO_ICALL                                         $20     
         33        IS_EQUAL                                         ~21     $19, $20
         34        SEND_VAL                                                 ~21
         35        DO_ICALL                                                 
         36      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2F4I9W2%3A30%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4I9W2
function name:  {closure}
number of ops:  4
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   31     0  E >   NEW                                              $0      'Closure'
          1        DO_FCALL                                      0          
          2      > RETURN                                                   $0
   32     3*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2F4I9W2%3A30%240

Class Singleton:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/4I9W2
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/4I9W2
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/4I9W2
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/4I9W2
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/4I9W2
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:
145.53 ms | 1405 KiB | 17 Q