3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getIndex($index, $step, $size): int { return ((($index + $step) % $size) + $size) % $size; } echo getIndex(1, +1, 7); // I expect this to return 2 echo "\n"; echo getIndex(1, -1, 7); // I expect this to return 7
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jerEA
function name:  (null)
number of ops:  14
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   INIT_FCALL                                               'getindex'
          1        SEND_VAL                                                 1
          2        SEND_VAL                                                 1
          3        SEND_VAL                                                 7
          4        DO_FCALL                                      0  $0      
          5        ECHO                                                     $0
    9     6        ECHO                                                     '%0A'
   10     7        INIT_FCALL                                               'getindex'
          8        SEND_VAL                                                 1
          9        SEND_VAL                                                 -1
         10        SEND_VAL                                                 7
         11        DO_FCALL                                      0  $1      
         12        ECHO                                                     $1
         13      > RETURN                                                   1

Function getindex:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/jerEA
function name:  getIndex
number of ops:  11
compiled vars:  !0 = $index, !1 = $step, !2 = $size
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
    5     3        ADD                                              ~3      !0, !1
          4        MOD                                              ~4      ~3, !2
          5        ADD                                              ~5      ~4, !2
          6        MOD                                              ~6      ~5, !2
          7        VERIFY_RETURN_TYPE                                       ~6
          8      > RETURN                                                   ~6
    6     9*       VERIFY_RETURN_TYPE                                       
         10*     > RETURN                                                   null

End of function getindex

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
252.65 ms | 1006 KiB | 15 Q