3v4l.org

run code in 300+ PHP versions simultaneously
<?php $start = new \DateTime('2019-05-08 07:00:00'); $end = new \DateTime('2019-05-08 07:30:00'); function getSlots(\DateTime $start, \DateTime $end): array { $slots = []; while ($start < $end) { $old = clone($start); $start->modify('+2 hours'); if ($start > $end) { echo 1; $slots[] = [ 'from' => $old, 'to' => $end ]; return $slots; } else { $slots[] = [ 'from' => $old, 'to' => clone($start) ]; } } return $slots; } var_dump(getSlots($start, $end));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qAatj
function name:  (null)
number of ops:  16
compiled vars:  !0 = $start, !1 = $end
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   NEW                                              $2      'DateTime'
          1        SEND_VAL_EX                                              '2019-05-08+07%3A00%3A00'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $2
    4     4        NEW                                              $5      'DateTime'
          5        SEND_VAL_EX                                              '2019-05-08+07%3A30%3A00'
          6        DO_FCALL                                      0          
          7        ASSIGN                                                   !1, $5
   30     8        INIT_FCALL                                               'var_dump'
          9        INIT_FCALL                                               'getslots'
         10        SEND_VAR                                                 !0
         11        SEND_VAR                                                 !1
         12        DO_FCALL                                      0  $8      
         13        SEND_VAR                                                 $8
         14        DO_ICALL                                                 
         15      > RETURN                                                   1

Function getslots:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 24
Branch analysis from position: 24
2 jumps found. (Code = 44) Position 1 = 26, Position 2 = 4
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 19
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
2 jumps found. (Code = 44) Position 1 = 26, Position 2 = 4
Branch analysis from position: 26
Branch analysis from position: 4
filename:       /in/qAatj
function name:  getSlots
number of ops:  30
compiled vars:  !0 = $start, !1 = $end, !2 = $slots, !3 = $old
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    8     2        ASSIGN                                                   !2, <array>
    9     3      > JMP                                                      ->24
   10     4    >   CLONE                                            ~5      !0
          5        ASSIGN                                                   !3, ~5
   11     6        INIT_METHOD_CALL                                         !0, 'modify'
          7        SEND_VAL_EX                                              '%2B2+hours'
          8        DO_FCALL                                      0          
   13     9        IS_SMALLER                                               !1, !0
         10      > JMPZ                                                     ~8, ->19
   14    11    >   ECHO                                                     1
   16    12        INIT_ARRAY                                       ~10     !3, 'from'
   17    13        ADD_ARRAY_ELEMENT                                ~10     !1, 'to'
   15    14        ASSIGN_DIM                                               !2
   17    15        OP_DATA                                                  ~10
   19    16        VERIFY_RETURN_TYPE                                       !2
         17      > RETURN                                                   !2
         18*       JMP                                                      ->24
   22    19    >   INIT_ARRAY                                       ~12     !3, 'from'
   23    20        CLONE                                            ~13     !0
         21        ADD_ARRAY_ELEMENT                                ~12     ~13, 'to'
   21    22        ASSIGN_DIM                                               !2
   23    23        OP_DATA                                                  ~12
    9    24    >   IS_SMALLER                                               !0, !1
         25      > JMPNZ                                                    ~14, ->4
   27    26    >   VERIFY_RETURN_TYPE                                       !2
         27      > RETURN                                                   !2
   28    28*       VERIFY_RETURN_TYPE                                       
         29*     > RETURN                                                   null

End of function getslots

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.22 ms | 1403 KiB | 16 Q