3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getGridStepForValue(float $c, int $minCountLines): float { $config = [15, 5, 2, 1]; $n = ceil($c); $length = \strlen((string)$n); while ($length) { foreach ($config as $singleDivisor) { $nDivisor = (float)str_pad((string)$singleDivisor, $length, '0'); if ($n - ($nDivisor * $minCountLines) > 0) { return $nDivisor; } } $length--; } return getGridStepForValue($c * 10, $minCountLines) / 10; } var_dump(getGridStepForValue(1, 4), getGridStepForValue(1, 5));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/QPnct
function name:  (null)
number of ops:  13
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   INIT_FCALL                                               'var_dump'
          1        INIT_FCALL                                               'getgridstepforvalue'
          2        SEND_VAL                                                 1
          3        SEND_VAL                                                 4
          4        DO_FCALL                                      0  $0      
          5        SEND_VAR                                                 $0
   22     6        INIT_FCALL                                               'getgridstepforvalue'
          7        SEND_VAL                                                 1
          8        SEND_VAL                                                 5
          9        DO_FCALL                                      0  $1      
         10        SEND_VAR                                                 $1
         11        DO_ICALL                                                 
         12      > RETURN                                                   1

Function getgridstepforvalue:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 31
Branch analysis from position: 31
2 jumps found. (Code = 44) Position 1 = 32, Position 2 = 11
Branch analysis from position: 32
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
2 jumps found. (Code = 77) Position 1 = 12, Position 2 = 29
Branch analysis from position: 12
2 jumps found. (Code = 78) Position 1 = 13, Position 2 = 29
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 25, Position 2 = 28
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
Branch analysis from position: 29
2 jumps found. (Code = 44) Position 1 = 32, Position 2 = 11
Branch analysis from position: 32
Branch analysis from position: 11
Branch analysis from position: 29
filename:       /in/QPnct
function name:  getGridStepForValue
number of ops:  42
compiled vars:  !0 = $c, !1 = $minCountLines, !2 = $config, !3 = $n, !4 = $length, !5 = $singleDivisor, !6 = $nDivisor
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    5     2        ASSIGN                                                   !2, <array>
    7     3        INIT_FCALL                                               'ceil'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $8      
          6        ASSIGN                                                   !3, $8
    8     7        CAST                                          6  ~10     !3
          8        STRLEN                                           ~11     ~10
          9        ASSIGN                                                   !4, ~11
    9    10      > JMP                                                      ->31
   10    11    > > FE_RESET_R                                       $13     !2, ->29
         12    > > FE_FETCH_R                                               $13, !5, ->29
   11    13    >   INIT_FCALL                                               'str_pad'
         14        CAST                                          6  ~14     !5
         15        SEND_VAL                                                 ~14
         16        SEND_VAR                                                 !4
         17        SEND_VAL                                                 '0'
         18        DO_ICALL                                         $15     
         19        CAST                                          5  ~16     $15
         20        ASSIGN                                                   !6, ~16
   12    21        MUL                                              ~18     !6, !1
         22        SUB                                              ~19     !3, ~18
         23        IS_SMALLER                                               0, ~19
         24      > JMPZ                                                     ~20, ->28
   13    25    >   VERIFY_RETURN_TYPE                                       !6
         26        FE_FREE                                                  $13
         27      > RETURN                                                   !6
   10    28    > > JMP                                                      ->12
         29    >   FE_FREE                                                  $13
   16    30        PRE_DEC                                                  !4
    9    31    > > JMPNZ                                                    !4, ->11
   18    32    >   INIT_FCALL_BY_NAME                                       'getGridStepForValue'
         33        MUL                                              ~22     !0, 10
         34        SEND_VAL_EX                                              ~22
         35        SEND_VAR_EX                                              !1
         36        DO_FCALL                                      0  $23     
         37        DIV                                              ~24     $23, 10
         38        VERIFY_RETURN_TYPE                                       ~24
         39      > RETURN                                                   ~24
   19    40*       VERIFY_RETURN_TYPE                                       
         41*     > RETURN                                                   null

End of function getgridstepforvalue

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
174.08 ms | 1403 KiB | 21 Q