3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MyDateTime extends \DateTime { public function add(\DateInterval $interval) { $oldDay = (int)$this->format('d'); $this->setDate((int)$this->format('Y'), (int)$this->format('m'), 1); parent::add($interval); $maxDay = (int)$this->format('t'); if($oldDay > $maxDay){ $this->setDate((int)$this->format('Y'), (int)$this->format('m'), $maxDay); } else { $this->setDate((int)$this->format('Y'), (int)$this->format('m'), $oldDay); } return $this; } public function sub(\DateInterval $interval) { $oldDay = (int)$this->format('d'); $this->setDate((int)$this->format('Y'), (int)$this->format('m'), 1); parent::sub($interval); $maxDay = (int)$this->format('t'); if($oldDay > $maxDay){ $this->setDate((int)$this->format('Y'), (int)$this->format('m'), $maxDay); } else { $this->setDate((int)$this->format('Y'), (int)$this->format('m'), $oldDay); } return $this; } } $myDateTime = new MyDateTime('30th November 2012'); $interval = new \DateInterval('P3M'); var_dump($myDateTime->add($interval));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qegiF
function name:  (null)
number of ops:  15
compiled vars:  !0 = $myDateTime, !1 = $interval
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   33     0  E >   NEW                                              $2      'MyDateTime'
          1        SEND_VAL_EX                                              '30th+November+2012'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !0, $2
   34     4        NEW                                              $5      'DateInterval'
          5        SEND_VAL_EX                                              'P3M'
          6        DO_FCALL                                      0          
          7        ASSIGN                                                   !1, $5
   35     8        INIT_FCALL                                               'var_dump'
          9        INIT_METHOD_CALL                                         !0, 'add'
         10        SEND_VAR_EX                                              !1
         11        DO_FCALL                                      0  $8      
         12        SEND_VAR                                                 $8
         13        DO_ICALL                                                 
         14      > RETURN                                                   1

Class MyDateTime:
Function add:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 29, Position 2 = 43
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 56
Branch analysis from position: 56
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 43
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qegiF
function name:  add
number of ops:  59
compiled vars:  !0 = $interval, !1 = $oldDay, !2 = $maxDay
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   RECV                                             !0      
    6     1        INIT_METHOD_CALL                                         'format'
          2        SEND_VAL_EX                                              'd'
          3        DO_FCALL                                      0  $3      
          4        CAST                                          4  ~4      $3
          5        ASSIGN                                                   !1, ~4
    7     6        INIT_METHOD_CALL                                         'setDate'
          7        INIT_METHOD_CALL                                         'format'
          8        SEND_VAL_EX                                              'Y'
          9        DO_FCALL                                      0  $6      
         10        CAST                                          4  ~7      $6
         11        SEND_VAL_EX                                              ~7
         12        INIT_METHOD_CALL                                         'format'
         13        SEND_VAL_EX                                              'm'
         14        DO_FCALL                                      0  $8      
         15        CAST                                          4  ~9      $8
         16        SEND_VAL_EX                                              ~9
         17        SEND_VAL_EX                                              1
         18        DO_FCALL                                      0          
    8    19        INIT_STATIC_METHOD_CALL                                  'add'
         20        SEND_VAR_EX                                              !0
         21        DO_FCALL                                      0          
    9    22        INIT_METHOD_CALL                                         'format'
         23        SEND_VAL_EX                                              't'
         24        DO_FCALL                                      0  $12     
         25        CAST                                          4  ~13     $12
         26        ASSIGN                                                   !2, ~13
   10    27        IS_SMALLER                                               !2, !1
         28      > JMPZ                                                     ~15, ->43
   11    29    >   INIT_METHOD_CALL                                         'setDate'
         30        INIT_METHOD_CALL                                         'format'
         31        SEND_VAL_EX                                              'Y'
         32        DO_FCALL                                      0  $16     
         33        CAST                                          4  ~17     $16
         34        SEND_VAL_EX                                              ~17
         35        INIT_METHOD_CALL                                         'format'
         36        SEND_VAL_EX                                              'm'
         37        DO_FCALL                                      0  $18     
         38        CAST                                          4  ~19     $18
         39        SEND_VAL_EX                                              ~19
         40        SEND_VAR_EX                                              !2
         41        DO_FCALL                                      0          
         42      > JMP                                                      ->56
   13    43    >   INIT_METHOD_CALL                                         'setDate'
         44        INIT_METHOD_CALL                                         'format'
         45        SEND_VAL_EX                                              'Y'
         46        DO_FCALL                                      0  $21     
         47        CAST                                          4  ~22     $21
         48        SEND_VAL_EX                                              ~22
         49        INIT_METHOD_CALL                                         'format'
         50        SEND_VAL_EX                                              'm'
         51        DO_FCALL                                      0  $23     
         52        CAST                                          4  ~24     $23
         53        SEND_VAL_EX                                              ~24
         54        SEND_VAR_EX                                              !1
         55        DO_FCALL                                      0          
   15    56    >   FETCH_THIS                                       ~26     
         57      > RETURN                                                   ~26
   16    58*     > RETURN                                                   null

End of function add

Function sub:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 29, Position 2 = 43
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 56
Branch analysis from position: 56
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 43
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qegiF
function name:  sub
number of ops:  59
compiled vars:  !0 = $interval, !1 = $oldDay, !2 = $maxDay
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   18     0  E >   RECV                                             !0      
   20     1        INIT_METHOD_CALL                                         'format'
          2        SEND_VAL_EX                                              'd'
          3        DO_FCALL                                      0  $3      
          4        CAST                                          4  ~4      $3
          5        ASSIGN                                                   !1, ~4
   21     6        INIT_METHOD_CALL                                         'setDate'
          7        INIT_METHOD_CALL                                         'format'
          8        SEND_VAL_EX                                              'Y'
          9        DO_FCALL                                      0  $6      
         10        CAST                                          4  ~7      $6
         11        SEND_VAL_EX                                              ~7
         12        INIT_METHOD_CALL                                         'format'
         13        SEND_VAL_EX                                              'm'
         14        DO_FCALL                                      0  $8      
         15        CAST                                          4  ~9      $8
         16        SEND_VAL_EX                                              ~9
         17        SEND_VAL_EX                                              1
         18        DO_FCALL                                      0          
   22    19        INIT_STATIC_METHOD_CALL                                  'sub'
         20        SEND_VAR_EX                                              !0
         21        DO_FCALL                                      0          
   23    22        INIT_METHOD_CALL                                         'format'
         23        SEND_VAL_EX                                              't'
         24        DO_FCALL                                      0  $12     
         25        CAST                                          4  ~13     $12
         26        ASSIGN                                                   !2, ~13
   24    27        IS_SMALLER                                               !2, !1
         28      > JMPZ                                                     ~15, ->43
   25    29    >   INIT_METHOD_CALL                                         'setDate'
         30        INIT_METHOD_CALL                                         'format'
         31        SEND_VAL_EX                                              'Y'
         32        DO_FCALL                                      0  $16     
         33        CAST                                          4  ~17     $16
         34        SEND_VAL_EX                                              ~17
         35        INIT_METHOD_CALL                                         'format'
         36        SEND_VAL_EX                                              'm'
         37        DO_FCALL                                      0  $18     
         38        CAST                                          4  ~19     $18
         39        SEND_VAL_EX                                              ~19
         40        SEND_VAR_EX                                              !2
         41        DO_FCALL                                      0          
         42      > JMP                                                      ->56
   27    43    >   INIT_METHOD_CALL                                         'setDate'
         44        INIT_METHOD_CALL                                         'format'
         45        SEND_VAL_EX                                              'Y'
         46        DO_FCALL                                      0  $21     
         47        CAST                                          4  ~22     $21
         48        SEND_VAL_EX                                              ~22
         49        INIT_METHOD_CALL                                         'format'
         50        SEND_VAL_EX                                              'm'
         51        DO_FCALL                                      0  $23     
         52        CAST                                          4  ~24     $23
         53        SEND_VAL_EX                                              ~24
         54        SEND_VAR_EX                                              !1
         55        DO_FCALL                                      0          
   29    56    >   FETCH_THIS                                       ~26     
         57      > RETURN                                                   ~26
   30    58*     > RETURN                                                   null

End of function sub

End of class MyDateTime.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
172.82 ms | 1408 KiB | 15 Q