3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Factory { private $instance = null; public function getInstance() { if ($this->instance === null) { $this->instance = new class() { private $var; public function get() { return $this->var; } public function set($value) { $this->var = $value; } }; } return $this->instance; } } $factory = new Factory(); $o = $factory->getInstance(); var_dump($o); $o->set(5); $o2 = $factory->getInstance(); var_dump($o2->get());
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/pP2Kc
function name:  (null)
number of ops:  21
compiled vars:  !0 = $factory, !1 = $o, !2 = $o2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   NEW                                              $3      'Factory'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $3
   25     3        INIT_METHOD_CALL                                         !0, 'getInstance'
          4        DO_FCALL                                      0  $6      
          5        ASSIGN                                                   !1, $6
   26     6        INIT_FCALL                                               'var_dump'
          7        SEND_VAR                                                 !1
          8        DO_ICALL                                                 
   27     9        INIT_METHOD_CALL                                         !1, 'set'
         10        SEND_VAL_EX                                              5
         11        DO_FCALL                                      0          
   28    12        INIT_METHOD_CALL                                         !0, 'getInstance'
         13        DO_FCALL                                      0  $10     
         14        ASSIGN                                                   !2, $10
   30    15        INIT_FCALL                                               'var_dump'
         16        INIT_METHOD_CALL                                         !2, 'get'
         17        DO_FCALL                                      0  $12     
         18        SEND_VAR                                                 $12
         19        DO_ICALL                                                 
         20      > 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/pP2Kc
function name:  get
number of ops:  3
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   FETCH_OBJ_R                                      ~0      'var'
          1      > RETURN                                                   ~0
   14     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/pP2Kc
function name:  set
number of ops:  4
compiled vars:  !0 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV                                             !0      
   16     1        ASSIGN_OBJ                                               'var'
          2        OP_DATA                                                  !0
   17     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 = 8
Branch analysis from position: 3
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
filename:       /in/pP2Kc
function name:  getInstance
number of ops:  11
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   FETCH_OBJ_R                                      ~0      'instance'
          1        TYPE_CHECK                                    2          ~0
          2      > JMPZ                                                     ~1, ->8
   10     3    >   DECLARE_ANON_CLASS                               <unknown> 
          4        NEW                                              $4      $3
          5        DO_FCALL                                      0          
          6        ASSIGN_OBJ                                               'instance'
          7        OP_DATA                                                  $4
   20     8    >   FETCH_OBJ_R                                      ~6      'instance'
          9      > RETURN                                                   ~6
   21    10*     > RETURN                                                   null

End of function getinstance

End of class Factory.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
173.33 ms | 1400 KiB | 15 Q