3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types=1); error_reporting(-1); ini_set('display_errors', 'On'); /** * @param DateTimeImmutable $start * @param DateTimeImmutable $end * * @return Generator */ function remainingDaysPerMonthBetween(\DateTimeImmutable $start, \DateTimeImmutable $end): \Generator { while ($start < $end) { $diff = $start->diff(min( $start->modify('last day of this month'), $end )); yield [$start, $diff->days]; $start = $start->modify('first day of next month'); } } $start = new \DateTimeImmutable('2019-02-11'); $end = new \DateTimeImmutable('2019-04-23'); foreach (remainingDaysPerMonthBetween($start, $end) as [$date, $remainingDays]) { printf("%s: %d\n", $date->format('M'), $remainingDays + 1); }
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 20, Position 2 = 36
Branch analysis from position: 20
2 jumps found. (Code = 78) Position 1 = 21, Position 2 = 36
Branch analysis from position: 21
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
Branch analysis from position: 36
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 36
filename:       /in/BCAYq
function name:  (null)
number of ops:  38
compiled vars:  !0 = $start, !1 = $end, !2 = $date, !3 = $remainingDays
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   INIT_FCALL                                               'error_reporting'
          1        SEND_VAL                                                 -1
          2        DO_ICALL                                                 
    5     3        INIT_FCALL                                               'ini_set'
          4        SEND_VAL                                                 'display_errors'
          5        SEND_VAL                                                 'On'
          6        DO_ICALL                                                 
   26     7        NEW                                              $6      'DateTimeImmutable'
          8        SEND_VAL_EX                                              '2019-02-11'
          9        DO_FCALL                                      0          
         10        ASSIGN                                                   !0, $6
   27    11        NEW                                              $9      'DateTimeImmutable'
         12        SEND_VAL_EX                                              '2019-04-23'
         13        DO_FCALL                                      0          
         14        ASSIGN                                                   !1, $9
   29    15        INIT_FCALL                                               'remainingdayspermonthbetween'
         16        SEND_VAR                                                 !0
         17        SEND_VAR                                                 !1
         18        DO_FCALL                                      0  $12     
         19      > FE_RESET_R                                       $13     $12, ->36
         20    > > FE_FETCH_R                                               $13, $14, ->36
         21    >   FETCH_LIST_R                                     $15     $14, 0
         22        ASSIGN                                                   !2, $15
         23        FETCH_LIST_R                                     $17     $14, 1
         24        ASSIGN                                                   !3, $17
         25        FREE                                                     $14
   30    26        INIT_FCALL                                               'printf'
         27        SEND_VAL                                                 '%25s%3A+%25d%0A'
         28        INIT_METHOD_CALL                                         !2, 'format'
         29        SEND_VAL_EX                                              'M'
         30        DO_FCALL                                      0  $19     
         31        SEND_VAR                                                 $19
         32        ADD                                              ~20     !3, 1
         33        SEND_VAL                                                 ~20
         34        DO_ICALL                                                 
   29    35      > JMP                                                      ->20
         36    >   FE_FREE                                                  $13
   31    37      > RETURN                                                   1

Function remainingdayspermonthbetween:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
2 jumps found. (Code = 44) Position 1 = 25, Position 2 = 4
Branch analysis from position: 25
1 jumps found. (Code = 161) Position 1 = -2
Branch analysis from position: 4
2 jumps found. (Code = 44) Position 1 = 25, Position 2 = 4
Branch analysis from position: 25
Branch analysis from position: 4
filename:       /in/BCAYq
function name:  remainingDaysPerMonthBetween
number of ops:  26
compiled vars:  !0 = $start, !1 = $end, !2 = $diff
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
          1        RECV                                             !1      
          2        GENERATOR_CREATE                                         
   14     3      > JMP                                                      ->23
   15     4    >   INIT_METHOD_CALL                                         !0, 'diff'
          5        INIT_FCALL                                               'min'
   16     6        INIT_METHOD_CALL                                         !0, 'modify'
          7        SEND_VAL_EX                                              'last+day+of+this+month'
          8        DO_FCALL                                      0  $3      
          9        SEND_VAR                                                 $3
   17    10        SEND_VAR                                                 !1
         11        DO_ICALL                                         $4      
         12        SEND_VAR_NO_REF_EX                                       $4
         13        DO_FCALL                                      0  $5      
   15    14        ASSIGN                                                   !2, $5
   20    15        INIT_ARRAY                                       ~7      !0
         16        FETCH_OBJ_R                                      ~8      !2, 'days'
         17        ADD_ARRAY_ELEMENT                                ~7      ~8
         18        YIELD                                                    ~7
   22    19        INIT_METHOD_CALL                                         !0, 'modify'
         20        SEND_VAL_EX                                              'first+day+of+next+month'
         21        DO_FCALL                                      0  $10     
         22        ASSIGN                                                   !0, $10
   14    23    >   IS_SMALLER                                               !0, !1
         24      > JMPNZ                                                    ~12, ->4
   24    25    > > GENERATOR_RETURN                                         

End of function remainingdayspermonthbetween

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
168.24 ms | 1407 KiB | 22 Q