3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Record { protected $index=0; //page index protected $pages=[]; //pages array public function nextPage() { $this->index++; } public function addRecord($key, $value) { $this->pages[$this->index][$key] = $value; } public function getPage($index) { if ($index > $this->index) return NULL; else return $this->pages[$this->index]; } } class AdditiveRecord extends Record { private function getSums($range) { $sums = $this->pages[$range[0]]; $lim = ($range[1] <= $this->index) ? $range[1] : $this->index; for ($i = $range[0]+1;$i<$lim;$i++) { foreach($this->pages[$i] as $k=>$v) $sums[$k] += $v; } return $sums; } } $m = new AdditiveRecord(); for ($j = 1;$j<3;$j++) { for ($i = 1;$i<10;$i++) $m.addElement($i,$j*10+$i); $m->nextPage(); } $m->getSums([0,1]);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
2 jumps found. (Code = 44) Position 1 = 23, Position 2 = 5
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 16
Branch analysis from position: 16
2 jumps found. (Code = 44) Position 1 = 18, Position 2 = 7
Branch analysis from position: 18
2 jumps found. (Code = 44) Position 1 = 23, Position 2 = 5
Branch analysis from position: 23
Branch analysis from position: 5
Branch analysis from position: 7
2 jumps found. (Code = 44) Position 1 = 18, Position 2 = 7
Branch analysis from position: 18
Branch analysis from position: 7
filename:       /in/MraKW
function name:  (null)
number of ops:  27
compiled vars:  !0 = $m, !1 = $j, !2 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   33     0  E >   NEW                                              $3      'AdditiveRecord'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $3
   34     3        ASSIGN                                                   !1, 1
          4      > JMP                                                      ->21
   35     5    >   ASSIGN                                                   !2, 1
          6      > JMP                                                      ->16
   36     7    >   INIT_FCALL_BY_NAME                                       'addElement'
          8        SEND_VAR_EX                                              !2
          9        MUL                                              ~8      !1, 10
         10        ADD                                              ~9      ~8, !2
         11        SEND_VAL_EX                                              ~9
         12        DO_FCALL                                      0  $10     
         13        CONCAT                                           ~11     !0, $10
         14        FREE                                                     ~11
   35    15        PRE_INC                                                  !2
         16    >   IS_SMALLER                                               !2, 10
         17      > JMPNZ                                                    ~13, ->7
   37    18    >   INIT_METHOD_CALL                                         !0, 'nextPage'
         19        DO_FCALL                                      0          
   34    20        PRE_INC                                                  !1
         21    >   IS_SMALLER                                               !1, 3
         22      > JMPNZ                                                    ~16, ->5
   39    23    >   INIT_METHOD_CALL                                         !0, 'getSums'
         24        SEND_VAL_EX                                              <array>
         25        DO_FCALL                                      0          
         26      > RETURN                                                   1

Class Record:
Function nextpage:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MraKW
function name:  nextPage
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   PRE_INC_OBJ                                              'index'
    9     1      > RETURN                                                   null

End of function nextpage

Function addrecord:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MraKW
function name:  addRecord
number of ops:  8
compiled vars:  !0 = $key, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   11     2        FETCH_OBJ_R                                      ~3      'index'
          3        FETCH_OBJ_W                                      $2      'pages'
          4        FETCH_DIM_W                                      $4      $2, ~3
          5        ASSIGN_DIM                                               $4, !0
          6        OP_DATA                                                  !1
   12     7      > RETURN                                                   null

End of function addrecord

Function getpage:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 6
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MraKW
function name:  getPage
number of ops:  11
compiled vars:  !0 = $index
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
   14     1        FETCH_OBJ_R                                      ~1      'index'
          2        IS_SMALLER                                               ~1, !0
          3      > JMPZ                                                     ~2, ->6
   15     4    > > RETURN                                                   null
          5*       JMP                                                      ->10
   17     6    >   FETCH_OBJ_R                                      ~4      'index'
          7        FETCH_OBJ_R                                      ~3      'pages'
          8        FETCH_DIM_R                                      ~5      ~3, ~4
          9      > RETURN                                                   ~5
   18    10*     > RETURN                                                   null

End of function getpage

End of class Record.

Class AdditiveRecord:
Function getsums:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 12
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
2 jumps found. (Code = 44) Position 1 = 31, Position 2 = 19
Branch analysis from position: 31
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
2 jumps found. (Code = 77) Position 1 = 22, Position 2 = 27
Branch analysis from position: 22
2 jumps found. (Code = 78) Position 1 = 23, Position 2 = 27
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
Branch analysis from position: 27
2 jumps found. (Code = 44) Position 1 = 31, Position 2 = 19
Branch analysis from position: 31
Branch analysis from position: 19
Branch analysis from position: 27
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
filename:       /in/MraKW
function name:  getSums
number of ops:  33
compiled vars:  !0 = $range, !1 = $sums, !2 = $lim, !3 = $i, !4 = $v, !5 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   22     0  E >   RECV                                             !0      
   23     1        FETCH_DIM_R                                      ~7      !0, 0
          2        FETCH_OBJ_R                                      ~6      'pages'
          3        FETCH_DIM_R                                      ~8      ~6, ~7
          4        ASSIGN                                                   !1, ~8
   24     5        FETCH_DIM_R                                      ~10     !0, 1
          6        FETCH_OBJ_R                                      ~11     'index'
          7        IS_SMALLER_OR_EQUAL                                      ~10, ~11
          8      > JMPZ                                                     ~12, ->12
          9    >   FETCH_DIM_R                                      ~13     !0, 1
         10        QM_ASSIGN                                        ~14     ~13
         11      > JMP                                                      ->14
         12    >   FETCH_OBJ_R                                      ~15     'index'
         13        QM_ASSIGN                                        ~14     ~15
         14    >   ASSIGN                                                   !2, ~14
   25    15        FETCH_DIM_R                                      ~17     !0, 0
         16        ADD                                              ~18     ~17, 1
         17        ASSIGN                                                   !3, ~18
         18      > JMP                                                      ->29
   26    19    >   FETCH_OBJ_R                                      ~20     'pages'
         20        FETCH_DIM_R                                      ~21     ~20, !3
         21      > FE_RESET_R                                       $22     ~21, ->27
         22    > > FE_FETCH_R                                       ~23     $22, !4, ->27
         23    >   ASSIGN                                                   !5, ~23
   27    24        ASSIGN_DIM_OP                +=               1          !1, !5
         25        OP_DATA                                                  !4
   26    26      > JMP                                                      ->22
         27    >   FE_FREE                                                  $22
   25    28        PRE_INC                                                  !3
         29    >   IS_SMALLER                                               !3, !2
         30      > JMPNZ                                                    ~27, ->19
   29    31    > > RETURN                                                   !1
   30    32*     > RETURN                                                   null

End of function getsums

Function nextpage:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MraKW
function name:  nextPage
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   PRE_INC_OBJ                                              'index'
    9     1      > RETURN                                                   null

End of function nextpage

Function addrecord:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MraKW
function name:  addRecord
number of ops:  8
compiled vars:  !0 = $key, !1 = $value
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   11     2        FETCH_OBJ_R                                      ~3      'index'
          3        FETCH_OBJ_W                                      $2      'pages'
          4        FETCH_DIM_W                                      $4      $2, ~3
          5        ASSIGN_DIM                                               $4, !0
          6        OP_DATA                                                  !1
   12     7      > RETURN                                                   null

End of function addrecord

Function getpage:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 4, Position 2 = 6
Branch analysis from position: 4
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/MraKW
function name:  getPage
number of ops:  11
compiled vars:  !0 = $index
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
   14     1        FETCH_OBJ_R                                      ~1      'index'
          2        IS_SMALLER                                               ~1, !0
          3      > JMPZ                                                     ~2, ->6
   15     4    > > RETURN                                                   null
          5*       JMP                                                      ->10
   17     6    >   FETCH_OBJ_R                                      ~4      'index'
          7        FETCH_OBJ_R                                      ~3      'pages'
          8        FETCH_DIM_R                                      ~5      ~3, ~4
          9      > RETURN                                                   ~5
   18    10*     > RETURN                                                   null

End of function getpage

End of class AdditiveRecord.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
171.59 ms | 1407 KiB | 13 Q