3v4l.org

run code in 300+ PHP versions simultaneously
<?php declare(strict_types=1); error_reporting(-1); ini_set('display_errors', 'On'); $helper = new class extends SplMinHeap { public function compare($a, $b): int { return ($b['current_qty'] + $b['add_qty']) <=> ($a['current_qty'] + $a['add_qty']); } }; $locations = [ ['location_name' => 'Toronto', 'current_qty' => 3, 'add_qty' => 0], ['location_name' => 'Mississauga', 'current_qty' => 7, 'add_qty' => 0], ['location_name' => 'London', 'current_qty' => 5, 'add_qty' => 0], ]; foreach ($locations as $entry) { $helper->insert($entry); } $qty = 10000; while ($qty-- > 0) { $min = $helper->extract(); $min['add_qty']++; $helper->insert($min); } print_r(iterator_to_array($helper));
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 13, Position 2 = 18
Branch analysis from position: 13
2 jumps found. (Code = 78) Position 1 = 14, Position 2 = 18
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
2 jumps found. (Code = 44) Position 1 = 32, Position 2 = 21
Branch analysis from position: 32
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
2 jumps found. (Code = 44) Position 1 = 32, Position 2 = 21
Branch analysis from position: 32
Branch analysis from position: 21
Branch analysis from position: 18
filename:       /in/nDOY8
function name:  (null)
number of ops:  39
compiled vars:  !0 = $helper, !1 = $locations, !2 = $entry, !3 = $qty, !4 = $min
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   INIT_FCALL                                               'error_reporting'
          1        SEND_VAL                                                 -1
          2        DO_ICALL                                                 
    5     3        INIT_FCALL                                               'ini_set'
          4        SEND_VAL                                                 'display_errors'
          5        SEND_VAL                                                 'On'
          6        DO_ICALL                                                 
    7     7        DECLARE_ANON_CLASS                               <unknown> 'splminheap'
          8        NEW                                              $8      $7
          9        DO_FCALL                                      0          
         10        ASSIGN                                                   !0, $8
   15    11        ASSIGN                                                   !1, <array>
   21    12      > FE_RESET_R                                       $12     !1, ->18
         13    > > FE_FETCH_R                                               $12, !2, ->18
   22    14    >   INIT_METHOD_CALL                                         !0, 'insert'
         15        SEND_VAR_EX                                              !2
         16        DO_FCALL                                      0          
   21    17      > JMP                                                      ->13
         18    >   FE_FREE                                                  $12
   25    19        ASSIGN                                                   !3, 10000
   26    20      > JMP                                                      ->29
   27    21    >   INIT_METHOD_CALL                                         !0, 'extract'
         22        DO_FCALL                                      0  $15     
         23        ASSIGN                                                   !4, $15
   28    24        FETCH_DIM_RW                                     $17     !4, 'add_qty'
         25        PRE_INC                                                  $17
   30    26        INIT_METHOD_CALL                                         !0, 'insert'
         27        SEND_VAR_EX                                              !4
         28        DO_FCALL                                      0          
   26    29    >   POST_DEC                                         ~20     !3
         30        IS_SMALLER                                               0, ~20
         31      > JMPNZ                                                    ~21, ->21
   33    32    >   INIT_FCALL                                               'print_r'
         33        INIT_FCALL                                               'iterator_to_array'
         34        SEND_VAR                                                 !0
         35        DO_ICALL                                         $22     
         36        SEND_VAR                                                 $22
         37        DO_ICALL                                                 
         38      > RETURN                                                   1

Class SplMinHeap@anonymous:
Function compare:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/nDOY8
function name:  compare
number of ops:  13
compiled vars:  !0 = $a, !1 = $b
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   11     2        FETCH_DIM_R                                      ~2      !1, 'current_qty'
          3        FETCH_DIM_R                                      ~3      !1, 'add_qty'
          4        ADD                                              ~4      ~2, ~3
          5        FETCH_DIM_R                                      ~5      !0, 'current_qty'
          6        FETCH_DIM_R                                      ~6      !0, 'add_qty'
          7        ADD                                              ~7      ~5, ~6
          8        SPACESHIP                                        ~8      ~4, ~7
          9        VERIFY_RETURN_TYPE                                       ~8
         10      > RETURN                                                   ~8
   12    11*       VERIFY_RETURN_TYPE                                       
         12*     > RETURN                                                   null

End of function compare

End of class SplMinHeap@anonymous.

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
147.87 ms | 1019 KiB | 17 Q