3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Odometer { public function __construct(array $values, $places){ $this->values = array_values($values); $this->places = $places; // 0=>a, 1=>b, ... prints [a],[b],... $this->output = reset($values); // [0]=>0, [0]=>1, [0]=>2, ...[] $this->register[0] = key($values); end($values); $this->limit = key($values); } public function iterate(){ for($i = 0; $i < count($register); $i++){ if($this->register[$i] > $this->limit){ $this->register[$i] = 0; if(isset($this->register[$i+1])){ $this->register[$i+1]++; } else { $this->register[$i+1] = 0; } } } $this->register[0]++; } public function setMeter(){ for($i = 0; $i < count($this->register); $i++){ $this->meter[$i] = $this->values[$this->register[$i]]; } } public function readMeter(){ $this->setMeter(); return '[' . implode('][', $this->meter) . ']'; } }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/SoNRB
function name:  (null)
number of ops:  1
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   42     0  E > > RETURN                                                   1

Class Odometer:
Function __construct:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/SoNRB
function name:  __construct
number of ops:  29
compiled vars:  !0 = $values, !1 = $places
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    5     2        INIT_FCALL                                               'array_values'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $3      
          5        ASSIGN_OBJ                                               'values'
          6        OP_DATA                                                  $3
    6     7        ASSIGN_OBJ                                               'places'
          8        OP_DATA                                                  !1
    9     9        INIT_FCALL                                               'reset'
         10        SEND_REF                                                 !0
         11        DO_ICALL                                         $6      
         12        ASSIGN_OBJ                                               'output'
         13        OP_DATA                                                  $6
   12    14        INIT_FCALL                                               'key'
         15        SEND_VAR                                                 !0
         16        DO_ICALL                                         $9      
         17        FETCH_OBJ_W                                      $7      'register'
         18        ASSIGN_DIM                                               $7, 0
         19        OP_DATA                                                  $9
   14    20        INIT_FCALL                                               'end'
         21        SEND_REF                                                 !0
         22        DO_ICALL                                                 
   15    23        INIT_FCALL                                               'key'
         24        SEND_VAR                                                 !0
         25        DO_ICALL                                         $12     
         26        ASSIGN_OBJ                                               'limit'
         27        OP_DATA                                                  $12
   16    28      > RETURN                                                   null

End of function __construct

Function iterate:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
2 jumps found. (Code = 44) Position 1 = 27, Position 2 = 2
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 2
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 23
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 19
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
2 jumps found. (Code = 44) Position 1 = 27, Position 2 = 2
Branch analysis from position: 27
Branch analysis from position: 2
Branch analysis from position: 19
2 jumps found. (Code = 44) Position 1 = 27, Position 2 = 2
Branch analysis from position: 27
Branch analysis from position: 2
Branch analysis from position: 23
filename:       /in/SoNRB
function name:  iterate
number of ops:  31
compiled vars:  !0 = $i, !1 = $register
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   ASSIGN                                                   !0, 0
          1      > JMP                                                      ->24
   20     2    >   FETCH_OBJ_R                                      ~3      'register'
          3        FETCH_DIM_R                                      ~4      ~3, !0
          4        FETCH_OBJ_R                                      ~5      'limit'
          5        IS_SMALLER                                               ~5, ~4
          6      > JMPZ                                                     ~6, ->23
   21     7    >   FETCH_OBJ_W                                      $7      'register'
          8        ASSIGN_DIM                                               $7, !0
          9        OP_DATA                                                  0
   22    10        ADD                                              ~10     !0, 1
         11        FETCH_OBJ_IS                                     ~9      'register'
         12        ISSET_ISEMPTY_DIM_OBJ                         0          ~9, ~10
         13      > JMPZ                                                     ~11, ->19
   23    14    >   ADD                                              ~13     !0, 1
         15        FETCH_OBJ_RW                                     $12     'register'
         16        FETCH_DIM_RW                                     $14     $12, ~13
         17        PRE_INC                                                  $14
         18      > JMP                                                      ->23
   25    19    >   ADD                                              ~17     !0, 1
         20        FETCH_OBJ_W                                      $16     'register'
         21        ASSIGN_DIM                                               $16, ~17
         22        OP_DATA                                                  0
   19    23    >   PRE_INC                                                  !0
         24    >   COUNT                                            ~20     !1
         25        IS_SMALLER                                               !0, ~20
         26      > JMPNZ                                                    ~21, ->2
   29    27    >   FETCH_OBJ_RW                                     $22     'register'
         28        FETCH_DIM_RW                                     $23     $22, 0
         29        PRE_INC                                                  $23
   30    30      > RETURN                                                   null

End of function iterate

Function setmeter:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
2 jumps found. (Code = 44) Position 1 = 14, Position 2 = 2
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 2
2 jumps found. (Code = 44) Position 1 = 14, Position 2 = 2
Branch analysis from position: 14
Branch analysis from position: 2
filename:       /in/SoNRB
function name:  setMeter
number of ops:  15
compiled vars:  !0 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   33     0  E >   ASSIGN                                                   !0, 0
          1      > JMP                                                      ->10
   34     2    >   FETCH_OBJ_R                                      ~5      'register'
          3        FETCH_DIM_R                                      ~6      ~5, !0
          4        FETCH_OBJ_R                                      ~4      'values'
          5        FETCH_DIM_R                                      ~7      ~4, ~6
          6        FETCH_OBJ_W                                      $2      'meter'
          7        ASSIGN_DIM                                               $2, !0
          8        OP_DATA                                                  ~7
   33     9        PRE_INC                                                  !0
         10    >   FETCH_OBJ_R                                      ~9      'register'
         11        COUNT                                            ~10     ~9
         12        IS_SMALLER                                               !0, ~10
         13      > JMPNZ                                                    ~11, ->2
   36    14    > > RETURN                                                   null

End of function setmeter

Function readmeter:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/SoNRB
function name:  readMeter
number of ops:  11
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   39     0  E >   INIT_METHOD_CALL                                         'setMeter'
          1        DO_FCALL                                      0          
   40     2        INIT_FCALL                                               'implode'
          3        SEND_VAL                                                 '%5D%5B'
          4        FETCH_OBJ_R                                      ~1      'meter'
          5        SEND_VAL                                                 ~1
          6        DO_ICALL                                         $2      
          7        CONCAT                                           ~3      '%5B', $2
          8        CONCAT                                           ~4      ~3, '%5D'
          9      > RETURN                                                   ~4
   41    10*     > RETURN                                                   null

End of function readmeter

End of class Odometer.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.21 ms | 1404 KiB | 23 Q