3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getDates(DateTime $date) { if ($date->format('d') == 20) { $nextMonth = clone $date; $nextMonth->modify('-1 day'); $nextMonth->modify('+1 month'); return [ 'start' => $date, 'end' => $nextMonth, ]; } else if ($date->format('d') == 19) { $lastMonth = clone $date; $lastMonth->modify('+1 day'); $lastMonth->modify('-1 month'); return [ 'start' => $lastMonth, 'end' => $date, ]; } } $date = new DateTime('2017-09-20'); var_dump(getDates($date)); $date = new DateTime('2017-09-19'); var_dump(getDates($date));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vBOkI
function name:  (null)
number of ops:  21
compiled vars:  !0 = $date
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   24     0  E >   NEW                                              $1      'DateTime'
          1        SEND_VAL_EX                                              '2017-09-20'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $1
   25     4        INIT_FCALL                                               'var_dump'
          5        INIT_FCALL                                               'getdates'
          6        SEND_VAR                                                 !0
          7        DO_FCALL                                      0  $4      
          8        SEND_VAR                                                 $4
          9        DO_ICALL                                                 
   27    10        NEW                                              $6      'DateTime'
         11        SEND_VAL_EX                                              '2017-09-19'
         12        DO_FCALL                                      0          
         13        ASSIGN                                                   !0, $6
   28    14        INIT_FCALL                                               'var_dump'
         15        INIT_FCALL                                               'getdates'
         16        SEND_VAR                                                 !0
         17        DO_FCALL                                      0  $9      
         18        SEND_VAR                                                 $9
         19        DO_ICALL                                                 
         20      > RETURN                                                   1

Function getdates:
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 = 62) Position 1 = -2
Branch analysis from position: 18
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 34
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 34
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vBOkI
function name:  getDates
number of ops:  35
compiled vars:  !0 = $date, !1 = $nextMonth, !2 = $lastMonth
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
    4     1        INIT_METHOD_CALL                                         !0, 'format'
          2        SEND_VAL_EX                                              'd'
          3        DO_FCALL                                      0  $3      
          4        IS_EQUAL                                                 $3, 20
          5      > JMPZ                                                     ~4, ->18
    5     6    >   CLONE                                            ~5      !0
          7        ASSIGN                                                   !1, ~5
    6     8        INIT_METHOD_CALL                                         !1, 'modify'
          9        SEND_VAL_EX                                              '-1+day'
         10        DO_FCALL                                      0          
    7    11        INIT_METHOD_CALL                                         !1, 'modify'
         12        SEND_VAL_EX                                              '%2B1+month'
         13        DO_FCALL                                      0          
    9    14        INIT_ARRAY                                       ~9      !0, 'start'
   10    15        ADD_ARRAY_ELEMENT                                ~9      !1, 'end'
         16      > RETURN                                                   ~9
         17*       JMP                                                      ->34
   12    18    >   INIT_METHOD_CALL                                         !0, 'format'
         19        SEND_VAL_EX                                              'd'
         20        DO_FCALL                                      0  $10     
         21        IS_EQUAL                                                 $10, 19
         22      > JMPZ                                                     ~11, ->34
   13    23    >   CLONE                                            ~12     !0
         24        ASSIGN                                                   !2, ~12
   14    25        INIT_METHOD_CALL                                         !2, 'modify'
         26        SEND_VAL_EX                                              '%2B1+day'
         27        DO_FCALL                                      0          
   15    28        INIT_METHOD_CALL                                         !2, 'modify'
         29        SEND_VAL_EX                                              '-1+month'
         30        DO_FCALL                                      0          
   17    31        INIT_ARRAY                                       ~16     !2, 'start'
   18    32        ADD_ARRAY_ELEMENT                                ~16     !0, 'end'
         33      > RETURN                                                   ~16
   21    34    > > RETURN                                                   null

End of function getdates

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
147.67 ms | 1403 KiB | 17 Q