3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MyClass { public function __construct($id) { if (isset(self::$cache[$id])) return self::$cache[$id]; // Do expensive setup self::$cache[$id] = $this; } private static $cache = array(); } $a = new MyClass(1); $b = new MyClass(1);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/P2K1A
function name:  (null)
number of ops:  9
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   NEW                                              $2      'MyClass'
          1        SEND_VAL_EX                                              1
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $2
   18     4        NEW                                              $5      'MyClass'
          5        SEND_VAL_EX                                              1
          6        DO_FCALL                                      0          
          7        ASSIGN                                                   !1, $5
          8      > RETURN                                                   1

Class MyClass:
Function __construct:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 7
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/P2K1A
function name:  __construct
number of ops:  12
compiled vars:  !0 = $id
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
    7     1        FETCH_STATIC_PROP_IS                             ~1      'cache'
          2        ISSET_ISEMPTY_DIM_OBJ                         0          ~1, !0
          3      > JMPZ                                                     ~2, ->7
    8     4    >   FETCH_STATIC_PROP_R          unknown             ~3      'cache'
          5        FETCH_DIM_R                                      ~4      ~3, !0
          6      > RETURN                                                   ~4
   12     7    >   FETCH_THIS                                       ~7      
          8        FETCH_STATIC_PROP_W          unknown             $5      'cache'
          9        ASSIGN_DIM                                               $5, !0
         10        OP_DATA                                                  ~7
   13    11      > RETURN                                                   null

End of function __construct

End of class MyClass.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.38 ms | 1385 KiB | 13 Q