3v4l.org

run code in 300+ PHP versions simultaneously
<?php $configArray = json_decode('{"nominal":{"class":"sales\/quote_address_total_nominal","before":["subtotal"],"renderer":"checkout\/total_nominal","after":[],"_code":"nominal"},"subtotal":{"class":"sales\/quote_address_total_subtotal","after":["nominal"],"before":["grand_total"],"renderer":"tax\/checkout_subtotal","admin_renderer":"adminhtml\/sales_order_create_totals_subtotal","_code":"subtotal"},"shipping":{"class":"sales\/quote_address_total_shipping","after":["subtotal","freeshipping","tax_subtotal"],"before":["grand_total"],"renderer":"tax\/checkout_shipping","admin_renderer":"adminhtml\/sales_order_create_totals_shipping","_code":"shipping"},"grand_total":{"class":"sales\/quote_address_total_grand","after":["subtotal"],"renderer":"tax\/checkout_grandtotal","admin_renderer":"adminhtml\/sales_order_create_totals_grandtotal","before":[],"_code":"grand_total"},"msrp":{"class":"sales\/quote_address_total_msrp","before":[],"after":[],"_code":"msrp"},"freeshipping":{"class":"salesrule\/quote_freeshipping","after":["subtotal"],"before":["tax_subtotal","shipping"],"_code":"freeshipping"},"discount":{"class":"salesrule\/quote_discount","after":["subtotal","shipping"],"before":["grand_total"],"renderer":"tax\/checkout_discount","admin_renderer":"adminhtml\/sales_order_create_totals_discount","_code":"discount"},"tax_subtotal":{"class":"tax\/sales_total_quote_subtotal","after":["freeshipping"],"before":["tax","discount"],"_code":"tax_subtotal"},"tax_shipping":{"class":"tax\/sales_total_quote_shipping","after":["shipping","tax_subtotal"],"before":["tax","discount"],"_code":"tax_shipping"},"tax":{"class":"tax\/sales_total_quote_tax","after":["subtotal","shipping","discount"],"before":["grand_total"],"renderer":"tax\/checkout_tax","admin_renderer":"adminhtml\/sales_order_create_totals_tax","_code":"tax"},"weee":{"class":"weee\/total_quote_weee","after":["subtotal","tax_subtotal"],"before":["shipping","tax","discount"],"_code":"weee"}}', true); 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, function($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; }); print_r($configArray);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 95
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 95
Branch analysis from position: 7
2 jumps found. (Code = 77) Position 1 = 10, Position 2 = 50
Branch analysis from position: 10
2 jumps found. (Code = 78) Position 1 = 11, Position 2 = 50
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 15
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 15
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 50
2 jumps found. (Code = 77) Position 1 = 53, Position 2 = 93
Branch analysis from position: 53
2 jumps found. (Code = 78) Position 1 = 54, Position 2 = 93
Branch analysis from position: 54
2 jumps found. (Code = 43) Position 1 = 57, Position 2 = 58
Branch analysis from position: 57
1 jumps found. (Code = 42) Position 1 = 53
Branch analysis from position: 53
Branch analysis from position: 58
1 jumps found. (Code = 42) Position 1 = 53
Branch analysis from position: 53
Branch analysis from position: 93
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 93
Branch analysis from position: 50
Branch analysis from position: 95
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 95
filename:       /in/H4dtT
function name:  (null)
number of ops:  105
compiled vars:  !0 = $configArray, !1 = $data, !2 = $code, !3 = $beforeCode, !4 = $afterCode
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   INIT_FCALL                                               'json_decode'
          1        SEND_VAL                                                 '%7B%22nominal%22%3A%7B%22class%22%3A%22sales%5C%2Fquote_address_total_nominal%22%2C%22before%22%3A%5B%22subtotal%22%5D%2C%22renderer%22%3A%22checkout%5C%2Ftotal_nominal%22%2C%22after%22%3A%5B%5D%2C%22_code%22%3A%22nominal%22%7D%2C%22subtotal%22%3A%7B%22class%22%3A%22sales%5C%2Fquote_address_total_subtotal%22%2C%22after%22%3A%5B%22nominal%22%5D%2C%22before%22%3A%5B%22grand_total%22%5D%2C%22renderer%22%3A%22tax%5C%2Fcheckout_subtotal%22%2C%22admin_renderer%22%3A%22adminhtml%5C%2Fsales_order_create_totals_subtotal%22%2C%22_code%22%3A%22subtotal%22%7D%2C%22shipping%22%3A%7B%22class%22%3A%22sales%5C%2Fquote_address_total_shipping%22%2C%22after%22%3A%5B%22subtotal%22%2C%22freeshipping%22%2C%22tax_subtotal%22%5D%2C%22before%22%3A%5B%22grand_total%22%5D%2C%22renderer%22%3A%22tax%5C%2Fcheckout_shipping%22%2C%22admin_renderer%22%3A%22adminhtml%5C%2Fsales_order_create_totals_shipping%22%2C%22_code%22%3A%22shipping%22%7D%2C%22grand_total%22%3A%7B%22class%22%3A%22sales%5C%2Fquote_address_total_grand%22%2C%22after%22%3A%5B%22subtotal%22%5D%2C%22renderer%22%3A%22tax%5C%2Fcheckout_grandtotal%22%2C%22admin_renderer%22%3A%22adminhtml%5C%2Fsales_order_create_totals_grandtotal%22%2C%22before%22%3A%5B%5D%2C%22_code%22%3A%22grand_total%22%7D%2C%22msrp%22%3A%7B%22class%22%3A%22sales%5C%2Fquote_address_total_msrp%22%2C%22before%22%3A%5B%5D%2C%22after%22%3A%5B%5D%2C%22_code%22%3A%22msrp%22%7D%2C%22freeshipping%22%3A%7B%22class%22%3A%22salesrule%5C%2Fquote_freeshipping%22%2C%22after%22%3A%5B%22subtotal%22%5D%2C%22before%22%3A%5B%22tax_subtotal%22%2C%22shipping%22%5D%2C%22_code%22%3A%22freeshipping%22%7D%2C%22discount%22%3A%7B%22class%22%3A%22salesrule%5C%2Fquote_discount%22%2C%22after%22%3A%5B%22subtotal%22%2C%22shipping%22%5D%2C%22before%22%3A%5B%22grand_total%22%5D%2C%22renderer%22%3A%22tax%5C%2Fcheckout_discount%22%2C%22admin_renderer%22%3A%22adminhtml%5C%2Fsales_order_create_totals_discount%22%2C%22_code%22%3A%22discount%22%7D%2C%22tax_subtotal%22%3A%7B%22class%22%3A%22tax%5C%2Fsales_total_quote_subtotal%22%2C%22after%22%3A%5B%22freeshipping%22%5D%2C%22before%22%3A%5B%22tax%22%2C%22discount%22%5D%2C%22_code%22%3A%22tax_subtotal%22%7D%2C%22tax_shipping%22%3A%7B%22class%22%3A%22tax%5C%2Fsales_total_quote_shipping%22%2C%22after%22%3A%5B%22shipping%22%2C%22tax_subtotal%22%5D%2C%22before%22%3A%5B%22tax%22%2C%22discount%22%5D%2C%22_code%22%3A%22tax_shipping%22%7D%2C%22tax%22%3A%7B%22class%22%3A%22tax%5C%2Fsales_total_quote_tax%22%2C%22after%22%3A%5B%22subtotal%22%2C%22shipping%22%2C%22discount%22%5D%2C%22before%22%3A%5B%22grand_total%22%5D%2C%22renderer%22%3A%22tax%5C%2Fcheckout_tax%22%2C%22admin_renderer%22%3A%22adminhtml%5C%2Fsales_order_create_totals_tax%22%2C%22_code%22%3A%22tax%22%7D%2C%22weee%22%3A%7B%22class%22%3A%22weee%5C%2Ftotal_quote_weee%22%2C%22after%22%3A%5B%22subtotal%22%2C%22tax_subtotal%22%5D%2C%22before%22%3A%5B%22shipping%22%2C%22tax%22%2C%22discount%22%5D%2C%22_code%22%3A%22weee%22%7D%7D'
          2        SEND_VAL                                                 <true>
          3        DO_ICALL                                         $5      
          4        ASSIGN                                                   !0, $5
    5     5      > FE_RESET_R                                       $7      !0, ->95
          6    > > FE_FETCH_R                                       ~8      $7, !1, ->95
          7    >   ASSIGN                                                   !2, ~8
    6     8        FETCH_DIM_R                                      ~10     !1, 'before'
          9      > FE_RESET_R                                       $11     ~10, ->50
         10    > > FE_FETCH_R                                               $11, !3, ->50
    7    11    >   ISSET_ISEMPTY_DIM_OBJ                         0  ~12     !0, !3
         12        BOOL_NOT                                         ~13     ~12
         13      > JMPZ                                                     ~13, ->15
    8    14    > > JMP                                                      ->10
   10    15    >   INIT_FCALL                                               'array_unique'
         16        INIT_FCALL                                               'array_merge'
   11    17        FETCH_DIM_R                                      ~16     !0, !2
         18        FETCH_DIM_R                                      ~17     ~16, 'before'
         19        SEND_VAL                                                 ~17
         20        FETCH_DIM_R                                      ~18     !0, !3
         21        FETCH_DIM_R                                      ~19     ~18, 'before'
         22        SEND_VAL                                                 ~19
         23        DO_ICALL                                         $20     
         24        SEND_VAR                                                 $20
         25        DO_ICALL                                         $21     
   10    26        FETCH_DIM_W                                      $14     !0, !2
         27        ASSIGN_DIM                                               $14, 'before'
   11    28        OP_DATA                                                  $21
   13    29        INIT_FCALL                                               'array_merge'
   14    30        FETCH_DIM_R                                      ~24     !0, !3
         31        FETCH_DIM_R                                      ~25     ~24, 'after'
         32        SEND_VAL                                                 ~25
         33        INIT_ARRAY                                       ~26     !2
         34        SEND_VAL                                                 ~26
         35        FETCH_DIM_R                                      ~27     !1, 'after'
         36        SEND_VAL                                                 ~27
         37        DO_ICALL                                         $28     
   13    38        FETCH_DIM_W                                      $22     !0, !3
         39        ASSIGN_DIM                                               $22, 'after'
   14    40        OP_DATA                                                  $28
   16    41        INIT_FCALL                                               'array_unique'
         42        FETCH_DIM_R                                      ~31     !0, !3
         43        FETCH_DIM_R                                      ~32     ~31, 'after'
         44        SEND_VAL                                                 ~32
         45        DO_ICALL                                         $33     
         46        FETCH_DIM_W                                      $29     !0, !3
         47        ASSIGN_DIM                                               $29, 'after'
         48        OP_DATA                                                  $33
    6    49      > JMP                                                      ->10
         50    >   FE_FREE                                                  $11
   18    51        FETCH_DIM_R                                      ~34     !1, 'after'
         52      > FE_RESET_R                                       $35     ~34, ->93
         53    > > FE_FETCH_R                                               $35, !4, ->93
   19    54    >   ISSET_ISEMPTY_DIM_OBJ                         0  ~36     !0, !4
         55        BOOL_NOT                                         ~37     ~36
         56      > JMPZ                                                     ~37, ->58
   20    57    > > JMP                                                      ->53
   22    58    >   INIT_FCALL                                               'array_unique'
         59        INIT_FCALL                                               'array_merge'
   23    60        FETCH_DIM_R                                      ~40     !0, !2
         61        FETCH_DIM_R                                      ~41     ~40, 'after'
         62        SEND_VAL                                                 ~41
         63        FETCH_DIM_R                                      ~42     !0, !4
         64        FETCH_DIM_R                                      ~43     ~42, 'after'
         65        SEND_VAL                                                 ~43
         66        DO_ICALL                                         $44     
         67        SEND_VAR                                                 $44
         68        DO_ICALL                                         $45     
   22    69        FETCH_DIM_W                                      $38     !0, !2
         70        ASSIGN_DIM                                               $38, 'after'
   23    71        OP_DATA                                                  $45
   25    72        INIT_FCALL                                               'array_merge'
   26    73        FETCH_DIM_R                                      ~48     !0, !4
         74        FETCH_DIM_R                                      ~49     ~48, 'before'
         75        SEND_VAL                                                 ~49
         76        INIT_ARRAY                                       ~50     !2
         77        SEND_VAL                                                 ~50
         78        FETCH_DIM_R                                      ~51     !1, 'before'
         79        SEND_VAL                                                 ~51
         80        DO_ICALL                                         $52     
   25    81        FETCH_DIM_W                                      $46     !0, !4
         82        ASSIGN_DIM                                               $46, 'before'
   26    83        OP_DATA                                                  $52
   28    84        INIT_FCALL                                               'array_unique'
         85        FETCH_DIM_R                                      ~55     !0, !4
         86        FETCH_DIM_R                                      ~56     ~55, 'before'
         87        SEND_VAL                                                 ~56
         88        DO_ICALL                                         $57     
         89        FETCH_DIM_W                                      $53     !0, !4
         90        ASSIGN_DIM                                               $53, 'before'
         91        OP_DATA                                                  $57
   18    92      > JMP                                                      ->53
         93    >   FE_FREE                                                  $35
    5    94      > JMP                                                      ->6
         95    >   FE_FREE                                                  $7
   31    96        INIT_FCALL                                               'uasort'
         97        SEND_REF                                                 !0
         98        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FH4dtT%3A31%240'
   42    99        SEND_VAL                                                 ~58
        100        DO_ICALL                                                 
   44   101        INIT_FCALL                                               'print_r'
        102        SEND_VAR                                                 !0
        103        DO_ICALL                                                 
        104      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FH4dtT%3A31%240:
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/H4dtT
function name:  {closure}
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
-------------------------------------------------------------------------------------
   31     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   32     2        FETCH_DIM_R                                      ~5      !0, '_code'
          3        ASSIGN                                                   !2, ~5
   33     4        FETCH_DIM_R                                      ~7      !1, '_code'
          5        ASSIGN                                                   !3, ~7
   34     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
   35    19    >   ASSIGN                                                   !4, -1
         20      > JMP                                                      ->37
   36    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
   37    34    >   ASSIGN                                                   !4, 1
         35      > JMP                                                      ->37
   39    36    >   ASSIGN                                                   !4, 0
   41    37    > > RETURN                                                   !4
   42    38*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FH4dtT%3A31%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
172.79 ms | 1412 KiB | 25 Q