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 = static function() { return new self(); }; $bcl = Closure::bind($cl, null, 'Singleton'); var_dump(Singleton::getInstance()); var_dump(Singleton::getInstance()); var_dump(Singleton::getInstance()); var_dump($bcl()); var_dump($bcl());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8kF4B
function name:  (null)
number of ops:  34
compiled vars:  !0 = $cl, !1 = $bcl
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2F8kF4B%3A19%240'
          1        ASSIGN                                                   !0, ~2
   23     2        INIT_STATIC_METHOD_CALL                                  'Closure', 'bind'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 null
          5        SEND_VAL                                                 'Singleton'
          6        DO_FCALL                                      0  $4      
          7        ASSIGN                                                   !1, $4
   25     8        INIT_FCALL                                               'var_dump'
          9        INIT_STATIC_METHOD_CALL                                  'Singleton', 'getInstance'
         10        DO_FCALL                                      0  $6      
         11        SEND_VAR                                                 $6
         12        DO_ICALL                                                 
   26    13        INIT_FCALL                                               'var_dump'
         14        INIT_STATIC_METHOD_CALL                                  'Singleton', 'getInstance'
         15        DO_FCALL                                      0  $8      
         16        SEND_VAR                                                 $8
         17        DO_ICALL                                                 
   27    18        INIT_FCALL                                               'var_dump'
         19        INIT_STATIC_METHOD_CALL                                  'Singleton', 'getInstance'
         20        DO_FCALL                                      0  $10     
         21        SEND_VAR                                                 $10
         22        DO_ICALL                                                 
   29    23        INIT_FCALL                                               'var_dump'
         24        INIT_DYNAMIC_CALL                                        !1
         25        DO_FCALL                                      0  $12     
         26        SEND_VAR                                                 $12
         27        DO_ICALL                                                 
   30    28        INIT_FCALL                                               'var_dump'
         29        INIT_DYNAMIC_CALL                                        !1
         30        DO_FCALL                                      0  $14     
         31        SEND_VAR                                                 $14
         32        DO_ICALL                                                 
         33      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2F8kF4B%3A19%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8kF4B
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%2F8kF4B%3A19%240

Class Singleton:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/8kF4B
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/8kF4B
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:
152.73 ms | 1400 KiB | 15 Q