3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Cl { public function scalar(): void { static $counter = 0; $counter++; var_dump($counter); } public function obj(): void { static $counter; if ($counter === null) { $counter = new class() { public int $n = 0; }; } $counter->n++; var_dump($counter->n); } } $o = new Cl(); $o->scalar(); $o->scalar(); $o->obj(); $o->obj();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/G1EiN
function name:  (null)
number of ops:  12
compiled vars:  !0 = $o
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   28     0  E >   NEW                                              $1      'Cl'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   29     3        INIT_METHOD_CALL                                         !0, 'scalar'
          4        DO_FCALL                                      0          
   30     5        INIT_METHOD_CALL                                         !0, 'scalar'
          6        DO_FCALL                                      0          
   31     7        INIT_METHOD_CALL                                         !0, 'obj'
          8        DO_FCALL                                      0          
   32     9        INIT_METHOD_CALL                                         !0, 'obj'
         10        DO_FCALL                                      0          
         11      > RETURN                                                   1

Class class@anonymous: [no user functions]
Class Cl:
Function scalar:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/G1EiN
function name:  scalar
number of ops:  6
compiled vars:  !0 = $counter
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   BIND_STATIC                                              !0
    8     1        PRE_INC                                                  !0
   10     2        INIT_FCALL                                               'var_dump'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                                 
   11     5      > RETURN                                                   null

End of function scalar

Function obj:
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/G1EiN
function name:  obj
number of ops:  13
compiled vars:  !0 = $counter
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   BIND_STATIC                                              !0
   16     1        TYPE_CHECK                                    2          !0
          2      > JMPZ                                                     ~1, ->7
   17     3    >   DECLARE_ANON_CLASS                               <unknown> 
          4        NEW                                              $3      $2
          5        DO_FCALL                                      0          
          6        ASSIGN                                                   !0, $3
   22     7    >   PRE_INC_OBJ                                              !0, 'n'
   24     8        INIT_FCALL                                               'var_dump'
          9        FETCH_OBJ_R                                      ~7      !0, 'n'
         10        SEND_VAL                                                 ~7
         11        DO_ICALL                                                 
   25    12      > RETURN                                                   null

End of function obj

End of class Cl.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
229.28 ms | 1011 KiB | 14 Q