Skip to content

Commit 67fbb40

Browse files
Remove dead code in Navigation (#17969)
* Remove temporary variable $node Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Simplify Generator::getNavigationLink Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> --------- Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
1 parent c608ec5 commit 67fbb40

File tree

4 files changed

+13
-59
lines changed

4 files changed

+13
-59
lines changed

libraries/classes/Html/Generator.php

Lines changed: 10 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -361,60 +361,27 @@ public static function getFunctionsForField(array $field, $insertMode, array $fo
361361
/**
362362
* Renders a single link for the top of the navigation panel
363363
*
364-
* @param string $link The url for the link
365-
* @param bool $showText Whether to show the text or to
366-
* only use it for title attributes
367-
* @param string $text The text to display and use for title attributes
368-
* @param bool $showIcon Whether to show the icon
369-
* @param string $icon The filename of the icon to show
370-
* @param string $linkId Value to use for the ID attribute
371-
* @param bool $disableAjax Whether to disable ajax page loading for this link
372-
* @param string $linkTarget The name of the target frame for the link
373-
* @param array $classes HTML classes to apply
364+
* @param string $link The url for the link
365+
* @param string $text The text to display and use for title attributes
366+
* @param string $icon The filename of the icon to show
367+
* @param string $linkId Value to use for the ID attribute
374368
*
375369
* @return string HTML code for one link
376370
*/
377371
public static function getNavigationLink(
378-
$link,
379-
$showText,
380-
$text,
381-
$showIcon,
382-
$icon,
383-
$linkId = '',
384-
$disableAjax = false,
385-
$linkTarget = '',
386-
array $classes = []
372+
string $link,
373+
string $text,
374+
string $icon,
375+
string $linkId = ''
387376
): string {
388377
$retval = '<a href="' . $link . '"';
389-
if (! empty($linkId)) {
378+
if ($linkId !== '') {
390379
$retval .= ' id="' . $linkId . '"';
391380
}
392381

393-
if (! empty($linkTarget)) {
394-
$retval .= ' target="' . $linkTarget . '"';
395-
}
396-
397-
if ($disableAjax) {
398-
$classes[] = 'disableAjax';
399-
}
400-
401-
if (! empty($classes)) {
402-
$retval .= ' class="' . implode(' ', $classes) . '"';
403-
}
404-
405382
$retval .= ' title="' . $text . '">';
406-
if ($showIcon) {
407-
$retval .= self::getImage($icon, $text);
408-
}
409-
410-
if ($showText) {
411-
$retval .= $text;
412-
}
413-
383+
$retval .= self::getImage($icon, $text);
414384
$retval .= '</a>';
415-
if ($showText) {
416-
$retval .= '<br>';
417-
}
418385

419386
return $retval;
420387
}

libraries/classes/Navigation/NavigationTree.php

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,7 @@ public function __construct($template, DatabaseInterface $dbi)
199199
}
200200

201201
// Initialize the tree by creating a root node
202-
$node = NodeFactory::getInstance('NodeDatabaseContainer', 'root');
203-
$this->tree = $node;
202+
$this->tree = NodeFactory::getInstance('NodeDatabaseContainer', 'root');
204203
if (! $GLOBALS['cfg']['NavigationTreeEnableGrouping'] || ! $GLOBALS['cfg']['ShowDatabasesNavigationAsTree']) {
205204
return;
206205
}
@@ -1331,15 +1330,9 @@ private function fastFilterHtml(Node $node): string
13311330
*/
13321331
private function controls(): string
13331332
{
1334-
// always iconic
1335-
$showIcon = true;
1336-
$showText = false;
1337-
13381333
$collapseAll = Generator::getNavigationLink(
13391334
'#',
1340-
$showText,
13411335
__('Collapse all'),
1342-
$showIcon,
13431336
's_collapseall',
13441337
'pma_navigation_collapse'
13451338
);
@@ -1350,7 +1343,7 @@ private function controls(): string
13501343
$title = __('Unlink from main panel');
13511344
}
13521345

1353-
$unlink = Generator::getNavigationLink('#', $showText, $title, $showIcon, $syncImage, 'pma_navigation_sync');
1346+
$unlink = Generator::getNavigationLink('#', $title, $syncImage, 'pma_navigation_sync');
13541347

13551348
return $this->template->render('navigation/tree/controls', [
13561349
'collapse_all' => $collapseAll,

phpstan-baseline.neon

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4665,11 +4665,6 @@ parameters:
46654665
count: 1
46664666
path: libraries/classes/Html/Generator.php
46674667

4668-
-
4669-
message: "#^Method PhpMyAdmin\\\\Html\\\\Generator\\:\\:getNavigationLink\\(\\) has parameter \\$classes with no value type specified in iterable type array\\.$#"
4670-
count: 1
4671-
path: libraries/classes/Html/Generator.php
4672-
46734668
-
46744669
message: "#^Parameter \\#1 \\$params of static method PhpMyAdmin\\\\Url\\:\\:getCommon\\(\\) expects array\\<string, bool\\|int\\|string\\>, array\\<int\\|string, mixed\\> given\\.$#"
46754670
count: 2

psalm-baseline.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7119,8 +7119,7 @@
71197119
<code>$title</code>
71207120
<code>$value</code>
71217121
</MixedArgument>
7122-
<MixedArgumentTypeCoercion occurrences="2">
7123-
<code>$classes</code>
7122+
<MixedArgumentTypeCoercion occurrences="1">
71247123
<code>$key</code>
71257124
</MixedArgumentTypeCoercion>
71267125
<MixedArrayAccess occurrences="3">

0 commit comments

Comments
 (0)