3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getIntervalEnd($pointer, $interval){ $to = clone $pointer; // For minute interval, return end of the pointers minute if($interval == 'PT1M') $to->setTime($to->format('H'), $to->format('i'), 59); // For hour interval, return end of the pointers hour elseif($interval == 'PT1H') $to->setTime($to->format('H'), 59, 59); // For day interval, return end of the pointers day elseif($interval == 'P1D') $to->setTime(23, 59, 59); // For week interval, return end of the pointers week elseif($interval == 'P7D'){ if($to->format('N') != 7) $to->setTimestamp(strtotime('next sunday', $to->getTimestamp())); $to->setTime(23, 59, 59); } // For month interval, return end of the pointers month elseif($interval == 'P1M') $to->setDate($to->format('Y'), $to->format('m'),$to->format('t'))->setTime(23, 59, 59); // For year interval, return end of the pointers year elseif($interval == 'P1Y') $to->setDate($to->format('Y'), 12, 31)->setTime(23, 59, 59); return $to; } echo getIntervalEnd(new \DateTime(), 'P1D')->format('c');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/PLnhj
function name:  (null)
number of ops:  11
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   39     0  E >   INIT_FCALL                                               'getintervalend'
          1        NEW                                              $0      'DateTime'
          2        DO_FCALL                                      0          
          3        SEND_VAR                                                 $0
          4        SEND_VAL                                                 'P1D'
          5        DO_FCALL                                      0  $2      
          6        INIT_METHOD_CALL                                         $2, 'format'
          7        SEND_VAL_EX                                              'c'
          8        DO_FCALL                                      0  $3      
          9        ECHO                                                     $3
         10      > RETURN                                                   1

Function getintervalend:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 6, Position 2 = 18
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 96
Branch analysis from position: 96
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
2 jumps found. (Code = 43) Position 1 = 20, Position 2 = 29
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 96
Branch analysis from position: 96
Branch analysis from position: 29
2 jumps found. (Code = 43) Position 1 = 31, Position 2 = 37
Branch analysis from position: 31
1 jumps found. (Code = 42) Position 1 = 96
Branch analysis from position: 96
Branch analysis from position: 37
2 jumps found. (Code = 43) Position 1 = 39, Position 2 = 59
Branch analysis from position: 39
2 jumps found. (Code = 43) Position 1 = 44, Position 2 = 53
Branch analysis from position: 44
1 jumps found. (Code = 42) Position 1 = 96
Branch analysis from position: 96
Branch analysis from position: 53
Branch analysis from position: 59
2 jumps found. (Code = 43) Position 1 = 61, Position 2 = 81
Branch analysis from position: 61
1 jumps found. (Code = 42) Position 1 = 96
Branch analysis from position: 96
Branch analysis from position: 81
2 jumps found. (Code = 43) Position 1 = 83, Position 2 = 96
Branch analysis from position: 83
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 96
filename:       /in/PLnhj
function name:  getIntervalEnd
number of ops:  98
compiled vars:  !0 = $pointer, !1 = $interval, !2 = $to
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    6     2        CLONE                                            ~3      !0
          3        ASSIGN                                                   !2, ~3
    9     4        IS_EQUAL                                                 !1, 'PT1M'
          5      > JMPZ                                                     ~5, ->18
   10     6    >   INIT_METHOD_CALL                                         !2, 'setTime'
          7        INIT_METHOD_CALL                                         !2, 'format'
          8        SEND_VAL_EX                                              'H'
          9        DO_FCALL                                      0  $6      
         10        SEND_VAR_NO_REF_EX                                       $6
         11        INIT_METHOD_CALL                                         !2, 'format'
         12        SEND_VAL_EX                                              'i'
         13        DO_FCALL                                      0  $7      
         14        SEND_VAR_NO_REF_EX                                       $7
         15        SEND_VAL_EX                                              59
         16        DO_FCALL                                      0          
         17      > JMP                                                      ->96
   13    18    >   IS_EQUAL                                                 !1, 'PT1H'
         19      > JMPZ                                                     ~9, ->29
   14    20    >   INIT_METHOD_CALL                                         !2, 'setTime'
         21        INIT_METHOD_CALL                                         !2, 'format'
         22        SEND_VAL_EX                                              'H'
         23        DO_FCALL                                      0  $10     
         24        SEND_VAR_NO_REF_EX                                       $10
         25        SEND_VAL_EX                                              59
         26        SEND_VAL_EX                                              59
         27        DO_FCALL                                      0          
         28      > JMP                                                      ->96
   17    29    >   IS_EQUAL                                                 !1, 'P1D'
         30      > JMPZ                                                     ~12, ->37
   18    31    >   INIT_METHOD_CALL                                         !2, 'setTime'
         32        SEND_VAL_EX                                              23
         33        SEND_VAL_EX                                              59
         34        SEND_VAL_EX                                              59
         35        DO_FCALL                                      0          
         36      > JMP                                                      ->96
   21    37    >   IS_EQUAL                                                 !1, 'P7D'
         38      > JMPZ                                                     ~14, ->59
   22    39    >   INIT_METHOD_CALL                                         !2, 'format'
         40        SEND_VAL_EX                                              'N'
         41        DO_FCALL                                      0  $15     
         42        IS_NOT_EQUAL                                             $15, 7
         43      > JMPZ                                                     ~16, ->53
   23    44    >   INIT_METHOD_CALL                                         !2, 'setTimestamp'
         45        INIT_FCALL                                               'strtotime'
         46        SEND_VAL                                                 'next+sunday'
         47        INIT_METHOD_CALL                                         !2, 'getTimestamp'
         48        DO_FCALL                                      0  $17     
         49        SEND_VAR                                                 $17
         50        DO_ICALL                                         $18     
         51        SEND_VAR_NO_REF_EX                                       $18
         52        DO_FCALL                                      0          
   24    53    >   INIT_METHOD_CALL                                         !2, 'setTime'
         54        SEND_VAL_EX                                              23
         55        SEND_VAL_EX                                              59
         56        SEND_VAL_EX                                              59
         57        DO_FCALL                                      0          
         58      > JMP                                                      ->96
   28    59    >   IS_EQUAL                                                 !1, 'P1M'
         60      > JMPZ                                                     ~21, ->81
   29    61    >   INIT_METHOD_CALL                                         !2, 'setDate'
         62        INIT_METHOD_CALL                                         !2, 'format'
         63        SEND_VAL_EX                                              'Y'
         64        DO_FCALL                                      0  $22     
         65        SEND_VAR_NO_REF_EX                                       $22
         66        INIT_METHOD_CALL                                         !2, 'format'
         67        SEND_VAL_EX                                              'm'
         68        DO_FCALL                                      0  $23     
         69        SEND_VAR_NO_REF_EX                                       $23
         70        INIT_METHOD_CALL                                         !2, 'format'
         71        SEND_VAL_EX                                              't'
         72        DO_FCALL                                      0  $24     
         73        SEND_VAR_NO_REF_EX                                       $24
         74        DO_FCALL                                      0  $25     
         75        INIT_METHOD_CALL                                         $25, 'setTime'
         76        SEND_VAL_EX                                              23
         77        SEND_VAL_EX                                              59
         78        SEND_VAL_EX                                              59
         79        DO_FCALL                                      0          
         80      > JMP                                                      ->96
   32    81    >   IS_EQUAL                                                 !1, 'P1Y'
         82      > JMPZ                                                     ~27, ->96
   33    83    >   INIT_METHOD_CALL                                         !2, 'setDate'
         84        INIT_METHOD_CALL                                         !2, 'format'
         85        SEND_VAL_EX                                              'Y'
         86        DO_FCALL                                      0  $28     
         87        SEND_VAR_NO_REF_EX                                       $28
         88        SEND_VAL_EX                                              12
         89        SEND_VAL_EX                                              31
         90        DO_FCALL                                      0  $29     
         91        INIT_METHOD_CALL                                         $29, 'setTime'
         92        SEND_VAL_EX                                              23
         93        SEND_VAL_EX                                              59
         94        SEND_VAL_EX                                              59
         95        DO_FCALL                                      0          
   35    96    > > RETURN                                                   !2
   36    97*     > RETURN                                                   null

End of function getintervalend

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
164.08 ms | 1407 KiB | 16 Q