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 = new class() { public int $n = 0; }; $counter->n++; var_dump($counter->n); } } $o = new Cl(); $o->scalar(); $o->scalar(); $o->obj(); $o->obj(); $o = new class() extends Cl {}; $o->scalar(); $o->obj();
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/gTufh
function name:  (null)
number of ops:  20
compiled vars:  !0 = $o
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   NEW                                              $1      'Cl'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   26     3        INIT_METHOD_CALL                                         !0, 'scalar'
          4        DO_FCALL                                      0          
   27     5        INIT_METHOD_CALL                                         !0, 'scalar'
          6        DO_FCALL                                      0          
   28     7        INIT_METHOD_CALL                                         !0, 'obj'
          8        DO_FCALL                                      0          
   29     9        INIT_METHOD_CALL                                         !0, 'obj'
         10        DO_FCALL                                      0          
   31    11        DECLARE_ANON_CLASS                               <unknown> 'cl'
         12        NEW                                              $9      $8
         13        DO_FCALL                                      0          
         14        ASSIGN                                                   !0, $9
   32    15        INIT_METHOD_CALL                                         !0, 'scalar'
         16        DO_FCALL                                      0          
   33    17        INIT_METHOD_CALL                                         !0, 'obj'
         18        DO_FCALL                                      0          
         19      > 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/gTufh
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
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/gTufh
function name:  obj
number of ops:  11
compiled vars:  !0 = $counter
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   ZEND_BIND_INIT_STATIC_OR_JMP                             !0
          1        DECLARE_ANON_CLASS                               <unknown> 
          2        NEW                                              $2      $1
          3        DO_FCALL                                      0          
          4        BIND_STATIC                                              !0, $2
   19     5        PRE_INC_OBJ                                              !0, 'n'
   21     6        INIT_FCALL                                               'var_dump'
          7        FETCH_OBJ_R                                      ~5      !0, 'n'
          8        SEND_VAL                                                 ~5
          9        DO_ICALL                                                 
   22    10      > RETURN                                                   null

End of function obj

End of class Cl.

Class Cl@anonymous: [no user functions]

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
137.63 ms | 1002 KiB | 14 Q