3v4l.org

run code in 300+ PHP versions simultaneously
<?php class A { private static self $singleton; private function __construct() {} public static function getInstance(): self { if(!isset(self::$singleton)) { self::$singleton = new self; } return self::$singleton; } } $a = A::getInstance(); $b = A::getInstance(); $c = A::getInstance(); var_dump($a); var_dump($b); var_dump($c);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MluojW
function name:  (null)
number of ops:  19
compiled vars:  !0 = $a, !1 = $b, !2 = $c
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   INIT_STATIC_METHOD_CALL                                  'A', 'getInstance'
          1        DO_FCALL                                      0  $3      
          2        ASSIGN                                                   !0, $3
   18     3        INIT_STATIC_METHOD_CALL                                  'A', 'getInstance'
          4        DO_FCALL                                      0  $5      
          5        ASSIGN                                                   !1, $5
   19     6        INIT_STATIC_METHOD_CALL                                  'A', 'getInstance'
          7        DO_FCALL                                      0  $7      
          8        ASSIGN                                                   !2, $7
   21     9        INIT_FCALL                                               'var_dump'
         10        SEND_VAR                                                 !0
         11        DO_ICALL                                                 
   22    12        INIT_FCALL                                               'var_dump'
         13        SEND_VAR                                                 !1
         14        DO_ICALL                                                 
   23    15        INIT_FCALL                                               'var_dump'
         16        SEND_VAR                                                 !2
         17        DO_ICALL                                                 
         18      > RETURN                                                   1

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

End of function __construct

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/MluojW
function name:  getInstance
number of ops:  12
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   ISSET_ISEMPTY_STATIC_PROP                        ~0      'singleton'
          1        BOOL_NOT                                         ~1      ~0
          2      > JMPZ                                                     ~1, ->7
   11     3    >   NEW                          self                $3      
          4        DO_FCALL                                      0          
          5        ASSIGN_STATIC_PROP                                       'singleton'
          6        OP_DATA                                                  $3
   13     7    >   FETCH_STATIC_PROP_R          unknown             ~5      'singleton'
          8        VERIFY_RETURN_TYPE                                       ~5
          9      > RETURN                                                   ~5
   14    10*       VERIFY_RETURN_TYPE                                       
         11*     > RETURN                                                   null

End of function getinstance

End of class A.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
125 ms | 1000 KiB | 14 Q