3v4l.org

run code in 300+ PHP versions simultaneously
<?php $configArray = array( 'nominal' => array( 'class' => 'sales/quote_address_total_nominal', 'before' => array( 0 => 'subtotal', ), 'renderer' => 'checkout/total_nominal', 'after' => array(), '_code' => 'nominal', ), 'subtotal' => array( 'class' => 'sales/quote_address_total_subtotal', 'after' => array( 0 => 'nominal', ), 'before' => array( 0 => 'grand_total', ), 'renderer' => 'tax/checkout_subtotal', 'admin_renderer' => 'adminhtml/sales_order_create_totals_subtotal', '_code' => 'subtotal', ), 'shipping' => array( 'class' => 'sales/quote_address_total_shipping', 'after' => array( 0 => 'subtotal', 1 => 'freeshipping', 2 => 'tax_subtotal', ), 'before' => array( 0 => 'grand_total', ), 'renderer' => 'tax/checkout_shipping', 'admin_renderer' => 'adminhtml/sales_order_create_totals_shipping', '_code' => 'shipping', ), 'grand_total' => array( 'class' => 'sales/quote_address_total_grand', 'after' => array( 0 => 'subtotal', ), 'renderer' => 'tax/checkout_grandtotal', 'admin_renderer' => 'adminhtml/sales_order_create_totals_grandtotal', 'before' => array(), '_code' => 'grand_total', ), 'msrp' => array( 'class' => 'sales/quote_address_total_msrp', 'before' => array(), 'after' => array(), '_code' => 'msrp', ), 'freeshipping' => array( 'class' => 'salesrule/quote_freeshipping', 'after' => array( 0 => 'subtotal', ), 'before' => array( 0 => 'tax_subtotal', 1 => 'shipping', ), '_code' => 'freeshipping', ), 'discount' => array( 'class' => 'salesrule/quote_discount', 'after' => array( 0 => 'subtotal', 1 => 'shipping', ), 'before' => array( 0 => 'grand_total', ), 'admin_renderer' => 'adminhtml/sales_order_create_totals_discount', 'renderer' => 'amrules/checkout_discount', '_code' => 'discount', ), 'tax_subtotal' => array( 'class' => 'tax/sales_total_quote_subtotal', 'after' => array( 0 => 'freeshipping', ), 'before' => array( 0 => 'tax', 1 => 'discount', ), '_code' => 'tax_subtotal', ), 'tax_shipping' => array( 'class' => 'tax/sales_total_quote_shipping', 'after' => array( 0 => 'shipping', 1 => 'tax_subtotal', ), 'before' => array( 0 => 'tax', 1 => 'discount', ), '_code' => 'tax_shipping', ), 'tax' => array( 'class' => 'tax/sales_total_quote_tax', 'after' => array( 0 => 'subtotal', 1 => 'shipping', 2 => 'discount', ), 'before' => array( 0 => 'grand_total', ), 'renderer' => 'tax/checkout_tax', 'admin_renderer' => 'adminhtml/sales_order_create_totals_tax', '_code' => 'tax', ), 'vaimo_klarna_fee' => array( 'class' => 'klarna/quote_total', 'after' => array( 0 => 'subtotal', 1 => 'discount', ), 'before' => array( 0 => 'shipping', 1 => 'tax', 2 => 'grand_total', ), 'renderer' => 'klarna/checkout_fee', '_code' => 'vaimo_klarna_fee', ), 'vaimo_klarna_fee_tax' => array( 'class' => 'klarna/quote_tax', 'after' => array( 0 => 'subtotal', 1 => 'discount', 2 => 'shipping', 3 => 'tax', ), 'before' => array( 0 => 'grand_total', ), '_code' => 'vaimo_klarna_fee_tax', ), ); function compareTotals($a, $b) { $aCode = $a['_code']; $bCode = $b['_code']; if (in_array($aCode, $b['after']) || in_array($bCode, $a['before'])) { $res = -1; } elseif (in_array($bCode, $a['after']) || in_array($aCode, $b['before'])) { $res = 1; } else { $res = 0; } return $res; } reset($configArray); $element = current($configArray); foreach ($configArray as $code => $data) { foreach ($data['before'] as $beforeCode) { if (!isset($configArray[$beforeCode])) { continue; } $configArray[$code]['before'] = array_unique(array_merge( $configArray[$code]['before'], $configArray[$beforeCode]['before'] )); $configArray[$beforeCode]['after'] = array_merge( $configArray[$beforeCode]['after'], array($code), $data['after'] ); $configArray[$beforeCode]['after'] = array_unique($configArray[$beforeCode]['after']); } foreach ($data['after'] as $afterCode) { if (!isset($configArray[$afterCode])) { continue; } $configArray[$code]['after'] = array_unique(array_merge( $configArray[$code]['after'], $configArray[$afterCode]['after'] )); $configArray[$afterCode]['before'] = array_merge( $configArray[$afterCode]['before'], array($code), $data['before'] ); $configArray[$afterCode]['before'] = array_unique($configArray[$afterCode]['before']); } } uasort($configArray, 'compareTotals'); print_r($configArray);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 98
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 98
Branch analysis from position: 10
2 jumps found. (Code = 77) Position 1 = 13, Position 2 = 53
Branch analysis from position: 13
2 jumps found. (Code = 78) Position 1 = 14, Position 2 = 53
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 18
Branch analysis from position: 17
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 = 13
Branch analysis from position: 13
Branch analysis from position: 53
2 jumps found. (Code = 77) Position 1 = 56, Position 2 = 96
Branch analysis from position: 56
2 jumps found. (Code = 78) Position 1 = 57, Position 2 = 96
Branch analysis from position: 57
2 jumps found. (Code = 43) Position 1 = 60, Position 2 = 61
Branch analysis from position: 60
1 jumps found. (Code = 42) Position 1 = 56
Branch analysis from position: 56
Branch analysis from position: 61
1 jumps found. (Code = 42) Position 1 = 56
Branch analysis from position: 56
Branch analysis from position: 96
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 96
Branch analysis from position: 53
Branch analysis from position: 98
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 98
filename:       /in/nUor4
function name:  (null)
number of ops:  107
compiled vars:  !0 = $configArray, !1 = $element, !2 = $data, !3 = $code, !4 = $beforeCode, !5 = $afterCode
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
  194     1        INIT_FCALL                                               'reset'
          2        SEND_REF                                                 !0
          3        DO_ICALL                                                 
  195     4        INIT_FCALL                                               'current'
          5        SEND_VAR                                                 !0
          6        DO_ICALL                                         $8      
          7        ASSIGN                                                   !1, $8
  196     8      > FE_RESET_R                                       $10     !0, ->98
          9    > > FE_FETCH_R                                       ~11     $10, !2, ->98
         10    >   ASSIGN                                                   !3, ~11
  197    11        FETCH_DIM_R                                      ~13     !2, 'before'
         12      > FE_RESET_R                                       $14     ~13, ->53
         13    > > FE_FETCH_R                                               $14, !4, ->53
  198    14    >   ISSET_ISEMPTY_DIM_OBJ                         0  ~15     !0, !4
         15        BOOL_NOT                                         ~16     ~15
         16      > JMPZ                                                     ~16, ->18
  199    17    > > JMP                                                      ->13
  201    18    >   INIT_FCALL                                               'array_unique'
         19        INIT_FCALL                                               'array_merge'
  202    20        FETCH_DIM_R                                      ~19     !0, !3
         21        FETCH_DIM_R                                      ~20     ~19, 'before'
         22        SEND_VAL                                                 ~20
         23        FETCH_DIM_R                                      ~21     !0, !4
         24        FETCH_DIM_R                                      ~22     ~21, 'before'
         25        SEND_VAL                                                 ~22
         26        DO_ICALL                                         $23     
         27        SEND_VAR                                                 $23
         28        DO_ICALL                                         $24     
  201    29        FETCH_DIM_W                                      $17     !0, !3
         30        ASSIGN_DIM                                               $17, 'before'
  202    31        OP_DATA                                                  $24
  204    32        INIT_FCALL                                               'array_merge'
  205    33        FETCH_DIM_R                                      ~27     !0, !4
         34        FETCH_DIM_R                                      ~28     ~27, 'after'
         35        SEND_VAL                                                 ~28
         36        INIT_ARRAY                                       ~29     !3
         37        SEND_VAL                                                 ~29
         38        FETCH_DIM_R                                      ~30     !2, 'after'
         39        SEND_VAL                                                 ~30
         40        DO_ICALL                                         $31     
  204    41        FETCH_DIM_W                                      $25     !0, !4
         42        ASSIGN_DIM                                               $25, 'after'
  205    43        OP_DATA                                                  $31
  207    44        INIT_FCALL                                               'array_unique'
         45        FETCH_DIM_R                                      ~34     !0, !4
         46        FETCH_DIM_R                                      ~35     ~34, 'after'
         47        SEND_VAL                                                 ~35
         48        DO_ICALL                                         $36     
         49        FETCH_DIM_W                                      $32     !0, !4
         50        ASSIGN_DIM                                               $32, 'after'
         51        OP_DATA                                                  $36
  197    52      > JMP                                                      ->13
         53    >   FE_FREE                                                  $14
  209    54        FETCH_DIM_R                                      ~37     !2, 'after'
         55      > FE_RESET_R                                       $38     ~37, ->96
         56    > > FE_FETCH_R                                               $38, !5, ->96
  210    57    >   ISSET_ISEMPTY_DIM_OBJ                         0  ~39     !0, !5
         58        BOOL_NOT                                         ~40     ~39
         59      > JMPZ                                                     ~40, ->61
  211    60    > > JMP                                                      ->56
  213    61    >   INIT_FCALL                                               'array_unique'
         62        INIT_FCALL                                               'array_merge'
  214    63        FETCH_DIM_R                                      ~43     !0, !3
         64        FETCH_DIM_R                                      ~44     ~43, 'after'
         65        SEND_VAL                                                 ~44
         66        FETCH_DIM_R                                      ~45     !0, !5
         67        FETCH_DIM_R                                      ~46     ~45, 'after'
         68        SEND_VAL                                                 ~46
         69        DO_ICALL                                         $47     
         70        SEND_VAR                                                 $47
         71        DO_ICALL                                         $48     
  213    72        FETCH_DIM_W                                      $41     !0, !3
         73        ASSIGN_DIM                                               $41, 'after'
  214    74        OP_DATA                                                  $48
  216    75        INIT_FCALL                                               'array_merge'
  217    76        FETCH_DIM_R                                      ~51     !0, !5
         77        FETCH_DIM_R                                      ~52     ~51, 'before'
         78        SEND_VAL                                                 ~52
         79        INIT_ARRAY                                       ~53     !3
         80        SEND_VAL                                                 ~53
         81        FETCH_DIM_R                                      ~54     !2, 'before'
         82        SEND_VAL                                                 ~54
         83        DO_ICALL                                         $55     
  216    84        FETCH_DIM_W                                      $49     !0, !5
         85        ASSIGN_DIM                                               $49, 'before'
  217    86        OP_DATA                                                  $55
  219    87        INIT_FCALL                                               'array_unique'
         88        FETCH_DIM_R                                      ~58     !0, !5
         89        FETCH_DIM_R                                      ~59     ~58, 'before'
         90        SEND_VAL                                                 ~59
         91        DO_ICALL                                         $60     
         92        FETCH_DIM_W                                      $56     !0, !5
         93        ASSIGN_DIM                                               $56, 'before'
         94        OP_DATA                                                  $60
  209    95      > JMP                                                      ->56
         96    >   FE_FREE                                                  $38
  196    97      > JMP                                                      ->9
         98    >   FE_FREE                                                  $10
  222    99        INIT_FCALL                                               'uasort'
        100        SEND_REF                                                 !0
        101        SEND_VAL                                                 'compareTotals'
        102        DO_ICALL                                                 
  224   103        INIT_FCALL                                               'print_r'
        104        SEND_VAR                                                 !0
        105        DO_ICALL                                                 
        106      > RETURN                                                   1

Function comparetotals:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 12, Position 2 = 18
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 21
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 37
Branch analysis from position: 37
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 21
2 jumps found. (Code = 47) Position 1 = 27, Position 2 = 33
Branch analysis from position: 27
2 jumps found. (Code = 43) Position 1 = 34, Position 2 = 36
Branch analysis from position: 34
1 jumps found. (Code = 42) Position 1 = 37
Branch analysis from position: 37
Branch analysis from position: 36
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 33
Branch analysis from position: 18
filename:       /in/nUor4
function name:  compareTotals
number of ops:  39
compiled vars:  !0 = $a, !1 = $b, !2 = $aCode, !3 = $bCode, !4 = $res
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  180     0  E >   RECV                                             !0      
          1        RECV                                             !1      
  182     2        FETCH_DIM_R                                      ~5      !0, '_code'
          3        ASSIGN                                                   !2, ~5
  183     4        FETCH_DIM_R                                      ~7      !1, '_code'
          5        ASSIGN                                                   !3, ~7
  184     6        INIT_FCALL                                               'in_array'
          7        SEND_VAR                                                 !2
          8        FETCH_DIM_R                                      ~9      !1, 'after'
          9        SEND_VAL                                                 ~9
         10        DO_ICALL                                         $10     
         11      > JMPNZ_EX                                         ~11     $10, ->18
         12    >   INIT_FCALL                                               'in_array'
         13        SEND_VAR                                                 !3
         14        FETCH_DIM_R                                      ~12     !0, 'before'
         15        SEND_VAL                                                 ~12
         16        DO_ICALL                                         $13     
         17        BOOL                                             ~11     $13
         18    > > JMPZ                                                     ~11, ->21
  185    19    >   ASSIGN                                                   !4, -1
         20      > JMP                                                      ->37
  186    21    >   INIT_FCALL                                               'in_array'
         22        SEND_VAR                                                 !3
         23        FETCH_DIM_R                                      ~15     !0, 'after'
         24        SEND_VAL                                                 ~15
         25        DO_ICALL                                         $16     
         26      > JMPNZ_EX                                         ~17     $16, ->33
         27    >   INIT_FCALL                                               'in_array'
         28        SEND_VAR                                                 !2
         29        FETCH_DIM_R                                      ~18     !1, 'before'
         30        SEND_VAL                                                 ~18
         31        DO_ICALL                                         $19     
         32        BOOL                                             ~17     $19
         33    > > JMPZ                                                     ~17, ->36
  187    34    >   ASSIGN                                                   !4, 1
         35      > JMP                                                      ->37
  189    36    >   ASSIGN                                                   !4, 0
  191    37    > > RETURN                                                   !4
  192    38*     > RETURN                                                   null

End of function comparetotals

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
161.44 ms | 1400 KiB | 27 Q