3v4l.org

run code in 300+ PHP versions simultaneously
<?php print_r(getPeroid()->start); function getPeroid(\Datetime $date = null, DateInterval $interval = null) { $interval = $interval ? : new DateInterval('P7D'); $end = $date ? : new DateTime(); $end->modify("Last Sunday"); $start = clone $end; $start->sub($interval); return (object) array( "start" => $start->format("l, d F Y"), "end" => $end->format("l, d F Y") ); } function getPeriodBetween(Datetime $start = null, Datetime $end = null, DateInterval $interval = null) { $interval = $interval ? : new DateInterval('P7D'); if ($start === null) { $start = new DateTime(); $start->modify("First Sunday of January"); } else { $start->modify("First Sunday"); } if ($end === null) { $end = new DateTime(); $end->modify("Last Sunday of December"); } $range = array(); while ( $start < $end ) { $r = (object) array( "start" => $start->format("l, d F Y") ); $start->add($interval); $r->end = $start->format("l, d F Y"); $range[] = $r; } return $range; }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HkC2V
function name:  (null)
number of ops:  7
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   INIT_FCALL                                               'print_r'
          1        INIT_FCALL_BY_NAME                                       'getPeroid'
          2        DO_FCALL                                      0  $0      
          3        FETCH_OBJ_R                                      ~1      $0, 'start'
          4        SEND_VAL                                                 ~1
          5        DO_ICALL                                                 
   43     6      > RETURN                                                   1

Function getperoid:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/HkC2V
function name:  getPeroid
number of ops:  32
compiled vars:  !0 = $date, !1 = $interval, !2 = $end, !3 = $start
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV_INIT                                        !0      null
          1        RECV_INIT                                        !1      null
    5     2        JMP_SET                                          ~4      !1, ->7
          3        NEW                                              $5      'DateInterval'
          4        SEND_VAL_EX                                              'P7D'
          5        DO_FCALL                                      0          
          6        QM_ASSIGN                                        ~4      $5
          7        ASSIGN                                                   !1, ~4
    6     8        JMP_SET                                          ~8      !0, ->12
          9        NEW                                              $9      'DateTime'
         10        DO_FCALL                                      0          
         11        QM_ASSIGN                                        ~8      $9
         12        ASSIGN                                                   !2, ~8
    7    13        INIT_METHOD_CALL                                         !2, 'modify'
         14        SEND_VAL_EX                                              'Last+Sunday'
         15        DO_FCALL                                      0          
    9    16        CLONE                                            ~13     !2
         17        ASSIGN                                                   !3, ~13
   10    18        INIT_METHOD_CALL                                         !3, 'sub'
         19        SEND_VAR_EX                                              !1
         20        DO_FCALL                                      0          
   13    21        INIT_METHOD_CALL                                         !3, 'format'
         22        SEND_VAL_EX                                              'l%2C+d+F+Y'
         23        DO_FCALL                                      0  $16     
         24        INIT_ARRAY                                       ~17     $16, 'start'
   14    25        INIT_METHOD_CALL                                         !2, 'format'
         26        SEND_VAL_EX                                              'l%2C+d+F+Y'
         27        DO_FCALL                                      0  $18     
         28        ADD_ARRAY_ELEMENT                                ~17     $18, 'end'
         29        CAST                                          8  ~19     ~17
         30      > RETURN                                                   ~19
   16    31*     > RETURN                                                   null

End of function getperoid

Function getperiodbetween:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 18
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 29
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 47
Branch analysis from position: 47
2 jumps found. (Code = 44) Position 1 = 49, Position 2 = 31
Branch analysis from position: 49
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 31
2 jumps found. (Code = 44) Position 1 = 49, Position 2 = 31
Branch analysis from position: 49
Branch analysis from position: 31
Branch analysis from position: 29
Branch analysis from position: 18
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 29
Branch analysis from position: 23
Branch analysis from position: 29
filename:       /in/HkC2V
function name:  getPeriodBetween
number of ops:  51
compiled vars:  !0 = $start, !1 = $end, !2 = $interval, !3 = $range, !4 = $r
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   RECV_INIT                                        !0      null
          1        RECV_INIT                                        !1      null
          2        RECV_INIT                                        !2      null
   19     3        JMP_SET                                          ~5      !2, ->8
          4        NEW                                              $6      'DateInterval'
          5        SEND_VAL_EX                                              'P7D'
          6        DO_FCALL                                      0          
          7        QM_ASSIGN                                        ~5      $6
          8        ASSIGN                                                   !2, ~5
   21     9        TYPE_CHECK                                    2          !0
         10      > JMPZ                                                     ~9, ->18
   22    11    >   NEW                                              $10     'DateTime'
         12        DO_FCALL                                      0          
         13        ASSIGN                                                   !0, $10
   23    14        INIT_METHOD_CALL                                         !0, 'modify'
         15        SEND_VAL_EX                                              'First+Sunday+of+January'
         16        DO_FCALL                                      0          
         17      > JMP                                                      ->21
   25    18    >   INIT_METHOD_CALL                                         !0, 'modify'
         19        SEND_VAL_EX                                              'First+Sunday'
         20        DO_FCALL                                      0          
   28    21    >   TYPE_CHECK                                    2          !1
         22      > JMPZ                                                     ~15, ->29
   29    23    >   NEW                                              $16     'DateTime'
         24        DO_FCALL                                      0          
         25        ASSIGN                                                   !1, $16
   30    26        INIT_METHOD_CALL                                         !1, 'modify'
         27        SEND_VAL_EX                                              'Last+Sunday+of+December'
         28        DO_FCALL                                      0          
   33    29    >   ASSIGN                                                   !3, <array>
   34    30      > JMP                                                      ->47
   36    31    >   INIT_METHOD_CALL                                         !0, 'format'
         32        SEND_VAL_EX                                              'l%2C+d+F+Y'
         33        DO_FCALL                                      0  $21     
         34        INIT_ARRAY                                       ~22     $21, 'start'
         35        CAST                                          8  ~23     ~22
   35    36        ASSIGN                                                   !4, ~23
   38    37        INIT_METHOD_CALL                                         !0, 'add'
         38        SEND_VAR_EX                                              !2
         39        DO_FCALL                                      0          
   39    40        INIT_METHOD_CALL                                         !0, 'format'
         41        SEND_VAL_EX                                              'l%2C+d+F+Y'
         42        DO_FCALL                                      0  $27     
         43        ASSIGN_OBJ                                               !4, 'end'
         44        OP_DATA                                                  $27
   40    45        ASSIGN_DIM                                               !3
         46        OP_DATA                                                  !4
   34    47    >   IS_SMALLER                                               !0, !1
         48      > JMPNZ                                                    ~29, ->31
   42    49    > > RETURN                                                   !3
   43    50*     > RETURN                                                   null

End of function getperiodbetween

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
178.96 ms | 1404 KiB | 15 Q