3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Factory { public function getInstance() { static $instance = null; if ($instance === null) { $instance = new class() { private $var; public function get() { return $this->var; } public function set($value) { $this->var = $value; } }; } return $instance; } } $f = new Factory(); $o = $f->getInstance(); $o->set(5); $o2 = $f->getInstance(); var_dump($o2->get());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3ZRvP
function name:  (null)
number of ops:  18
compiled vars:  !0 = $f, !1 = $o, !2 = $o2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   NEW                                              $3      'Factory'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $3
   23     3        INIT_METHOD_CALL                                         !0, 'getInstance'
          4        DO_FCALL                                      0  $6      
          5        ASSIGN                                                   !1, $6
   24     6        INIT_METHOD_CALL                                         !1, 'set'
          7        SEND_VAL_EX                                              5
          8        DO_FCALL                                      0          
   25     9        INIT_METHOD_CALL                                         !0, 'getInstance'
         10        DO_FCALL                                      0  $9      
         11        ASSIGN                                                   !2, $9
   27    12        INIT_FCALL                                               'var_dump'
         13        INIT_METHOD_CALL                                         !2, 'get'
         14        DO_FCALL                                      0  $11     
         15        SEND_VAR                                                 $11
         16        DO_ICALL                                                 
         17      > RETURN                                                   1

Class class@anonymous:
Function get:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3ZRvP
function name:  get
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   11     0  E >   FETCH_OBJ_R                                      ~0      'var'
          1      > RETURN                                                   ~0
   12     2*     > RETURN                                                   null

End of function get

Function set:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/3ZRvP
function name:  set
number of ops:  4
compiled vars:  !0 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
   14     1        ASSIGN_OBJ                                               'var'
          2        OP_DATA                                                  !0
   15     3      > RETURN                                                   null

End of function set

End of class class@anonymous.

Class Factory:
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/3ZRvP
function name:  getInstance
number of ops:  9
compiled vars:  !0 = $instance
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   BIND_STATIC                                              !0
    7     1        TYPE_CHECK                                    2          !0
          2      > JMPZ                                                     ~1, ->7
    8     3    >   DECLARE_ANON_CLASS                               <object> 
          4        NEW                                              $3      $2
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !0, $3
   18     7    > > RETURN                                                   !0
   19     8*     > RETURN                                                   null

End of function getinstance

End of class Factory.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
183.18 ms | 1400 KiB | 15 Q