3v4l.org

run code in 500+ PHP versions simultaneously
<?php function getStartOfWeekDate($date = null) { if ($date instanceof \DateTime) { $date = clone $date; } else { // If date is falsy, it won't harm $date = new \DateTime($date); } return $date->modify('monday this week'); } echo getStartOfWeekDate(new \DateTime('2020-12-06'))->format('Y-m-d');
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/En702
function name:  (null)
number of ops:  11
compiled vars:  none
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   14     0  E >   INIT_FCALL                                                   'getstartofweekdate'
          1        NEW                                                  $0      'DateTime'
          2        SEND_VAL_EX                                                  '2020-12-06'
          3        DO_FCALL                                          0          
          4        SEND_VAR                                                     $0
          5        DO_FCALL                                          0  $2      
          6        INIT_METHOD_CALL                                             $2, 'format'
          7        SEND_VAL_EX                                                  'Y-m-d'
          8        DO_FCALL                                          0  $3      
          9        ECHO                                                         $3
         10      > RETURN                                                       1

Function getstartofweekdate:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 3, Position 2 = 6
Branch analysis from position: 3
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 6
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/En702
function name:  getStartOfWeekDate
number of ops:  15
compiled vars:  !0 = $date
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    2     0  E >   RECV_INIT                                            !0      null
    4     1        INSTANCEOF                                                   !0, 'DateTime'
          2      > JMPZ                                                         ~1, ->6
    5     3    >   CLONE                                                ~2      !0
          4        ASSIGN                                                       !0, ~2
    4     5      > JMP                                                          ->10
    8     6    >   NEW                                                  $4      'DateTime'
          7        SEND_VAR_EX                                                  !0
          8        DO_FCALL                                          0          
          9        ASSIGN                                                       !0, $4
   11    10    >   INIT_METHOD_CALL                                             !0, 'modify'
         11        SEND_VAL_EX                                                  'monday+this+week'
         12        DO_FCALL                                          0  $7      
         13      > RETURN                                                       $7
   12    14*     > RETURN                                                       null

End of function getstartofweekdate

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
166.34 ms | 3297 KiB | 13 Q