3v4l.org

run code in 300+ PHP versions simultaneously
<?php $base = new DateTime("2015-03-04 00:00:00 Europe/Berlin"); $date = new DateTime("2015-03-06 04:23:56 UTC"); $interval = new DateInterval('P1D'); var_dump(ceilDateTimeByInterval($base, $date, $interval)); function ceilDateTimeByInterval($baseDate, $date, $interval) { $ret = $date; $diff = $baseDate->diff($date); if ($interval->y) { $y = ceil($diff->y / $interval->y) * $interval->y; } if ($interval->m) { $m = ceil($diff->m / $interval->m) * $interval->m; } if ($interval->d) { $d = ceil($diff->d / $interval->d) * $interval->d; } if (isset($y) || isset($m) || isset($d)) { $y = isset($y) ? $y : (int)$date->format('Y'); $m = isset($m) ? $m : (int)$date->format('m'); $d = isset($d) ? $d : (int)$date->format('d'); $ret = ($ret === $date) ? clone $ret : $ret; $ret->setDate($y, $m, $d); } if ($interval->h) { $h = ceil($diff->h / $interval->h) * $interval->h; } if ($interval->i) { $i = ceil($diff->i / $interval->i) * $interval->i; } if ($interval->s) { $s = ceil($diff->s / $interval->s) * $interval->s; } if (isset($h) || isset($i) || isset($s)) { $h = isset($h) ? $h : (int)$date->format('G'); $i = isset($i) ? $i : (int)$date->format('i'); $s = isset($s) ? $s : (int)$date->format('s'); $ret = ($ret === $date) ? clone $ret : $ret; $ret->setTime($h, $i, $s); } return $ret; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/gOUmC
function name:  (null)
number of ops:  21
compiled vars:  !0 = $base, !1 = $date, !2 = $interval
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   NEW                                              $3      'DateTime'
          1        SEND_VAL_EX                                              '2015-03-04+00%3A00%3A00+Europe%2FBerlin'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $3
    4     4        NEW                                              $6      'DateTime'
          5        SEND_VAL_EX                                              '2015-03-06+04%3A23%3A56+UTC'
          6        DO_FCALL                                      0          
          7        ASSIGN                                                   !1, $6
    5     8        NEW                                              $9      'DateInterval'
          9        SEND_VAL_EX                                              'P1D'
         10        DO_FCALL                                      0          
         11        ASSIGN                                                   !2, $9
    6    12        INIT_FCALL                                               'var_dump'
         13        INIT_FCALL_BY_NAME                                       'ceilDateTimeByInterval'
         14        SEND_VAR_EX                                              !0
         15        SEND_VAR_EX                                              !1
         16        SEND_VAR_EX                                              !2
         17        DO_FCALL                                      0  $12     
         18        SEND_VAR                                                 $12
         19        DO_ICALL                                                 
   57    20      > RETURN                                                   1

Function ceildatetimebyinterval:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 10, Position 2 = 19
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 21, Position 2 = 30
Branch analysis from position: 21
2 jumps found. (Code = 43) Position 1 = 32, Position 2 = 41
Branch analysis from position: 32
2 jumps found. (Code = 47) Position 1 = 43, Position 2 = 45
Branch analysis from position: 43
2 jumps found. (Code = 47) Position 1 = 46, Position 2 = 48
Branch analysis from position: 46
2 jumps found. (Code = 43) Position 1 = 49, Position 2 = 91
Branch analysis from position: 49
2 jumps found. (Code = 43) Position 1 = 51, Position 2 = 53
Branch analysis from position: 51
1 jumps found. (Code = 42) Position 1 = 58
Branch analysis from position: 58
2 jumps found. (Code = 43) Position 1 = 61, Position 2 = 63
Branch analysis from position: 61
1 jumps found. (Code = 42) Position 1 = 68
Branch analysis from position: 68
2 jumps found. (Code = 43) Position 1 = 71, Position 2 = 73
Branch analysis from position: 71
1 jumps found. (Code = 42) Position 1 = 78
Branch analysis from position: 78
2 jumps found. (Code = 43) Position 1 = 81, Position 2 = 84
Branch analysis from position: 81
1 jumps found. (Code = 42) Position 1 = 85
Branch analysis from position: 85
2 jumps found. (Code = 43) Position 1 = 93, Position 2 = 102
Branch analysis from position: 93
2 jumps found. (Code = 43) Position 1 = 104, Position 2 = 113
Branch analysis from position: 104
2 jumps found. (Code = 43) Position 1 = 115, Position 2 = 124
Branch analysis from position: 115
2 jumps found. (Code = 47) Position 1 = 126, Position 2 = 128
Branch analysis from position: 126
2 jumps found. (Code = 47) Position 1 = 129, Position 2 = 131
Branch analysis from position: 129
2 jumps found. (Code = 43) Position 1 = 132, Position 2 = 174
Branch analysis from position: 132
2 jumps found. (Code = 43) Position 1 = 134, Position 2 = 136
Branch analysis from position: 134
1 jumps found. (Code = 42) Position 1 = 141
Branch analysis from position: 141
2 jumps found. (Code = 43) Position 1 = 144, Position 2 = 146
Branch analysis from position: 144
1 jumps found. (Code = 42) Position 1 = 151
Branch analysis from position: 151
2 jumps found. (Code = 43) Position 1 = 154, Position 2 = 156
Branch analysis from position: 154
1 jumps found. (Code = 42) Position 1 = 161
Branch analysis from position: 161
2 jumps found. (Code = 43) Position 1 = 164, Position 2 = 167
Branch analysis from position: 164
1 jumps found. (Code = 42) Position 1 = 168
Branch analysis from position: 168
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 167
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 156
2 jumps found. (Code = 43) Position 1 = 164, Position 2 = 167
Branch analysis from position: 164
Branch analysis from position: 167
Branch analysis from position: 146
2 jumps found. (Code = 43) Position 1 = 154, Position 2 = 156
Branch analysis from position: 154
Branch analysis from position: 156
Branch analysis from position: 136
2 jumps found. (Code = 43) Position 1 = 144, Position 2 = 146
Branch analysis from position: 144
Branch analysis from position: 146
Branch analysis from position: 174
Branch analysis from position: 131
Branch analysis from position: 128
Branch analysis from position: 124
Branch analysis from position: 113
Branch analysis from position: 102
Branch analysis from position: 84
2 jumps found. (Code = 43) Position 1 = 93, Position 2 = 102
Branch analysis from position: 93
Branch analysis from position: 102
Branch analysis from position: 73
2 jumps found. (Code = 43) Position 1 = 81, Position 2 = 84
Branch analysis from position: 81
Branch analysis from position: 84
Branch analysis from position: 63
2 jumps found. (Code = 43) Position 1 = 71, Position 2 = 73
Branch analysis from position: 71
Branch analysis from position: 73
Branch analysis from position: 53
2 jumps found. (Code = 43) Position 1 = 61, Position 2 = 63
Branch analysis from position: 61
Branch analysis from position: 63
Branch analysis from position: 91
Branch analysis from position: 48
Branch analysis from position: 45
Branch analysis from position: 41
Branch analysis from position: 30
Branch analysis from position: 19
filename:       /in/gOUmC
function name:  ceilDateTimeByInterval
number of ops:  176
compiled vars:  !0 = $baseDate, !1 = $date, !2 = $interval, !3 = $ret, !4 = $diff, !5 = $y, !6 = $m, !7 = $d, !8 = $h, !9 = $i, !10 = $s
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        RECV                                             !2      
    9     3        ASSIGN                                                   !3, !1
   10     4        INIT_METHOD_CALL                                         !0, 'diff'
          5        SEND_VAR_EX                                              !1
          6        DO_FCALL                                      0  $12     
          7        ASSIGN                                                   !4, $12
   12     8        FETCH_OBJ_R                                      ~14     !2, 'y'
          9      > JMPZ                                                     ~14, ->19
   13    10    >   INIT_FCALL                                               'ceil'
         11        FETCH_OBJ_R                                      ~15     !4, 'y'
         12        FETCH_OBJ_R                                      ~16     !2, 'y'
         13        DIV                                              ~17     ~15, ~16
         14        SEND_VAL                                                 ~17
         15        DO_ICALL                                         $18     
         16        FETCH_OBJ_R                                      ~19     !2, 'y'
         17        MUL                                              ~20     $18, ~19
         18        ASSIGN                                                   !5, ~20
   16    19    >   FETCH_OBJ_R                                      ~22     !2, 'm'
         20      > JMPZ                                                     ~22, ->30
   17    21    >   INIT_FCALL                                               'ceil'
         22        FETCH_OBJ_R                                      ~23     !4, 'm'
         23        FETCH_OBJ_R                                      ~24     !2, 'm'
         24        DIV                                              ~25     ~23, ~24
         25        SEND_VAL                                                 ~25
         26        DO_ICALL                                         $26     
         27        FETCH_OBJ_R                                      ~27     !2, 'm'
         28        MUL                                              ~28     $26, ~27
         29        ASSIGN                                                   !6, ~28
   20    30    >   FETCH_OBJ_R                                      ~30     !2, 'd'
         31      > JMPZ                                                     ~30, ->41
   21    32    >   INIT_FCALL                                               'ceil'
         33        FETCH_OBJ_R                                      ~31     !4, 'd'
         34        FETCH_OBJ_R                                      ~32     !2, 'd'
         35        DIV                                              ~33     ~31, ~32
         36        SEND_VAL                                                 ~33
         37        DO_ICALL                                         $34     
         38        FETCH_OBJ_R                                      ~35     !2, 'd'
         39        MUL                                              ~36     $34, ~35
         40        ASSIGN                                                   !7, ~36
   24    41    >   ISSET_ISEMPTY_CV                                 ~38     !5
         42      > JMPNZ_EX                                         ~38     ~38, ->45
         43    >   ISSET_ISEMPTY_CV                                 ~39     !6
         44        BOOL                                             ~38     ~39
         45    > > JMPNZ_EX                                         ~38     ~38, ->48
         46    >   ISSET_ISEMPTY_CV                                 ~40     !7
         47        BOOL                                             ~38     ~40
         48    > > JMPZ                                                     ~38, ->91
   25    49    >   ISSET_ISEMPTY_CV                                         !5
         50      > JMPZ                                                     ~41, ->53
         51    >   QM_ASSIGN                                        ~42     !5
         52      > JMP                                                      ->58
         53    >   INIT_METHOD_CALL                                         !1, 'format'
         54        SEND_VAL_EX                                              'Y'
         55        DO_FCALL                                      0  $43     
         56        CAST                                          4  ~44     $43
         57        QM_ASSIGN                                        ~42     ~44
         58    >   ASSIGN                                                   !5, ~42
   26    59        ISSET_ISEMPTY_CV                                         !6
         60      > JMPZ                                                     ~46, ->63
         61    >   QM_ASSIGN                                        ~47     !6
         62      > JMP                                                      ->68
         63    >   INIT_METHOD_CALL                                         !1, 'format'
         64        SEND_VAL_EX                                              'm'
         65        DO_FCALL                                      0  $48     
         66        CAST                                          4  ~49     $48
         67        QM_ASSIGN                                        ~47     ~49
         68    >   ASSIGN                                                   !6, ~47
   27    69        ISSET_ISEMPTY_CV                                         !7
         70      > JMPZ                                                     ~51, ->73
         71    >   QM_ASSIGN                                        ~52     !7
         72      > JMP                                                      ->78
         73    >   INIT_METHOD_CALL                                         !1, 'format'
         74        SEND_VAL_EX                                              'd'
         75        DO_FCALL                                      0  $53     
         76        CAST                                          4  ~54     $53
         77        QM_ASSIGN                                        ~52     ~54
         78    >   ASSIGN                                                   !7, ~52
   30    79        IS_IDENTICAL                                             !3, !1
         80      > JMPZ                                                     ~56, ->84
         81    >   CLONE                                            ~57     !3
         82        QM_ASSIGN                                        ~58     ~57
         83      > JMP                                                      ->85
         84    >   QM_ASSIGN                                        ~58     !3
         85    >   ASSIGN                                                   !3, ~58
   31    86        INIT_METHOD_CALL                                         !3, 'setDate'
         87        SEND_VAR_EX                                              !5
         88        SEND_VAR_EX                                              !6
         89        SEND_VAR_EX                                              !7
         90        DO_FCALL                                      0          
   34    91    >   FETCH_OBJ_R                                      ~61     !2, 'h'
         92      > JMPZ                                                     ~61, ->102
   35    93    >   INIT_FCALL                                               'ceil'
         94        FETCH_OBJ_R                                      ~62     !4, 'h'
         95        FETCH_OBJ_R                                      ~63     !2, 'h'
         96        DIV                                              ~64     ~62, ~63
         97        SEND_VAL                                                 ~64
         98        DO_ICALL                                         $65     
         99        FETCH_OBJ_R                                      ~66     !2, 'h'
        100        MUL                                              ~67     $65, ~66
        101        ASSIGN                                                   !8, ~67
   38   102    >   FETCH_OBJ_R                                      ~69     !2, 'i'
        103      > JMPZ                                                     ~69, ->113
   39   104    >   INIT_FCALL                                               'ceil'
        105        FETCH_OBJ_R                                      ~70     !4, 'i'
        106        FETCH_OBJ_R                                      ~71     !2, 'i'
        107        DIV                                              ~72     ~70, ~71
        108        SEND_VAL                                                 ~72
        109        DO_ICALL                                         $73     
        110        FETCH_OBJ_R                                      ~74     !2, 'i'
        111        MUL                                              ~75     $73, ~74
        112        ASSIGN                                                   !9, ~75
   42   113    >   FETCH_OBJ_R                                      ~77     !2, 's'
        114      > JMPZ                                                     ~77, ->124
   43   115    >   INIT_FCALL                                               'ceil'
        116        FETCH_OBJ_R                                      ~78     !4, 's'
        117        FETCH_OBJ_R                                      ~79     !2, 's'
        118        DIV                                              ~80     ~78, ~79
        119        SEND_VAL                                                 ~80
        120        DO_ICALL                                         $81     
        121        FETCH_OBJ_R                                      ~82     !2, 's'
        122        MUL                                              ~83     $81, ~82
        123        ASSIGN                                                   !10, ~83
   46   124    >   ISSET_ISEMPTY_CV                                 ~85     !8
        125      > JMPNZ_EX                                         ~85     ~85, ->128
        126    >   ISSET_ISEMPTY_CV                                 ~86     !9
        127        BOOL                                             ~85     ~86
        128    > > JMPNZ_EX                                         ~85     ~85, ->131
        129    >   ISSET_ISEMPTY_CV                                 ~87     !10
        130        BOOL                                             ~85     ~87
        131    > > JMPZ                                                     ~85, ->174
   47   132    >   ISSET_ISEMPTY_CV                                         !8
        133      > JMPZ                                                     ~88, ->136
        134    >   QM_ASSIGN                                        ~89     !8
        135      > JMP                                                      ->141
        136    >   INIT_METHOD_CALL                                         !1, 'format'
        137        SEND_VAL_EX                                              'G'
        138        DO_FCALL                                      0  $90     
        139        CAST                                          4  ~91     $90
        140        QM_ASSIGN                                        ~89     ~91
        141    >   ASSIGN                                                   !8, ~89
   48   142        ISSET_ISEMPTY_CV                                         !9
        143      > JMPZ                                                     ~93, ->146
        144    >   QM_ASSIGN                                        ~94     !9
        145      > JMP                                                      ->151
        146    >   INIT_METHOD_CALL                                         !1, 'format'
        147        SEND_VAL_EX                                              'i'
        148        DO_FCALL                                      0  $95     
        149        CAST                                          4  ~96     $95
        150        QM_ASSIGN                                        ~94     ~96
        151    >   ASSIGN                                                   !9, ~94
   49   152        ISSET_ISEMPTY_CV                                         !10
        153      > JMPZ                                                     ~98, ->156
        154    >   QM_ASSIGN                                        ~99     !10
        155      > JMP                                                      ->161
        156    >   INIT_METHOD_CALL                                         !1, 'format'
        157        SEND_VAL_EX                                              's'
        158        DO_FCALL                                      0  $100    
        159        CAST                                          4  ~101    $100
        160        QM_ASSIGN                                        ~99     ~101
        161    >   ASSIGN                                                   !10, ~99
   52   162        IS_IDENTICAL                                             !3, !1
        163      > JMPZ                                                     ~103, ->167
        164    >   CLONE                                            ~104    !3
        165        QM_ASSIGN                                        ~105    ~104
        166      > JMP                                                      ->168
        167    >   QM_ASSIGN                                        ~105    !3
        168    >   ASSIGN                                                   !3, ~105
   53   169        INIT_METHOD_CALL                                         !3, 'setTime'
        170        SEND_VAR_EX                                              !8
        171        SEND_VAR_EX                                              !9
        172        SEND_VAR_EX                                              !10
        173        DO_FCALL                                      0          
   56   174    > > RETURN                                                   !3
   57   175*     > RETURN                                                   null

End of function ceildatetimebyinterval

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
160.41 ms | 1416 KiB | 17 Q