3v4l.org

run code in 300+ PHP versions simultaneously
<?php class MyInterval extends DateInterval { public static function instance(DateInterval $di) { $date = array_filter(array( 'Y' => $di->y, 'M' => $di->m, 'D' => $di->d, )); $time = array_filter(array( 'H' => $di->h, 'M' => $di->i, 'S' => $di->s, )); $specString = 'P'; foreach ($date as $key => $value) { $specString .= $value.$key; } if (count($time) > 0) { $specString .= 'T'; foreach ($time as $key => $value) { $specString .= $value.$key; } } return new static($specString === 'P' ? 'PT0S' : $specString); } } $diff = (new DateTime('yesterday'))->diff(new DateTime('tomorrow')); $myDiff = MyInterval::instance($diff); var_dump($myDiff);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/KdcYk
function name:  (null)
number of ops:  18
compiled vars:  !0 = $diff, !1 = $myDiff
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   36     0  E >   NEW                                              $2      'DateTime'
          1        SEND_VAL_EX                                              'yesterday'
          2        DO_FCALL                                      0          
          3        INIT_METHOD_CALL                                         $2, 'diff'
          4        NEW                                              $4      'DateTime'
          5        SEND_VAL_EX                                              'tomorrow'
          6        DO_FCALL                                      0          
          7        SEND_VAR_NO_REF_EX                                       $4
          8        DO_FCALL                                      0  $6      
          9        ASSIGN                                                   !0, $6
   38    10        INIT_STATIC_METHOD_CALL                                  'MyInterval', 'instance'
         11        SEND_VAR                                                 !0
         12        DO_FCALL                                      0  $8      
         13        ASSIGN                                                   !1, $8
   40    14        INIT_FCALL                                               'var_dump'
         15        SEND_VAR                                                 !1
         16        DO_ICALL                                                 
         17      > RETURN                                                   1

Class MyInterval:
Function instance:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 23, Position 2 = 28
Branch analysis from position: 23
2 jumps found. (Code = 78) Position 1 = 24, Position 2 = 28
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
Branch analysis from position: 28
2 jumps found. (Code = 43) Position 1 = 32, Position 2 = 40
Branch analysis from position: 32
2 jumps found. (Code = 77) Position 1 = 34, Position 2 = 39
Branch analysis from position: 34
2 jumps found. (Code = 78) Position 1 = 35, Position 2 = 39
Branch analysis from position: 35
1 jumps found. (Code = 42) Position 1 = 34
Branch analysis from position: 34
Branch analysis from position: 39
2 jumps found. (Code = 43) Position 1 = 43, Position 2 = 45
Branch analysis from position: 43
1 jumps found. (Code = 42) Position 1 = 46
Branch analysis from position: 46
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 45
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 39
Branch analysis from position: 40
Branch analysis from position: 28
filename:       /in/KdcYk
function name:  instance
number of ops:  50
compiled vars:  !0 = $di, !1 = $date, !2 = $time, !3 = $specString, !4 = $value, !5 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    5     0  E >   RECV                                             !0      
    7     1        INIT_FCALL                                               'array_filter'
    8     2        FETCH_OBJ_R                                      ~6      !0, 'y'
          3        INIT_ARRAY                                       ~7      ~6, 'Y'
    9     4        FETCH_OBJ_R                                      ~8      !0, 'm'
          5        ADD_ARRAY_ELEMENT                                ~7      ~8, 'M'
   10     6        FETCH_OBJ_R                                      ~9      !0, 'd'
          7        ADD_ARRAY_ELEMENT                                ~7      ~9, 'D'
          8        SEND_VAL                                                 ~7
          9        DO_ICALL                                         $10     
    7    10        ASSIGN                                                   !1, $10
   13    11        INIT_FCALL                                               'array_filter'
   14    12        FETCH_OBJ_R                                      ~12     !0, 'h'
         13        INIT_ARRAY                                       ~13     ~12, 'H'
   15    14        FETCH_OBJ_R                                      ~14     !0, 'i'
         15        ADD_ARRAY_ELEMENT                                ~13     ~14, 'M'
   16    16        FETCH_OBJ_R                                      ~15     !0, 's'
         17        ADD_ARRAY_ELEMENT                                ~13     ~15, 'S'
         18        SEND_VAL                                                 ~13
         19        DO_ICALL                                         $16     
   13    20        ASSIGN                                                   !2, $16
   19    21        ASSIGN                                                   !3, 'P'
   21    22      > FE_RESET_R                                       $19     !1, ->28
         23    > > FE_FETCH_R                                       ~20     $19, !4, ->28
         24    >   ASSIGN                                                   !5, ~20
   22    25        CONCAT                                           ~22     !4, !5
         26        ASSIGN_OP                                     8          !3, ~22
   21    27      > JMP                                                      ->23
         28    >   FE_FREE                                                  $19
   25    29        COUNT                                            ~24     !2
         30        IS_SMALLER                                               0, ~24
         31      > JMPZ                                                     ~25, ->40
   26    32    >   ASSIGN_OP                                     8          !3, 'T'
   27    33      > FE_RESET_R                                       $27     !2, ->39
         34    > > FE_FETCH_R                                       ~28     $27, !4, ->39
         35    >   ASSIGN                                                   !5, ~28
   28    36        CONCAT                                           ~30     !4, !5
         37        ASSIGN_OP                                     8          !3, ~30
   27    38      > JMP                                                      ->34
         39    >   FE_FREE                                                  $27
   32    40    >   NEW                          static              $32     
         41        IS_IDENTICAL                                             !3, 'P'
         42      > JMPZ                                                     ~33, ->45
         43    >   QM_ASSIGN                                        ~34     'PT0S'
         44      > JMP                                                      ->46
         45    >   QM_ASSIGN                                        ~34     !3
         46    >   SEND_VAL_EX                                              ~34
         47        DO_FCALL                                      0          
         48      > RETURN                                                   $32
   33    49*     > RETURN                                                   null

End of function instance

End of class MyInterval.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.6 ms | 1400 KiB | 17 Q