3v4l.org

run code in 300+ PHP versions simultaneously
<?php class InterestCalculator { private array $dailyInterest = []; private static int $interest = 89; public function calculateDailyInterest(string $start, string $end): array { $this->dailyInterest = array_fill(0, date_diff(date_create($start), date_create($end))->format('%a'), self::$interest); $total = array_sum($this->dailyInterest); array_walk($this->dailyInterest, function (int &$value, int $key): void { $value = ($this->dailyInterest[$key -1] ?? 0) + $value; }); return compact('total') + ['dailyInterest' => $this->dailyInterest]; } } print_r((new InterestCalculator)->calculateDailyInterest('2022-06-06', '2023-06-04'));

Abusive script

This script was stopped while abusing our resources

Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9mNln
function name:  (null)
number of ops:  10
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   21     0  E >   INIT_FCALL                                               'print_r'
          1        NEW                                              $0      'InterestCalculator'
          2        DO_FCALL                                      0          
          3        INIT_METHOD_CALL                                         $0, 'calculateDailyInterest'
          4        SEND_VAL_EX                                              '2022-06-06'
          5        SEND_VAL_EX                                              '2023-06-04'
          6        DO_FCALL                                      0  $2      
          7        SEND_VAR                                                 $2
          8        DO_ICALL                                                 
          9      > RETURN                                                   1

Class InterestCalculator:
Function calculatedailyinterest:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9mNln
function name:  calculateDailyInterest
number of ops:  44
compiled vars:  !0 = $start, !1 = $end, !2 = $total
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    8     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   10     2        INIT_FCALL                                               'array_fill'
          3        SEND_VAL                                                 0
          4        INIT_FCALL                                               'date_diff'
          5        INIT_FCALL                                               'date_create'
          6        SEND_VAR                                                 !0
          7        DO_ICALL                                         $4      
          8        SEND_VAR                                                 $4
          9        INIT_FCALL                                               'date_create'
         10        SEND_VAR                                                 !1
         11        DO_ICALL                                         $5      
         12        SEND_VAR                                                 $5
         13        DO_ICALL                                         $6      
         14        INIT_METHOD_CALL                                         $6, 'format'
         15        SEND_VAL_EX                                              '%25a'
         16        DO_FCALL                                      0  $7      
         17        SEND_VAR                                                 $7
         18        FETCH_STATIC_PROP_R          unknown             ~8      'interest'
         19        SEND_VAL                                                 ~8
         20        DO_ICALL                                         $9      
         21        ASSIGN_OBJ                                               'dailyInterest'
         22        OP_DATA                                                  $9
   11    23        INIT_FCALL                                               'array_sum'
         24        FETCH_OBJ_R                                      ~10     'dailyInterest'
         25        SEND_VAL                                                 ~10
         26        DO_ICALL                                         $11     
         27        ASSIGN                                                   !2, $11
   13    28        INIT_FCALL                                               'array_walk'
         29        FETCH_OBJ_W                                      $13     'dailyInterest'
         30        SEND_REF                                                 $13
         31        DECLARE_LAMBDA_FUNCTION                          ~14     [0]
   15    32        SEND_VAL                                                 ~14
   13    33        DO_ICALL                                                 
   17    34        INIT_FCALL                                               'compact'
         35        SEND_VAL                                                 'total'
         36        DO_ICALL                                         $16     
         37        FETCH_OBJ_R                                      ~17     'dailyInterest'
         38        INIT_ARRAY                                       ~18     ~17, 'dailyInterest'
         39        ADD                                              ~19     $16, ~18
         40        VERIFY_RETURN_TYPE                                       ~19
         41      > RETURN                                                   ~19
   18    42*       VERIFY_RETURN_TYPE                                       
         43*     > RETURN                                                   null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/9mNln
function name:  {closure}
number of ops:  11
compiled vars:  !0 = $value, !1 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   13     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   14     2        FETCH_THIS                                       $2      
          3        SUB                                              ~4      !1, 1
          4        FETCH_OBJ_IS                                     ~3      $2, 'dailyInterest'
          5        FETCH_DIM_IS                                     ~5      ~3, ~4
          6        COALESCE                                         ~6      ~5
          7        QM_ASSIGN                                        ~6      0
          8        ADD                                              ~7      ~6, !0
          9        ASSIGN                                                   !0, ~7
   15    10      > RETURN                                                   null

End of Dynamic Function 0

End of function calculatedailyinterest

End of class InterestCalculator.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.93 ms | 1022 KiB | 20 Q