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>

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
8.3.60.0140.01016.75
8.3.50.0100.00316.63
8.3.40.0110.01119.09
8.3.30.0120.00418.63
8.3.20.0080.00024.18
8.3.10.0090.00924.66
8.3.00.0080.00026.16
8.2.180.0070.00725.92
8.2.170.0150.00018.79
8.2.160.0100.00322.96
8.2.150.0060.00925.66
8.2.140.0070.01124.66
8.2.130.0040.00426.16
8.2.120.0000.00720.75
8.2.110.0080.00020.29
8.2.100.0090.00317.91
8.2.90.0030.00518.03
8.2.80.0000.00917.97
8.2.70.0050.00317.50
8.2.60.0000.00817.75
8.2.50.0050.00317.93
8.2.40.0040.00419.35
8.2.30.0040.00419.29
8.2.20.0040.00418.15
8.2.10.0040.00419.28
8.2.00.0080.00019.34
8.1.280.0060.00925.92
8.1.270.0030.00522.25
8.1.260.0080.00026.35
8.1.250.0030.00628.09
8.1.240.0140.00722.00
8.1.230.0110.00022.65
8.1.220.0050.00317.74
8.1.210.0040.00418.77
8.1.200.0090.00317.13
8.1.190.0000.00817.22
8.1.180.0030.00518.10
8.1.170.0040.00417.62
8.1.160.0000.00818.86
8.1.150.0040.00418.90
8.1.140.0000.00818.82
8.1.130.0000.00720.17
8.1.120.0000.00717.35
8.1.110.0080.00017.45
8.1.100.0030.00517.41
8.1.90.0040.00417.42
8.1.80.0060.00317.47
8.1.70.0000.00717.38
8.1.60.0040.00417.59
8.1.50.0040.00417.48
8.1.40.0050.00317.47
8.1.30.0040.00417.64
8.1.20.0060.00317.63
8.1.10.0040.00417.46
8.1.00.0000.00817.41
8.0.300.0070.00019.73
8.0.290.0050.00316.75
8.0.280.0070.00018.33
8.0.270.0000.00716.74
8.0.260.0030.00318.31
8.0.250.0030.00317.00
8.0.240.0080.00016.88
8.0.230.0020.00516.90
8.0.220.0000.00816.93
8.0.210.0000.00716.84
8.0.200.0000.00716.97
8.0.190.0000.00816.92
8.0.180.0030.00516.95
8.0.170.0090.00016.92
8.0.160.0000.00716.91
8.0.150.0040.00416.88
8.0.140.0000.00716.88
8.0.130.0000.00613.29
8.0.120.0070.00016.77
8.0.110.0040.00416.77
8.0.100.0020.00517.01
8.0.90.0070.00016.97
8.0.80.0050.01016.91
8.0.70.0040.00416.99
8.0.60.0040.00416.76
8.0.50.0070.00016.93
8.0.30.0120.00617.29
8.0.20.0090.01217.03
8.0.10.0000.00816.93
8.0.00.0040.01416.83
7.4.330.0050.00015.55
7.4.320.0030.00316.34
7.4.300.0030.00316.54
7.4.290.0060.00316.38
7.4.280.0030.00616.36
7.4.270.0090.00016.49
7.4.260.0000.00513.36
7.4.250.0040.00416.43
7.4.240.0060.00116.60
7.4.230.0070.00016.36
7.4.220.0070.00016.50
7.4.210.0050.01116.47
7.4.200.0000.00716.65
7.4.130.0110.00716.47
7.4.120.0130.01216.52
7.4.110.0130.00316.34
7.4.100.0100.00716.59
7.4.90.0070.01016.56
7.4.80.0090.01519.39
7.4.70.0190.00316.52
7.4.60.0040.01816.34
7.4.50.0120.00916.62
7.4.40.0070.01016.48
7.4.30.0160.00616.51
7.4.20.0080.00816.46
7.4.10.0100.01316.70
7.4.00.0120.00916.54
7.3.330.0030.00316.38
7.3.320.0030.00313.04
7.3.310.0000.00616.17
7.3.300.0000.00616.07
7.3.290.0060.00916.23
7.3.280.0030.01316.12
7.3.260.0130.01016.57
7.3.230.0130.00416.20
7.3.210.0100.00616.43
7.3.200.0120.00916.36
7.3.190.0060.01216.42
7.3.180.0110.00816.52
7.3.170.0070.01016.52
7.3.160.0130.00416.49
7.3.150.0070.01316.37
7.3.140.0170.00716.27
7.3.130.0070.01016.29
7.3.120.0070.01116.31
7.3.110.0070.01116.30
7.3.100.0090.01216.15
7.3.90.0090.01216.25
7.3.80.0160.00016.41
7.3.70.0110.00516.19
7.3.60.0100.01016.19
7.3.50.0130.00416.25
7.3.40.0110.00616.35
7.3.30.0100.01016.33
7.3.20.0090.01018.16
7.3.10.0110.01117.82
7.3.00.0030.01318.14
7.2.330.0140.01016.66
7.2.320.0100.00716.68
7.2.310.0060.01216.50
7.2.300.0100.00916.36
7.2.290.0120.00616.64
7.2.280.0030.01716.64
7.2.270.0060.01216.46
7.2.260.0060.01216.27
7.2.250.0070.01416.56
7.2.240.0150.00316.38
7.2.230.0070.01616.52
7.2.220.0100.00816.56
7.2.210.0120.00616.49
7.2.200.0090.00916.63
7.2.190.0060.01216.59
7.2.180.0110.00716.48
7.2.170.0100.01016.43
7.2.160.0060.01016.45
7.2.150.0030.01718.57
7.2.140.0110.00718.38
7.2.130.0070.01118.28
7.2.120.0090.00918.40
7.2.110.0090.00918.55
7.2.100.0090.00918.36
7.2.90.0100.00718.09
7.2.80.0140.00318.16
7.2.70.0130.00318.35
7.2.60.0040.01418.36
7.2.50.0060.01118.39
7.2.40.0030.01518.30
7.2.30.0140.00318.46
7.2.20.0030.01618.27
7.2.10.0140.00318.17
7.2.00.0090.00918.44

preferences:
63.45 ms | 401 KiB | 5 Q