3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Singleton { private static $instance; private function __construct() { } public static function getInstance() { if (null === self::$instance) { self::$instance = new self(); } return self::$instance; } } $cl = function() { return new self(); }; var_dump(Singleton::getInstance()); var_dump(Singleton::getInstance()); var_dump(Singleton::getInstance());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VfDMP
function name:  (null)
number of ops:  18
compiled vars:  !0 = $cl
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FVfDMP%3A19%240'
          1        ASSIGN                                                   !0, ~1
   23     2        INIT_FCALL                                               'var_dump'
          3        INIT_STATIC_METHOD_CALL                                  'Singleton', 'getInstance'
          4        DO_FCALL                                      0  $3      
          5        SEND_VAR                                                 $3
          6        DO_ICALL                                                 
   24     7        INIT_FCALL                                               'var_dump'
          8        INIT_STATIC_METHOD_CALL                                  'Singleton', 'getInstance'
          9        DO_FCALL                                      0  $5      
         10        SEND_VAR                                                 $5
         11        DO_ICALL                                                 
   25    12        INIT_FCALL                                               'var_dump'
         13        INIT_STATIC_METHOD_CALL                                  'Singleton', 'getInstance'
         14        DO_FCALL                                      0  $7      
         15        SEND_VAR                                                 $7
         16        DO_ICALL                                                 
         17      > RETURN                                                   1

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

End of function %00%7Bclosure%7D%2Fin%2FVfDMP%3A19%240

Class Singleton:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/VfDMP
function name:  __construct
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     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/VfDMP
function name:  getInstance
number of ops:  10
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   FETCH_STATIC_PROP_R          unknown             ~0      'instance'
          1        TYPE_CHECK                                    2          ~0
          2      > JMPZ                                                     ~1, ->7
   12     3    >   NEW                          self                $3      
          4        DO_FCALL                                      0          
          5        ASSIGN_STATIC_PROP                                       'instance'
          6        OP_DATA                                                  $3
   14     7    >   FETCH_STATIC_PROP_R          unknown             ~5      'instance'
          8      > RETURN                                                   ~5
   15     9*     > RETURN                                                   null

End of function getinstance

End of class Singleton.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
153.12 ms | 1400 KiB | 15 Q