3v4l.org

run code in 300+ PHP versions simultaneously
<?php $x = new class() { public $callCounters = []; public function call($index) { if (!isset($this->callCounters[$index])) { $this->callCounters[$index] = 0; } ++$this->callCounters[$index]; } }; $indexes = range('a','e'); foreach($indexes as $index) { $r = rand(1,4); for($i = 0; $i <= $r; ++$i) { $x->call($index); } } var_dump($x->callCounters);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 10, Position 2 = 25
Branch analysis from position: 10
2 jumps found. (Code = 78) Position 1 = 11, Position 2 = 25
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
2 jumps found. (Code = 44) Position 1 = 24, Position 2 = 18
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 18
2 jumps found. (Code = 44) Position 1 = 24, Position 2 = 18
Branch analysis from position: 24
Branch analysis from position: 18
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
filename:       /in/L3NqP
function name:  (null)
number of ops:  31
compiled vars:  !0 = $x, !1 = $indexes, !2 = $index, !3 = $r, !4 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   DECLARE_ANON_CLASS                               <unknown> 
          1        NEW                                              $6      $5
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $6
   13     4        INIT_FCALL                                               'range'
          5        SEND_VAL                                                 'a'
          6        SEND_VAL                                                 'e'
          7        DO_ICALL                                         $9      
          8        ASSIGN                                                   !1, $9
   15     9      > FE_RESET_R                                       $11     !1, ->25
         10    > > FE_FETCH_R                                               $11, !2, ->25
   16    11    >   INIT_FCALL                                               'rand'
         12        SEND_VAL                                                 1
         13        SEND_VAL                                                 4
         14        DO_ICALL                                         $12     
         15        ASSIGN                                                   !3, $12
   17    16        ASSIGN                                                   !4, 0
         17      > JMP                                                      ->22
   18    18    >   INIT_METHOD_CALL                                         !0, 'call'
         19        SEND_VAR_EX                                              !2
         20        DO_FCALL                                      0          
   17    21        PRE_INC                                                  !4
         22    >   IS_SMALLER_OR_EQUAL                                      !4, !3
         23      > JMPNZ                                                    ~17, ->18
   15    24    > > JMP                                                      ->10
         25    >   FE_FREE                                                  $11
   22    26        INIT_FCALL                                               'var_dump'
         27        FETCH_OBJ_R                                      ~18     !0, 'callCounters'
         28        SEND_VAL                                                 ~18
         29        DO_ICALL                                                 
         30      > RETURN                                                   1

Class class@anonymous:
Function call:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 8
Branch analysis from position: 5
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
filename:       /in/L3NqP
function name:  call
number of ops:  12
compiled vars:  !0 = $index
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
    6     1        FETCH_OBJ_IS                                     ~1      'callCounters'
          2        ISSET_ISEMPTY_DIM_OBJ                         0  ~2      ~1, !0
          3        BOOL_NOT                                         ~3      ~2
          4      > JMPZ                                                     ~3, ->8
    7     5    >   FETCH_OBJ_W                                      $4      'callCounters'
          6        ASSIGN_DIM                                               $4, !0
          7        OP_DATA                                                  0
    9     8    >   FETCH_OBJ_RW                                     $6      'callCounters'
          9        FETCH_DIM_RW                                     $7      $6, !0
         10        PRE_INC                                                  $7
   10    11      > RETURN                                                   null

End of function call

End of class class@anonymous.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.59 ms | 1400 KiB | 19 Q