3v4l.org

run code in 300+ PHP versions simultaneously
<?php /** * @package Joomla.Site * @subpackage mod_menu * * @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; // Note. It is important to remove spaces between elements. ?> <?php // The menu class is deprecated. Use nav instead. ?> <ul class="nav <?php echo $class_sfx;?>"<?php $tag = ''; /* Never call the same method twice for the same result. There is no benefit to appending a zero-length string to a variable if ($params->get('tag_id') != null) { $tag = $params->get('tag_id') . ''; echo ' id="' . $tag . '"'; }*/ $tagId = $params->get('tag_id'); echo $tagId ? ' id="' . $tagId . '"' : ''; ?>> <?php /* Don't declare $i if you never intend to use it. * Never count() the same unchanged iterable twice -- save the count as a variable. * For declared array variables, to check if non-empty just check if "truthy" -- if ($path). * To directly access the last element's value in an array use end(). * $item->type can never be both "separator" and "heading" at the same time -- use elseif(). * $class is unconditionally declared inside the loop and is never empty so the empty() check is always unnecessary. * There is also no chance of leading or trailing whitespace characters in $class, so the trim call can be removed. * Just print the populated $class string directly into the li tag's class attribute. * I haven't wrapped my head around the deeper/shallower logic near the bottom, so I won't review that. * The final case (default in this code) does not need a break; statement. */ foreach ($list as $i => &$item) { $class = 'item-' . $item->id; if ($item->id == $active_id) { $class .= ' current'; } if (in_array($item->id, $path)) { $class .= ' active'; } elseif ($item->type == 'alias') { $aliasToId = $item->params->get('aliasoptions'); if (count($path) > 0 && $aliasToId == $path[count($path) - 1]) { $class .= ' active'; } elseif (in_array($aliasToId, $path)) { $class .= ' alias-parent-active'; } } if ($item->type == 'separator') { $class .= ' divider'; } if ($item->type == 'heading') { $class .= ' muted'; } if ($item->deeper) { $class .= ' dropdown nav-stacked'; } if ($item->parent) { $class .= ' parent'; } if (!empty($class)) { $class = ' class="' . trim($class) . '"'; } echo '<li' . $class . '>'; // Render the menu item. switch ($item->type) : case 'separator': case 'url': case 'component': case 'heading': require JModuleHelper::getLayoutPath('mod_menu', 'default_' . $item->type); break; default: require JModuleHelper::getLayoutPath('mod_menu', 'default_url'); break; endswitch; // The next item is deeper. if ($item->deeper) { echo '<ul class="dropdown-menu">'; } elseif ($item->shallower) { // The next item is shallower. echo '</li>'; echo str_repeat('</ul></li>', $item->level_diff); } else { // The next item is on the same level. echo '</li>'; } } ?></ul>
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 47) Position 1 = 2, Position 2 = 4
Branch analysis from position: 2
1 jumps found. (Code = 79) Position 1 = -2
Branch analysis from position: 4
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 18
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
2 jumps found. (Code = 125) Position 1 = 22, Position 2 = 132
Branch analysis from position: 22
2 jumps found. (Code = 126) Position 1 = 23, Position 2 = 132
Branch analysis from position: 23
2 jumps found. (Code = 43) Position 1 = 30, Position 2 = 31
Branch analysis from position: 30
2 jumps found. (Code = 43) Position 1 = 37, Position 2 = 39
Branch analysis from position: 37
1 jumps found. (Code = 42) Position 1 = 64
Branch analysis from position: 64
2 jumps found. (Code = 43) Position 1 = 67, Position 2 = 68
Branch analysis from position: 67
2 jumps found. (Code = 43) Position 1 = 71, Position 2 = 72
Branch analysis from position: 71
2 jumps found. (Code = 43) Position 1 = 74, Position 2 = 75
Branch analysis from position: 74
2 jumps found. (Code = 43) Position 1 = 77, Position 2 = 78
Branch analysis from position: 77
2 jumps found. (Code = 43) Position 1 = 81, Position 2 = 87
Branch analysis from position: 81
6 jumps found. (Code = 188) Position 1 = 101, Position 2 = 101, Position 3 = 101, Position 4 = 101, Position 5 = 109, Position 6 = 92
Branch analysis from position: 101
1 jumps found. (Code = 42) Position 1 = 115
Branch analysis from position: 115
2 jumps found. (Code = 43) Position 1 = 118, Position 2 = 120
Branch analysis from position: 118
1 jumps found. (Code = 42) Position 1 = 131
Branch analysis from position: 131
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
Branch analysis from position: 120
2 jumps found. (Code = 43) Position 1 = 122, Position 2 = 130
Branch analysis from position: 122
1 jumps found. (Code = 42) Position 1 = 131
Branch analysis from position: 131
Branch analysis from position: 130
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
Branch analysis from position: 101
Branch analysis from position: 101
Branch analysis from position: 101
Branch analysis from position: 109
1 jumps found. (Code = 42) Position 1 = 115
Branch analysis from position: 115
Branch analysis from position: 92
2 jumps found. (Code = 44) Position 1 = 94, Position 2 = 101
Branch analysis from position: 94
2 jumps found. (Code = 44) Position 1 = 96, Position 2 = 101
Branch analysis from position: 96
2 jumps found. (Code = 44) Position 1 = 98, Position 2 = 101
Branch analysis from position: 98
2 jumps found. (Code = 44) Position 1 = 100, Position 2 = 101
Branch analysis from position: 100
1 jumps found. (Code = 42) Position 1 = 109
Branch analysis from position: 109
Branch analysis from position: 101
Branch analysis from position: 101
Branch analysis from position: 101
Branch analysis from position: 101
Branch analysis from position: 87
Branch analysis from position: 78
Branch analysis from position: 75
Branch analysis from position: 72
Branch analysis from position: 68
Branch analysis from position: 39
2 jumps found. (Code = 43) Position 1 = 42, Position 2 = 64
Branch analysis from position: 42
2 jumps found. (Code = 46) Position 1 = 50, Position 2 = 55
Branch analysis from position: 50
2 jumps found. (Code = 43) Position 1 = 56, Position 2 = 58
Branch analysis from position: 56
1 jumps found. (Code = 42) Position 1 = 64
Branch analysis from position: 64
Branch analysis from position: 58
2 jumps found. (Code = 43) Position 1 = 63, Position 2 = 64
Branch analysis from position: 63
2 jumps found. (Code = 43) Position 1 = 67, Position 2 = 68
Branch analysis from position: 67
Branch analysis from position: 68
Branch analysis from position: 64
Branch analysis from position: 55
Branch analysis from position: 64
Branch analysis from position: 31
Branch analysis from position: 132
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 132
Branch analysis from position: 18
2 jumps found. (Code = 125) Position 1 = 22, Position 2 = 132
Branch analysis from position: 22
Branch analysis from position: 132
filename:       /in/0IJ5n
function name:  (null)
number of ops:  135
compiled vars:  !0 = $class_sfx, !1 = $tag, !2 = $tagId, !3 = $params, !4 = $list, !5 = $item, !6 = $i, !7 = $class, !8 = $active_id, !9 = $path, !10 = $aliasToId
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   10     0  E >   DEFINED                                          ~11     '_JEXEC'
          1      > JMPNZ_EX                                         ~11     ~11, ->4
          2    > > EXIT                                                     
          3*       BOOL                                             ~11     <true>
   14     4    >   ECHO                                                     '++++'
   15     5        ECHO                                                     '++++%3Cul+class%3D%22nav+'
          6        ECHO                                                     !0
          7        ECHO                                                     '%22'
   16     8        ASSIGN                                                   !1, ''
   25     9        INIT_METHOD_CALL                                         !3, 'get'
         10        SEND_VAL_EX                                              'tag_id'
         11        DO_FCALL                                      0  $13     
         12        ASSIGN                                                   !2, $13
   26    13      > JMPZ                                                     !2, ->18
         14    >   CONCAT                                           ~15     '+id%3D%22', !2
         15        CONCAT                                           ~16     ~15, '%22'
         16        QM_ASSIGN                                        ~17     ~16
         17      > JMP                                                      ->19
         18    >   QM_ASSIGN                                        ~17     ''
         19    >   ECHO                                                     ~17
   27    20        ECHO                                                     '%3E%0A++++'
   40    21      > FE_RESET_RW                                      $18     !4, ->132
         22    > > FE_FETCH_RW                                      ~19     $18, !5, ->132
         23    >   ASSIGN                                                   !6, ~19
   42    24        FETCH_OBJ_R                                      ~21     !5, 'id'
         25        CONCAT                                           ~22     'item-', ~21
         26        ASSIGN                                                   !7, ~22
   44    27        FETCH_OBJ_R                                      ~24     !5, 'id'
         28        IS_EQUAL                                                 !8, ~24
         29      > JMPZ                                                     ~25, ->31
   46    30    >   ASSIGN_OP                                     8          !7, '+current'
   49    31    >   INIT_FCALL                                               'in_array'
         32        FETCH_OBJ_R                                      ~27     !5, 'id'
         33        SEND_VAL                                                 ~27
         34        SEND_VAR                                                 !9
         35        DO_ICALL                                         $28     
         36      > JMPZ                                                     $28, ->39
   51    37    >   ASSIGN_OP                                     8          !7, '+active'
         38      > JMP                                                      ->64
   53    39    >   FETCH_OBJ_R                                      ~30     !5, 'type'
         40        IS_EQUAL                                                 ~30, 'alias'
         41      > JMPZ                                                     ~31, ->64
   55    42    >   FETCH_OBJ_R                                      ~32     !5, 'params'
         43        INIT_METHOD_CALL                                         ~32, 'get'
         44        SEND_VAL_EX                                              'aliasoptions'
         45        DO_FCALL                                      0  $33     
         46        ASSIGN                                                   !10, $33
   57    47        COUNT                                            ~35     !9
         48        IS_SMALLER                                       ~36     0, ~35
         49      > JMPZ_EX                                          ~36     ~36, ->55
         50    >   COUNT                                            ~37     !9
         51        SUB                                              ~38     ~37, 1
         52        FETCH_DIM_R                                      ~39     !9, ~38
         53        IS_EQUAL                                         ~40     !10, ~39
         54        BOOL                                             ~36     ~40
         55    > > JMPZ                                                     ~36, ->58
   59    56    >   ASSIGN_OP                                     8          !7, '+active'
         57      > JMP                                                      ->64
   61    58    >   INIT_FCALL                                               'in_array'
         59        SEND_VAR                                                 !10
         60        SEND_VAR                                                 !9
         61        DO_ICALL                                         $42     
         62      > JMPZ                                                     $42, ->64
   63    63    >   ASSIGN_OP                                     8          !7, '+alias-parent-active'
   67    64    >   FETCH_OBJ_R                                      ~44     !5, 'type'
         65        IS_EQUAL                                                 ~44, 'separator'
         66      > JMPZ                                                     ~45, ->68
   69    67    >   ASSIGN_OP                                     8          !7, '+divider'
   72    68    >   FETCH_OBJ_R                                      ~47     !5, 'type'
         69        IS_EQUAL                                                 ~47, 'heading'
         70      > JMPZ                                                     ~48, ->72
   74    71    >   ASSIGN_OP                                     8          !7, '+muted'
   77    72    >   FETCH_OBJ_R                                      ~50     !5, 'deeper'
         73      > JMPZ                                                     ~50, ->75
   79    74    >   ASSIGN_OP                                     8          !7, '+dropdown+nav-stacked'
   82    75    >   FETCH_OBJ_R                                      ~52     !5, 'parent'
         76      > JMPZ                                                     ~52, ->78
   84    77    >   ASSIGN_OP                                     8          !7, '+parent'
   87    78    >   ISSET_ISEMPTY_CV                                 ~54     !7
         79        BOOL_NOT                                         ~55     ~54
         80      > JMPZ                                                     ~55, ->87
   89    81    >   INIT_FCALL                                               'trim'
         82        SEND_VAR                                                 !7
         83        DO_ICALL                                         $56     
         84        CONCAT                                           ~57     '+class%3D%22', $56
         85        CONCAT                                           ~58     ~57, '%22'
         86        ASSIGN                                                   !7, ~58
   92    87    >   CONCAT                                           ~60     '%3Cli', !7
         88        CONCAT                                           ~61     ~60, '%3E'
         89        ECHO                                                     ~61
   95    90        FETCH_OBJ_R                                      ~62     !5, 'type'
         91      > SWITCH_STRING                                            ~62, [ 'separator':->101, 'url':->101, 'component':->101, 'heading':->101, ], ->109
   96    92    >   CASE                                                     ~62, 'separator'
         93      > JMPNZ                                                    ~63, ->101
   97    94    >   CASE                                                     ~62, 'url'
         95      > JMPNZ                                                    ~63, ->101
   98    96    >   CASE                                                     ~62, 'component'
         97      > JMPNZ                                                    ~63, ->101
   99    98    >   CASE                                                     ~62, 'heading'
         99      > JMPNZ                                                    ~63, ->101
        100    > > JMP                                                      ->109
  100   101    >   INIT_STATIC_METHOD_CALL                                  'JModuleHelper', 'getLayoutPath'
        102        SEND_VAL_EX                                              'mod_menu'
        103        FETCH_OBJ_R                                      ~64     !5, 'type'
        104        CONCAT                                           ~65     'default_', ~64
        105        SEND_VAL_EX                                              ~65
        106        DO_FCALL                                      0  $66     
        107        INCLUDE_OR_EVAL                                          $66, REQUIRE
  101   108      > JMP                                                      ->115
  104   109    >   INIT_STATIC_METHOD_CALL                                  'JModuleHelper', 'getLayoutPath'
        110        SEND_VAL_EX                                              'mod_menu'
        111        SEND_VAL_EX                                              'default_url'
        112        DO_FCALL                                      0  $68     
        113        INCLUDE_OR_EVAL                                          $68, REQUIRE
  105   114      > JMP                                                      ->115
        115    >   FREE                                                     ~62
  109   116        FETCH_OBJ_R                                      ~70     !5, 'deeper'
        117      > JMPZ                                                     ~70, ->120
  111   118    >   ECHO                                                     '%3Cul+class%3D%22dropdown-menu%22%3E'
        119      > JMP                                                      ->131
  113   120    >   FETCH_OBJ_R                                      ~71     !5, 'shallower'
        121      > JMPZ                                                     ~71, ->130
  116   122    >   ECHO                                                     '%3C%2Fli%3E'
  117   123        INIT_FCALL                                               'str_repeat'
        124        SEND_VAL                                                 '%3C%2Ful%3E%3C%2Fli%3E'
        125        FETCH_OBJ_R                                      ~72     !5, 'level_diff'
        126        SEND_VAL                                                 ~72
        127        DO_ICALL                                         $73     
        128        ECHO                                                     $73
        129      > JMP                                                      ->131
  122   130    >   ECHO                                                     '%3C%2Fli%3E'
   40   131    > > JMP                                                      ->22
        132    >   FE_FREE                                                  $18
  125   133        ECHO                                                     '%3C%2Ful%3E'
        134      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
180.15 ms | 1408 KiB | 19 Q