3v4l.org

run code in 300+ PHP versions simultaneously
<?php function rangeOfMonths($prior, $ahead, $baseYear = null, $baseMonth = null) { $baseYear = $baseYear ?: date('Y'); $baseMonth = $baseMonth ?: date('m'); $rangeStart = new DateTime($baseYear . '-' . $baseMonth . '-01 23:59:59'); $rangeEnd = clone($rangeStart); $rangeStart->modify("-{$prior} month"); $rangeEnd->modify("+{$ahead} month +1 day"); $period = new DatePeriod($rangeStart, new DateInterval('P1M'), $rangeEnd); $monthsList = []; foreach ($period as $i => $dateObject) { $monthsList[] = [ 'year' => $dateObject->format('Y'), 'nr_month' => $dateObject->format('n'), 'month_name' => $dateObject->format('M'), 'current' => $i == $prior ]; } return $monthsList; } var_export(rangeOfMonths(5, 6));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/C1Egc
function name:  (null)
number of ops:  8
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   26     0  E >   INIT_FCALL                                               'var_export'
          1        INIT_FCALL                                               'rangeofmonths'
          2        SEND_VAL                                                 5
          3        SEND_VAL                                                 6
          4        DO_FCALL                                      0  $0      
          5        SEND_VAR                                                 $0
          6        DO_ICALL                                                 
          7      > RETURN                                                   1

Function rangeofmonths:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 48, Position 2 = 67
Branch analysis from position: 48
2 jumps found. (Code = 78) Position 1 = 49, Position 2 = 67
Branch analysis from position: 49
1 jumps found. (Code = 42) Position 1 = 48
Branch analysis from position: 48
Branch analysis from position: 67
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 67
filename:       /in/C1Egc
function name:  rangeOfMonths
number of ops:  70
compiled vars:  !0 = $prior, !1 = $ahead, !2 = $baseYear, !3 = $baseMonth, !4 = $rangeStart, !5 = $rangeEnd, !6 = $period, !7 = $monthsList, !8 = $dateObject, !9 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV_INIT                                        !2      null
          3        RECV_INIT                                        !3      null
    4     4        JMP_SET                                          ~10     !2, ->9
          5        INIT_FCALL                                               'date'
          6        SEND_VAL                                                 'Y'
          7        DO_ICALL                                         $11     
          8        QM_ASSIGN                                        ~10     $11
          9        ASSIGN                                                   !2, ~10
    5    10        JMP_SET                                          ~13     !3, ->15
         11        INIT_FCALL                                               'date'
         12        SEND_VAL                                                 'm'
         13        DO_ICALL                                         $14     
         14        QM_ASSIGN                                        ~13     $14
         15        ASSIGN                                                   !3, ~13
    7    16        NEW                                              $16     'DateTime'
         17        CONCAT                                           ~17     !2, '-'
         18        CONCAT                                           ~18     ~17, !3
         19        CONCAT                                           ~19     ~18, '-01+23%3A59%3A59'
         20        SEND_VAL_EX                                              ~19
         21        DO_FCALL                                      0          
         22        ASSIGN                                                   !4, $16
    8    23        CLONE                                            ~22     !4
         24        ASSIGN                                                   !5, ~22
   10    25        INIT_METHOD_CALL                                         !4, 'modify'
         26        ROPE_INIT                                     3  ~25     '-'
         27        ROPE_ADD                                      1  ~25     ~25, !0
         28        ROPE_END                                      2  ~24     ~25, '+month'
         29        SEND_VAL_EX                                              ~24
         30        DO_FCALL                                      0          
   11    31        INIT_METHOD_CALL                                         !5, 'modify'
         32        ROPE_INIT                                     3  ~29     '%2B'
         33        ROPE_ADD                                      1  ~29     ~29, !1
         34        ROPE_END                                      2  ~28     ~29, '+month+%2B1+day'
         35        SEND_VAL_EX                                              ~28
         36        DO_FCALL                                      0          
   13    37        NEW                                              $32     'DatePeriod'
         38        SEND_VAR_EX                                              !4
         39        NEW                                              $33     'DateInterval'
         40        SEND_VAL_EX                                              'P1M'
         41        DO_FCALL                                      0          
         42        SEND_VAR_NO_REF_EX                                       $33
         43        SEND_VAR_EX                                              !5
         44        DO_FCALL                                      0          
         45        ASSIGN                                                   !6, $32
   14    46        ASSIGN                                                   !7, <array>
   15    47      > FE_RESET_R                                       $38     !6, ->67
         48    > > FE_FETCH_R                                       ~39     $38, !8, ->67
         49    >   ASSIGN                                                   !9, ~39
   17    50        INIT_METHOD_CALL                                         !8, 'format'
         51        SEND_VAL_EX                                              'Y'
         52        DO_FCALL                                      0  $42     
         53        INIT_ARRAY                                       ~43     $42, 'year'
   18    54        INIT_METHOD_CALL                                         !8, 'format'
         55        SEND_VAL_EX                                              'n'
         56        DO_FCALL                                      0  $44     
         57        ADD_ARRAY_ELEMENT                                ~43     $44, 'nr_month'
   19    58        INIT_METHOD_CALL                                         !8, 'format'
         59        SEND_VAL_EX                                              'M'
         60        DO_FCALL                                      0  $45     
         61        ADD_ARRAY_ELEMENT                                ~43     $45, 'month_name'
   20    62        IS_EQUAL                                         ~46     !9, !0
         63        ADD_ARRAY_ELEMENT                                ~43     ~46, 'current'
   16    64        ASSIGN_DIM                                               !7
   20    65        OP_DATA                                                  ~43
   15    66      > JMP                                                      ->48
         67    >   FE_FREE                                                  $38
   23    68      > RETURN                                                   !7
   24    69*     > RETURN                                                   null

End of function rangeofmonths

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
148.4 ms | 1407 KiB | 18 Q