3v4l.org

run code in 500+ PHP versions simultaneously
<?php $config = [ 'finishing' => [ 'attributes' => [ '167' => [ 'option' => '5020', 'values' => [ '5818' => '41004', ], ], '176' => [ 'option' => '5021', 'values' => [ '5774' => '41014', ], ], ], 'pattern' => [ 'attribute' => '177', 'new_attribute' => '295', ], 'left' => [ 'bundle' => '16712', 'bundle_options' => [ '335' => '335', ], 'grinded' => [ 'old_product' => '16649', 'patterns' => [ '5780' => [ 'product' => '45938', 'value' => '7289', 'selection' => '7279', ], ], ], ], 'right' => [ 'bundle' => '16713', 'bundle_options' => [ '339' => '339', ], 'grinded' => [ 'old_product' => '16649', 'patterns' => [ '5780' => [ 'product' => '45938', 'value' => '7289', 'selection' => '7303', ], ], ], ], ], ]; function migrate(array $request, array $config): array { $config = $config['finishing']; foreach (['left', 'right'] as $sideName) { $request = migrateSide( $request, $config, $config[$sideName] ); } return $request; } function migrateSide( array $request, array $config, array $side ): array { $bundleOptions = $request['bundle_option'] ?? []; $superAttributes = $request['super_attribute'] ?? []; foreach ($side['bundle_options'] as $oldOption => $newOption) { if (!isset($bundleOptions[$oldOption])) { continue; } $oldSelection = (string) $bundleOptions[$oldOption]; /* * Find super attributes belonging to this bundle option. * * Example: * * 16712-335-16649-176 => 5774 * ^^^ ^^^^^ * opt product */ $source = findSourceAttributes( $superAttributes, $oldOption, $oldSelection ); /* * No matching super attributes means this is not * a Grinded configuration. */ if ($source === null) { continue; } /* * Check whether the selected product is the old * Grinded product. */ if ( $source['selection_product'] !== $side['grinded']['old_product'] ) { continue; } $request = migrateGrinded( $request, $config, $side, $oldOption, $newOption, $source ); } return $request; } function findSourceAttributes( array $superAttributes, string $oldOption, string $oldSelection ): ?array { $result = [ 'bundle_product' => null, 'selection_product' => null, 'attributes' => [], 'keys' => [], ]; foreach ($superAttributes as $key => $value) { $parts = explode('-', (string) $key); /* * Ignore unrelated keys. * * A super_attribute key that contains "-" * but is malformed is considered an error only * if it looks like one of our bundle keys. */ if (count($parts) !== 4) { continue; } [ $bundleProduct, $option, $selectionProduct, $attributeId ] = $parts; if ($option !== $oldOption) { continue; } /* * We need the old selected product ID from the key. */ if ($result['selection_product'] === null) { $result['selection_product'] = $selectionProduct; } elseif ( $result['selection_product'] !== $selectionProduct ) { throw new RuntimeException( "Different selection products found for bundle option {$oldOption}" ); } if ($result['bundle_product'] === null) { $result['bundle_product'] = $bundleProduct; } elseif ( $result['bundle_product'] !== $bundleProduct ) { throw new RuntimeException( "Different bundle products found for bundle option {$oldOption}" ); } $result['attributes'][$attributeId] = (string) $value; $result['keys'][] = $key; } if ($result['selection_product'] === null) { return null; } return $result; } function migrateGrinded( array $request, array $config, array $side, string $oldOption, string $newOption, array $source ): array { $attributes = $source['attributes']; /* * --------------------------------------------------------- * 1. Get old groundsole pattern * --------------------------------------------------------- */ $patternAttribute = $config['pattern']['attribute']; if (!isset($attributes[$patternAttribute])) { throw new RuntimeException( "Missing pattern attribute {$patternAttribute} " . "for bundle option {$oldOption}" ); } $oldPattern = $attributes[$patternAttribute]; if (!isset($side['grinded']['patterns'][$oldPattern])) { throw new RuntimeException( "Unknown pattern {$oldPattern} " . "for bundle option {$oldOption}" ); } $pattern = $side['grinded']['patterns'][$oldPattern]; /* * --------------------------------------------------------- * 2. Validate all attributes that become custom options * --------------------------------------------------------- */ foreach ($config['attributes'] as $attributeId => $mapping) { if (!isset($attributes[$attributeId])) { throw new RuntimeException( "Missing attribute {$attributeId} " . "for bundle option {$oldOption}" ); } $oldValue = $attributes[$attributeId]; if (!isset($mapping['values'][$oldValue])) { throw new RuntimeException( "Unknown value {$oldValue} " . "for attribute {$attributeId}" ); } } /* * --------------------------------------------------------- * 3. Change bundle selection * --------------------------------------------------------- */ $request['bundle_option'][$newOption] = $pattern['selection']; if ($oldOption !== $newOption) { unset($request['bundle_option'][$oldOption]); } /* * --------------------------------------------------------- * 4. Remove old super attributes * --------------------------------------------------------- */ foreach ($source['keys'] as $key) { unset($request['super_attribute'][$key]); } /* * --------------------------------------------------------- * 5. Add new pattern_variant super attribute * * Example: * * 16712-335-45938-295 => 7289 * --------------------------------------------------------- */ $newSuperAttributeKey = sprintf( '%s-%s-%s-%s', $source['bundle_product'], $newOption, $pattern['product'], $config['pattern']['new_attribute'] ); $request['super_attribute'][$newSuperAttributeKey] = $pattern['value']; /* * --------------------------------------------------------- * 6. Convert old configurable attributes into * custom options * * Example: * * 16712_335_options: * { * "5020": "41004", * "5021": "41014" * } * --------------------------------------------------------- */ $customOptionKey = sprintf( '%s_%s_options', $source['bundle_product'], $newOption ); $options = $request[$customOptionKey] ?? []; foreach ($config['attributes'] as $attributeId => $mapping) { $oldValue = $attributes[$attributeId]; $options[$mapping['option']] = $mapping['values'][$oldValue]; } $request[$customOptionKey] = $options; return $request; } /* * ============================================================= * INPUT * ============================================================= * * Paste your initial JSON here. */ $inputJson = <<<'JSON' { "product": "16714", "selected_configurable_option": "", "related_product": "", "item": "16714", "form_key": "a5TW22FK2IX7OSib", "files": [], "milling_files": "1088", "images": { "left": { "product_id": "", "path": "" }, "right": { "product_id": "", "path": "" } }, "next_step": "", "back_step": "", "back_from_checkout": "", "grouped_bundle": [ "16712", "16713" ], "step_selected_bundle": [ "16712", "16713" ], "bundle_option": { "333": "5549", "334": "4148", "335": "4151", "337": "5550", "338": "4162", "339": "4165" }, "super_attribute": { "16712-333-18898-163": "5652", "16712-333-18898-162": "5917", "16712-334-16680-160": "5642", "16712-335-16649-176": "5774", "16712-335-16649-177": "5780", "16712-335-16649-167": "5818", "16713-337-18898-163": "5652", "16713-337-18898-162": "5917", "16713-338-16680-160": "5642", "16713-339-16649-176": "5774", "16713-339-16649-177": "5780", "16713-339-16649-167": "5818" }, "16712_333_options": { "2914": "", "2915": "29596" }, "16712_334_options": { "2910": "" }, "16712_335_options": { "2906": "" }, "16712_options": { "1403": "" }, "16713_337_options": { "2914": "", "2915": "29596" }, "16713_338_options": { "2910": "" }, "16713_339_options": { "2906": "" }, "16713_options": { "1404": "" } } JSON; /* * ============================================================= * RUN * ============================================================= */ try { $input = json_decode( $inputJson, true, 512, JSON_THROW_ON_ERROR ); $output = migrate($input, $config); echo json_encode( $output, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES ); } catch (Throwable $e) { echo json_encode( [ 'error' => $e->getMessage(), ], JSON_PRETTY_PRINT ); }
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Found catch point at position: 20
Branch analysis from position: 20
2 jumps found. (Code = 107) Position 1 = 21, Position 2 = -2
Branch analysis from position: 21
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/TE0WA
function name:  (null)
number of ops:  30
compiled vars:  !0 = $config, !1 = $inputJson, !2 = $input, !3 = $output, !4 = $e
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
  375     1        ASSIGN                                                       !1, '%7B%0A++%22product%22%3A+%2216714%22%2C%0A++%22selected_configurable_option%22%3A+%22%22%2C%0A++%22related_product%22%3A+%22%22%2C%0A++%22item%22%3A+%2216714%22%2C%0A++%22form_key%22%3A+%22a5TW22FK2IX7OSib%22%2C%0A++%22files%22%3A+%5B%5D%2C%0A++%22milling_files%22%3A+%221088%22%2C%0A++%22images%22%3A+%7B%0A++++%22left%22%3A+%7B%0A++++++%22product_id%22%3A+%22%22%2C%0A++++++%22path%22%3A+%22%22%0A++++%7D%2C%0A++++%22right%22%3A+%7B%0A++++++%22product_id%22%3A+%22%22%2C%0A++++++%22path%22%3A+%22%22%0A++++%7D%0A++%7D%2C%0A++%22next_step%22%3A+%22%22%2C%0A++%22back_step%22%3A+%22%22%2C%0A++%22back_from_checkout%22%3A+%22%22%2C%0A++%22grouped_bundle%22%3A+%5B%0A++++%2216712%22%2C%0A++++%2216713%22%0A++%5D%2C%0A++%22step_selected_bundle%22%3A+%5B%0A++++%2216712%22%2C%0A++++%2216713%22%0A++%5D%2C%0A++%22bundle_option%22%3A+%7B%0A++++%22333%22%3A+%225549%22%2C%0A++++%22334%22%3A+%224148%22%2C%0A++++%22335%22%3A+%224151%22%2C%0A++++%22337%22%3A+%225550%22%2C%0A++++%22338%22%3A+%224162%22%2C%0A++++%22339%22%3A+%224165%22+%0A++%7D%2C%0A++%22super_attribute%22%3A+%7B%0A++++%2216712-333-18898-163%22%3A+%225652%22%2C%0A++++%2216712-333-18898-162%22%3A+%225917%22%2C%0A++++%2216712-334-16680-160%22%3A+%225642%22%2C%0A++++%2216712-335-16649-176%22%3A+%225774%22%2C%0A++++%2216712-335-16649-177%22%3A+%225780%22%2C%0A++++%2216712-335-16649-167%22%3A+%225818%22%2C%0A++++%2216713-337-18898-163%22%3A+%225652%22%2C%0A++++%2216713-337-18898-162%22%3A+%225917%22%2C%0A++++%2216713-338-16680-160%22%3A+%225642%22%2C%0A++++%2216713-339-16649-176%22%3A+%225774%22%2C%0A++++%2216713-339-16649-177%22%3A+%225780%22%2C%0A++++%2216713-339-16649-167%22%3A+%225818%22+%0A++%7D%2C%0A++%2216712_333_options%22%3A+%7B%0A++++%222914%22%3A+%22%22%2C%0A++++%222915%22%3A+%2229596%22%0A++%7D%2C%0A++%2216712_334_options%22%3A+%7B%0A++++%222910%22%3A+%22%22%0A++%7D%2C%0A++%2216712_335_options%22%3A+%7B%0A++++%222906%22%3A+%22%22%0A++%7D%2C%0A++%2216712_options%22%3A+%7B%0A++++%221403%22%3A+%22%22%0A++%7D%2C%0A++%2216713_337_options%22%3A+%7B%0A++++%222914%22%3A+%22%22%2C%0A++++%222915%22%3A+%2229596%22%0A++%7D%2C%0A++%2216713_338_options%22%3A+%7B%0A++++%222910%22%3A+%22%22%0A++%7D%2C%0A++%2216713_339_options%22%3A+%7B%0A++++%222906%22%3A+%22%22%0A++%7D%2C%0A++%2216713_options%22%3A+%7B%0A++++%221404%22%3A+%22%22%0A++%7D%0A%7D'
  464     2        INIT_FCALL                                                   'json_decode'
  465     3        SEND_VAR                                                     !1
  466     4        SEND_VAL                                                     <true>
  467     5        SEND_VAL                                                     512
  468     6        SEND_VAL                                                     4194304
  464     7        DO_ICALL                                             $7      
          8        ASSIGN                                                       !2, $7
  471     9        INIT_FCALL                                                   'migrate'
         10        SEND_VAR                                                     !2
         11        SEND_VAR                                                     !0
         12        DO_FCALL                                          0  $9      
         13        ASSIGN                                                       !3, $9
  473    14        INIT_FCALL                                                   'json_encode'
  474    15        SEND_VAR                                                     !3
  475    16        SEND_VAL                                                     192
  473    17        DO_ICALL                                             $11     
  475    18        ECHO                                                         $11
         19      > JMP                                                          ->29
  478    20  E > > CATCH                                           last         'Throwable'
  480    21    >   INIT_FCALL                                                   'json_encode'
  482    22        INIT_METHOD_CALL                                             !4, 'getMessage'
         23        DO_FCALL                                          0  $12     
         24        INIT_ARRAY                                           ~13     $12, 'error'
         25        SEND_VAL                                                     ~13
  484    26        SEND_VAL                                                     128
  480    27        DO_ICALL                                             $14     
  484    28        ECHO                                                         $14
  486    29    > > RETURN                                                       1

Function migrate:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 15
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 15
Branch analysis from position: 6
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
filename:       /in/TE0WA
function name:  migrate
number of ops:  20
compiled vars:  !0 = $request, !1 = $config, !2 = $sideName
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   68     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
   70     2        FETCH_DIM_R                                          ~3      !1, 'finishing'
          3        ASSIGN                                                       !1, ~3
   72     4      > FE_RESET_R                                           $5      <array>, ->15
          5    > > FE_FETCH_R                                                   $5, !2, ->15
   73     6    >   INIT_FCALL_BY_NAME                                           'migrateSide'
   74     7        SEND_VAR_EX                                                  !0
          8        SEND_VAR_EX                                                  !1
          9        CHECK_FUNC_ARG                                               
   76    10        FETCH_DIM_FUNC_ARG                                   $6      !1, !2
         11        SEND_FUNC_ARG                                                $6
   73    12        DO_FCALL                                          0  $7      
         13        ASSIGN                                                       !0, $7
   72    14      > JMP                                                          ->5
         15    >   FE_FREE                                                      $5
   80    16        VERIFY_RETURN_TYPE                                           !0
         17      > RETURN                                                       !0
   81    18*       VERIFY_RETURN_TYPE                                           
         19*     > RETURN                                                       null

End of function migrate

Function migrateside:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 13, Position 2 = 47
Branch analysis from position: 13
2 jumps found. (Code = 78) Position 1 = 14, Position 2 = 47
Branch analysis from position: 14
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 19
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
Branch analysis from position: 19
2 jumps found. (Code = 43) Position 1 = 30, Position 2 = 31
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
Branch analysis from position: 31
2 jumps found. (Code = 43) Position 1 = 36, Position 2 = 37
Branch analysis from position: 36
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
Branch analysis from position: 37
1 jumps found. (Code = 42) Position 1 = 13
Branch analysis from position: 13
Branch analysis from position: 47
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 47
filename:       /in/TE0WA
function name:  migrateSide
number of ops:  52
compiled vars:  !0 = $request, !1 = $config, !2 = $side, !3 = $bundleOptions, !4 = $superAttributes, !5 = $newOption, !6 = $oldOption, !7 = $oldSelection, !8 = $source
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   85     0  E >   RECV                                                 !0      
   86     1        RECV                                                 !1      
   87     2        RECV                                                 !2      
   89     3        FETCH_DIM_IS                                         ~9      !0, 'bundle_option'
          4        COALESCE                                             ~10     ~9
          5        QM_ASSIGN                                            ~10     <array>
          6        ASSIGN                                                       !3, ~10
   90     7        FETCH_DIM_IS                                         ~12     !0, 'super_attribute'
          8        COALESCE                                             ~13     ~12
          9        QM_ASSIGN                                            ~13     <array>
         10        ASSIGN                                                       !4, ~13
   92    11        FETCH_DIM_R                                          ~15     !2, 'bundle_options'
         12      > FE_RESET_R                                           $16     ~15, ->47
         13    > > FE_FETCH_R                                           ~17     $16, !5, ->47
         14    >   ASSIGN                                                       !6, ~17
   94    15        ISSET_ISEMPTY_DIM_OBJ                             0  ~19     !3, !6
         16        BOOL_NOT                                             ~20     ~19
         17      > JMPZ                                                         ~20, ->19
   95    18    > > JMP                                                          ->13
   98    19    >   FETCH_DIM_R                                          ~21     !3, !6
         20        CAST                                              6  ~22     ~21
         21        ASSIGN                                                       !7, ~22
  109    22        INIT_FCALL_BY_NAME                                           'findSourceAttributes'
  110    23        SEND_VAR_EX                                                  !4
         24        SEND_VAR_EX                                                  !6
         25        SEND_VAR_EX                                                  !7
  109    26        DO_FCALL                                          0  $24     
         27        ASSIGN                                                       !8, $24
  119    28        TYPE_CHECK                                        2          !8
         29      > JMPZ                                                         ~26, ->31
  120    30    > > JMP                                                          ->13
  128    31    >   FETCH_DIM_R                                          ~27     !8, 'selection_product'
  129    32        FETCH_DIM_R                                          ~28     !2, 'grinded'
         33        FETCH_DIM_R                                          ~29     ~28, 'old_product'
         34        IS_NOT_IDENTICAL                                             ~27, ~29
         35      > JMPZ                                                         ~30, ->37
  131    36    > > JMP                                                          ->13
  134    37    >   INIT_FCALL_BY_NAME                                           'migrateGrinded'
  135    38        SEND_VAR_EX                                                  !0
         39        SEND_VAR_EX                                                  !1
         40        SEND_VAR_EX                                                  !2
         41        SEND_VAR_EX                                                  !6
         42        SEND_VAR_EX                                                  !5
         43        SEND_VAR_EX                                                  !8
  134    44        DO_FCALL                                          0  $31     
         45        ASSIGN                                                       !0, $31
   92    46      > JMP                                                          ->13
         47    >   FE_FREE                                                      $16
  144    48        VERIFY_RETURN_TYPE                                           !0
         49      > RETURN                                                       !0
  145    50*       VERIFY_RETURN_TYPE                                           
         51*     > RETURN                                                       null

End of function migrateside

Function findsourceattributes:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 5, Position 2 = 68
Branch analysis from position: 5
2 jumps found. (Code = 78) Position 1 = 6, Position 2 = 68
Branch analysis from position: 6
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 17
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 17
2 jumps found. (Code = 43) Position 1 = 29, Position 2 = 30
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 30
2 jumps found. (Code = 43) Position 1 = 33, Position 2 = 36
Branch analysis from position: 33
1 jumps found. (Code = 42) Position 1 = 45
Branch analysis from position: 45
2 jumps found. (Code = 43) Position 1 = 48, Position 2 = 51
Branch analysis from position: 48
1 jumps found. (Code = 42) Position 1 = 60
Branch analysis from position: 60
1 jumps found. (Code = 42) Position 1 = 5
Branch analysis from position: 5
Branch analysis from position: 51
2 jumps found. (Code = 43) Position 1 = 54, Position 2 = 60
Branch analysis from position: 54
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 60
Branch analysis from position: 36
2 jumps found. (Code = 43) Position 1 = 39, Position 2 = 45
Branch analysis from position: 39
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 45
Branch analysis from position: 68
2 jumps found. (Code = 43) Position 1 = 72, Position 2 = 73
Branch analysis from position: 72
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 73
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 68
filename:       /in/TE0WA
function name:  findSourceAttributes
number of ops:  77
compiled vars:  !0 = $superAttributes, !1 = $oldOption, !2 = $oldSelection, !3 = $result, !4 = $value, !5 = $key, !6 = $parts, !7 = $bundleProduct, !8 = $option, !9 = $selectionProduct, !10 = $attributeId
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
  149     0  E >   RECV                                                 !0      
  150     1        RECV                                                 !1      
  151     2        RECV                                                 !2      
  153     3        ASSIGN                                                       !3, <array>
  160     4      > FE_RESET_R                                           $12     !0, ->68
          5    > > FE_FETCH_R                                           ~13     $12, !4, ->68
          6    >   ASSIGN                                                       !5, ~13
  162     7        INIT_FCALL                                                   'explode'
          8        SEND_VAL                                                     '-'
          9        CAST                                              6  ~15     !5
         10        SEND_VAL                                                     ~15
         11        DO_ICALL                                             $16     
         12        ASSIGN                                                       !6, $16
  171    13        COUNT                                                ~18     !6
         14        IS_NOT_IDENTICAL                                             ~18, 4
         15      > JMPZ                                                         ~19, ->17
  172    16    > > JMP                                                          ->5
  176    17    >   QM_ASSIGN                                            ~20     !6
         18        FETCH_LIST_R                                         $21     ~20, 0
         19        ASSIGN                                                       !7, $21
         20        FETCH_LIST_R                                         $23     ~20, 1
  177    21        ASSIGN                                                       !8, $23
         22        FETCH_LIST_R                                         $25     ~20, 2
  178    23        ASSIGN                                                       !9, $25
         24        FETCH_LIST_R                                         $27     ~20, 3
  179    25        ASSIGN                                                       !10, $27
         26        FREE                                                         ~20
  182    27        IS_NOT_IDENTICAL                                             !8, !1
         28      > JMPZ                                                         ~29, ->30
  183    29    > > JMP                                                          ->5
  189    30    >   FETCH_DIM_R                                          ~30     !3, 'selection_product'
         31        TYPE_CHECK                                        2          ~30
         32      > JMPZ                                                         ~31, ->36
  190    33    >   ASSIGN_DIM                                                   !3, 'selection_product'
         34        OP_DATA                                                      !9
  189    35      > JMP                                                          ->45
  192    36    >   FETCH_DIM_R                                          ~33     !3, 'selection_product'
         37        IS_NOT_IDENTICAL                                             !9, ~33
         38      > JMPZ                                                         ~34, ->45
  194    39    >   NEW                                                  $35     'RuntimeException'
  195    40        NOP                                                          
         41        FAST_CONCAT                                          ~36     'Different+selection+products+found+for+bundle+option+', !1
         42        SEND_VAL_EX                                                  ~36
  194    43        DO_FCALL                                          0          
  195    44      > THROW                                             0          $35
  199    45    >   FETCH_DIM_R                                          ~38     !3, 'bundle_product'
         46        TYPE_CHECK                                        2          ~38
         47      > JMPZ                                                         ~39, ->51
  200    48    >   ASSIGN_DIM                                                   !3, 'bundle_product'
         49        OP_DATA                                                      !7
  199    50      > JMP                                                          ->60
  202    51    >   FETCH_DIM_R                                          ~41     !3, 'bundle_product'
         52        IS_NOT_IDENTICAL                                             !7, ~41
         53      > JMPZ                                                         ~42, ->60
  204    54    >   NEW                                                  $43     'RuntimeException'
  205    55        NOP                                                          
         56        FAST_CONCAT                                          ~44     'Different+bundle+products+found+for+bundle+option+', !1
         57        SEND_VAL_EX                                                  ~44
  204    58        DO_FCALL                                          0          
  205    59      > THROW                                             0          $43
  209    60    >   CAST                                              6  ~48     !4
         61        FETCH_DIM_W                                          $46     !3, 'attributes'
         62        ASSIGN_DIM                                                   $46, !10
         63        OP_DATA                                                      ~48
  210    64        FETCH_DIM_W                                          $49     !3, 'keys'
         65        ASSIGN_DIM                                                   $49
         66        OP_DATA                                                      !5
  160    67      > JMP                                                          ->5
         68    >   FE_FREE                                                      $12
  213    69        FETCH_DIM_R                                          ~51     !3, 'selection_product'
         70        TYPE_CHECK                                        2          ~51
         71      > JMPZ                                                         ~52, ->73
  214    72    > > RETURN                                                       null
  217    73    >   VERIFY_RETURN_TYPE                                           !3
         74      > RETURN                                                       !3
  218    75*       VERIFY_RETURN_TYPE                                           
         76*     > RETURN                                                       null

End of function findsourceattributes

Function migrategrinded:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 24
Branch analysis from position: 14
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 24
2 jumps found. (Code = 43) Position 1 = 31, Position 2 = 41
Branch analysis from position: 31
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 41
2 jumps found. (Code = 77) Position 1 = 47, Position 2 = 79
Branch analysis from position: 47
2 jumps found. (Code = 78) Position 1 = 48, Position 2 = 79
Branch analysis from position: 48
2 jumps found. (Code = 43) Position 1 = 52, Position 2 = 62
Branch analysis from position: 52
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 62
2 jumps found. (Code = 43) Position 1 = 68, Position 2 = 78
Branch analysis from position: 68
1 jumps found. (Code = 108) Position 1 = -2
Branch analysis from position: 78
1 jumps found. (Code = 42) Position 1 = 47
Branch analysis from position: 47
Branch analysis from position: 79
2 jumps found. (Code = 43) Position 1 = 86, Position 2 = 88
Branch analysis from position: 86
2 jumps found. (Code = 77) Position 1 = 90, Position 2 = 94
Branch analysis from position: 90
2 jumps found. (Code = 78) Position 1 = 91, Position 2 = 94
Branch analysis from position: 91
1 jumps found. (Code = 42) Position 1 = 90
Branch analysis from position: 90
Branch analysis from position: 94
2 jumps found. (Code = 77) Position 1 = 123, Position 2 = 133
Branch analysis from position: 123
2 jumps found. (Code = 78) Position 1 = 124, Position 2 = 133
Branch analysis from position: 124
1 jumps found. (Code = 42) Position 1 = 123
Branch analysis from position: 123
Branch analysis from position: 133
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 133
Branch analysis from position: 94
Branch analysis from position: 88
Branch analysis from position: 79
filename:       /in/TE0WA
function name:  migrateGrinded
number of ops:  140
compiled vars:  !0 = $request, !1 = $config, !2 = $side, !3 = $oldOption, !4 = $newOption, !5 = $source, !6 = $attributes, !7 = $patternAttribute, !8 = $oldPattern, !9 = $pattern, !10 = $mapping, !11 = $attributeId, !12 = $oldValue, !13 = $key, !14 = $newSuperAttributeKey, !15 = $customOptionKey, !16 = $options
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
  222     0  E >   RECV                                                 !0      
  223     1        RECV                                                 !1      
  224     2        RECV                                                 !2      
  225     3        RECV                                                 !3      
  226     4        RECV                                                 !4      
  227     5        RECV                                                 !5      
  229     6        FETCH_DIM_R                                          ~17     !5, 'attributes'
          7        ASSIGN                                                       !6, ~17
  237     8        FETCH_DIM_R                                          ~19     !1, 'pattern'
          9        FETCH_DIM_R                                          ~20     ~19, 'attribute'
         10        ASSIGN                                                       !7, ~20
  239    11        ISSET_ISEMPTY_DIM_OBJ                             0  ~22     !6, !7
         12        BOOL_NOT                                             ~23     ~22
         13      > JMPZ                                                         ~23, ->24
  240    14    >   NEW                                                  $24     'RuntimeException'
  241    15        ROPE_INIT                                         3  ~26     'Missing+pattern+attribute+'
         16        ROPE_ADD                                          1  ~26     ~26, !7
         17        ROPE_END                                          2  ~25     ~26, '+'
  242    18        NOP                                                          
         19        FAST_CONCAT                                          ~28     'for+bundle+option+', !3
         20        CONCAT                                               ~29     ~25, ~28
         21        SEND_VAL_EX                                                  ~29
  240    22        DO_FCALL                                          0          
  242    23      > THROW                                             0          $24
  246    24    >   FETCH_DIM_R                                          ~31     !6, !7
         25        ASSIGN                                                       !8, ~31
  248    26        FETCH_DIM_IS                                         ~33     !2, 'grinded'
         27        FETCH_DIM_IS                                         ~34     ~33, 'patterns'
         28        ISSET_ISEMPTY_DIM_OBJ                             0  ~35     ~34, !8
         29        BOOL_NOT                                             ~36     ~35
         30      > JMPZ                                                         ~36, ->41
  249    31    >   NEW                                                  $37     'RuntimeException'
  250    32        ROPE_INIT                                         3  ~39     'Unknown+pattern+'
         33        ROPE_ADD                                          1  ~39     ~39, !8
         34        ROPE_END                                          2  ~38     ~39, '+'
  251    35        NOP                                                          
         36        FAST_CONCAT                                          ~41     'for+bundle+option+', !3
         37        CONCAT                                               ~42     ~38, ~41
         38        SEND_VAL_EX                                                  ~42
  249    39        DO_FCALL                                          0          
  251    40      > THROW                                             0          $37
  255    41    >   FETCH_DIM_R                                          ~44     !2, 'grinded'
         42        FETCH_DIM_R                                          ~45     ~44, 'patterns'
         43        FETCH_DIM_R                                          ~46     ~45, !8
         44        ASSIGN                                                       !9, ~46
  264    45        FETCH_DIM_R                                          ~48     !1, 'attributes'
         46      > FE_RESET_R                                           $49     ~48, ->79
         47    > > FE_FETCH_R                                           ~50     $49, !10, ->79
         48    >   ASSIGN                                                       !11, ~50
  266    49        ISSET_ISEMPTY_DIM_OBJ                             0  ~52     !6, !11
         50        BOOL_NOT                                             ~53     ~52
         51      > JMPZ                                                         ~53, ->62
  267    52    >   NEW                                                  $54     'RuntimeException'
  268    53        ROPE_INIT                                         3  ~56     'Missing+attribute+'
         54        ROPE_ADD                                          1  ~56     ~56, !11
         55        ROPE_END                                          2  ~55     ~56, '+'
  269    56        NOP                                                          
         57        FAST_CONCAT                                          ~58     'for+bundle+option+', !3
         58        CONCAT                                               ~59     ~55, ~58
         59        SEND_VAL_EX                                                  ~59
  267    60        DO_FCALL                                          0          
  269    61      > THROW                                             0          $54
  273    62    >   FETCH_DIM_R                                          ~61     !6, !11
         63        ASSIGN                                                       !12, ~61
  275    64        FETCH_DIM_IS                                         ~63     !10, 'values'
         65        ISSET_ISEMPTY_DIM_OBJ                             0  ~64     ~63, !12
         66        BOOL_NOT                                             ~65     ~64
         67      > JMPZ                                                         ~65, ->78
  276    68    >   NEW                                                  $66     'RuntimeException'
  277    69        ROPE_INIT                                         3  ~68     'Unknown+value+'
         70        ROPE_ADD                                          1  ~68     ~68, !12
         71        ROPE_END                                          2  ~67     ~68, '+'
  278    72        NOP                                                          
         73        FAST_CONCAT                                          ~70     'for+attribute+', !11
         74        CONCAT                                               ~71     ~67, ~70
         75        SEND_VAL_EX                                                  ~71
  276    76        DO_FCALL                                          0          
  278    77      > THROW                                             0          $66
  264    78    > > JMP                                                          ->47
         79    >   FE_FREE                                                      $49
  290    80        FETCH_DIM_R                                          ~75     !9, 'selection'
         81        FETCH_DIM_W                                          $73     !0, 'bundle_option'
         82        ASSIGN_DIM                                                   $73, !4
         83        OP_DATA                                                      ~75
  292    84        IS_NOT_IDENTICAL                                             !3, !4
         85      > JMPZ                                                         ~76, ->88
  293    86    >   FETCH_DIM_UNSET                                      $77     !0, 'bundle_option'
         87        UNSET_DIM                                                    $77, !3
  303    88    >   FETCH_DIM_R                                          ~78     !5, 'keys'
         89      > FE_RESET_R                                           $79     ~78, ->94
         90    > > FE_FETCH_R                                                   $79, !13, ->94
  304    91    >   FETCH_DIM_UNSET                                      $80     !0, 'super_attribute'
         92        UNSET_DIM                                                    $80, !13
  303    93      > JMP                                                          ->90
         94    >   FE_FREE                                                      $79
  320    95        FETCH_DIM_R                                          ~81     !5, 'bundle_product'
  322    96        FETCH_DIM_R                                          ~82     !9, 'product'
  323    97        FETCH_DIM_R                                          ~83     !1, 'pattern'
         98        FETCH_DIM_R                                          ~84     ~83, 'new_attribute'
         99        ROPE_INIT                                         7  ~86     ~81
        100        ROPE_ADD                                          1  ~86     ~86, '-'
        101        ROPE_ADD                                          2  ~86     ~86, !4
        102        ROPE_ADD                                          3  ~86     ~86, '-'
        103        ROPE_ADD                                          4  ~86     ~86, ~82
        104        ROPE_ADD                                          5  ~86     ~86, '-'
        105        ROPE_END                                          6  ~85     ~86, ~84
  318   106        ASSIGN                                                       !14, ~85
  327   107        FETCH_DIM_R                                          ~93     !9, 'value'
  326   108        FETCH_DIM_W                                          $91     !0, 'super_attribute'
        109        ASSIGN_DIM                                                   $91, !14
  327   110        OP_DATA                                                      ~93
  347   111        FETCH_DIM_R                                          ~94     !5, 'bundle_product'
  348   112        ROPE_INIT                                         4  ~96     ~94
        113        ROPE_ADD                                          1  ~96     ~96, '_'
        114        ROPE_ADD                                          2  ~96     ~96, !4
        115        ROPE_END                                          3  ~95     ~96, '_options'
  345   116        ASSIGN                                                       !15, ~95
  351   117        FETCH_DIM_IS                                         ~99     !0, !15
        118        COALESCE                                             ~100    ~99
        119        QM_ASSIGN                                            ~100    <array>
        120        ASSIGN                                                       !16, ~100
  353   121        FETCH_DIM_R                                          ~102    !1, 'attributes'
        122      > FE_RESET_R                                           $103    ~102, ->133
        123    > > FE_FETCH_R                                           ~104    $103, !10, ->133
        124    >   ASSIGN                                                       !11, ~104
  355   125        FETCH_DIM_R                                          ~106    !6, !11
        126        ASSIGN                                                       !12, ~106
  357   127        FETCH_DIM_R                                          ~108    !10, 'option'
  358   128        FETCH_DIM_R                                          ~110    !10, 'values'
        129        FETCH_DIM_R                                          ~111    ~110, !12
  357   130        ASSIGN_DIM                                                   !16, ~108
  358   131        OP_DATA                                                      ~111
  353   132      > JMP                                                          ->123
        133    >   FE_FREE                                                      $103
  361   134        ASSIGN_DIM                                                   !0, !15
        135        OP_DATA                                                      !16
  363   136        VERIFY_RETURN_TYPE                                           !0
        137      > RETURN                                                       !0
  364   138*       VERIFY_RETURN_TYPE                                           
        139*     > RETURN                                                       null

End of function migrategrinded

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
128.49 ms | 519 KiB | 11 Q