3v4l.org

run code in 300+ PHP versions simultaneously
<?php class Test { public $page = 1; private $range = 4; public function getNumbers($pagesCount) { $numbers = []; $rangeL = $this->page - $this->range - 1; if ($rangeL < 1) { $rangeL = 1; } $rangeR = $rangeL + $this->range * 2 + 1; if ($rangeR > $pagesCount) { $rangeR = $pagesCount; $rangeL = $pagesCount - $this->range * 2 + 1; if ($rangeL < 1) { $rangeL = 1; } } if ($rangeL > 1) { $numbers[] = 1; if ($rangeL > 2) { $rangeL++; $numbers[] = false; } } for ($i = $rangeL; $i <= $rangeR; $i++) { $numbers[] = $i; } if ($rangeR < $pagesCount) { if ($rangeR < $pagesCount - 2) { $numbers[] = false; } else { $numbers[] = $pagesCount - 1; } $numbers[] = $pagesCount; } return $numbers; } } $test = new Test; $test->page = 88; print_r($test->getNumbers(100)); $test->page = 7; print_r($test->getNumbers(100));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/tY1Eq
function name:  (null)
number of ops:  20
compiled vars:  !0 = $test
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   57     0  E >   NEW                                              $1      'Test'
          1        DO_FCALL                                      0          
          2        ASSIGN                                                   !0, $1
   59     3        ASSIGN_OBJ                                               !0, 'page'
          4        OP_DATA                                                  88
   60     5        INIT_FCALL                                               'print_r'
          6        INIT_METHOD_CALL                                         !0, 'getNumbers'
          7        SEND_VAL_EX                                              100
          8        DO_FCALL                                      0  $5      
          9        SEND_VAR                                                 $5
         10        DO_ICALL                                                 
   62    11        ASSIGN_OBJ                                               !0, 'page'
         12        OP_DATA                                                  7
   63    13        INIT_FCALL                                               'print_r'
         14        INIT_METHOD_CALL                                         !0, 'getNumbers'
         15        SEND_VAL_EX                                              100
         16        DO_FCALL                                      0  $8      
         17        SEND_VAR                                                 $8
         18        DO_ICALL                                                 
         19      > RETURN                                                   1

Class Test:
Function getnumbers:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 10
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 26
Branch analysis from position: 17
2 jumps found. (Code = 43) Position 1 = 25, Position 2 = 26
Branch analysis from position: 25
2 jumps found. (Code = 43) Position 1 = 28, Position 2 = 35
Branch analysis from position: 28
2 jumps found. (Code = 43) Position 1 = 32, Position 2 = 35
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 40
Branch analysis from position: 40
2 jumps found. (Code = 44) Position 1 = 42, Position 2 = 37
Branch analysis from position: 42
2 jumps found. (Code = 43) Position 1 = 44, Position 2 = 55
Branch analysis from position: 44
2 jumps found. (Code = 43) Position 1 = 47, Position 2 = 50
Branch analysis from position: 47
1 jumps found. (Code = 42) Position 1 = 53
Branch analysis from position: 53
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 50
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 55
Branch analysis from position: 37
2 jumps found. (Code = 44) Position 1 = 42, Position 2 = 37
Branch analysis from position: 42
Branch analysis from position: 37
Branch analysis from position: 35
Branch analysis from position: 35
Branch analysis from position: 26
Branch analysis from position: 26
Branch analysis from position: 10
filename:       /in/tY1Eq
function name:  getNumbers
number of ops:  57
compiled vars:  !0 = $pagesCount, !1 = $numbers, !2 = $rangeL, !3 = $rangeR, !4 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
   10     1        ASSIGN                                                   !1, <array>
   12     2        FETCH_OBJ_R                                      ~6      'page'
          3        FETCH_OBJ_R                                      ~7      'range'
          4        SUB                                              ~8      ~6, ~7
          5        SUB                                              ~9      ~8, 1
          6        ASSIGN                                                   !2, ~9
   14     7        IS_SMALLER                                               !2, 1
          8      > JMPZ                                                     ~11, ->10
   15     9    >   ASSIGN                                                   !2, 1
   18    10    >   FETCH_OBJ_R                                      ~13     'range'
         11        MUL                                              ~14     ~13, 2
         12        ADD                                              ~15     !2, ~14
         13        ADD                                              ~16     ~15, 1
         14        ASSIGN                                                   !3, ~16
   20    15        IS_SMALLER                                               !0, !3
         16      > JMPZ                                                     ~18, ->26
   21    17    >   ASSIGN                                                   !3, !0
   22    18        FETCH_OBJ_R                                      ~20     'range'
         19        MUL                                              ~21     ~20, 2
         20        SUB                                              ~22     !0, ~21
         21        ADD                                              ~23     ~22, 1
         22        ASSIGN                                                   !2, ~23
   24    23        IS_SMALLER                                               !2, 1
         24      > JMPZ                                                     ~25, ->26
   25    25    >   ASSIGN                                                   !2, 1
   29    26    >   IS_SMALLER                                               1, !2
         27      > JMPZ                                                     ~27, ->35
   30    28    >   ASSIGN_DIM                                               !1
         29        OP_DATA                                                  1
   32    30        IS_SMALLER                                               2, !2
         31      > JMPZ                                                     ~29, ->35
   33    32    >   PRE_INC                                                  !2
   35    33        ASSIGN_DIM                                               !1
         34        OP_DATA                                                  <false>
   39    35    >   ASSIGN                                                   !4, !2
         36      > JMP                                                      ->40
   40    37    >   ASSIGN_DIM                                               !1
         38        OP_DATA                                                  !4
   39    39        PRE_INC                                                  !4
         40    >   IS_SMALLER_OR_EQUAL                                      !4, !3
         41      > JMPNZ                                                    ~35, ->37
   43    42    >   IS_SMALLER                                               !3, !0
         43      > JMPZ                                                     ~36, ->55
   44    44    >   SUB                                              ~37     !0, 2
         45        IS_SMALLER                                               !3, ~37
         46      > JMPZ                                                     ~38, ->50
   45    47    >   ASSIGN_DIM                                               !1
         48        OP_DATA                                                  <false>
         49      > JMP                                                      ->53
   47    50    >   SUB                                              ~41     !0, 1
         51        ASSIGN_DIM                                               !1
         52        OP_DATA                                                  ~41
   50    53    >   ASSIGN_DIM                                               !1
         54        OP_DATA                                                  !0
   53    55    > > RETURN                                                   !1
   54    56*     > RETURN                                                   null

End of function getnumbers

End of class Test.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
142.68 ms | 1409 KiB | 15 Q