Qual(menu): Replace str_pad with str_repeat (fix phan notices)

The changes replace instances of `str_pad('', $level)` with `str_repeat(' ', $level)`.
This fixes suspicious argument order notices for str_pad (in phan).
This commit is contained in:
MDW 2025-12-09 14:50:21 +01:00
parent 2bdcec1e63
commit 9d39ac76de
No known key found for this signature in database
2 changed files with 20 additions and 20 deletions

View file

@ -2,7 +2,7 @@
/* Copyright (C) 2007 Patrick Raguin <patrick.raguin@gmail.com>
* Copyright (C) 2009 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2008-2013 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
*
* This program is free software; you can redistribute it and/or modify
@ -244,12 +244,12 @@ class MenuManager
// Start a new ul level 1
$level = 1;
print str_pad('', $level).'<ul class="ullevel1">'."\n";
print str_repeat(' ', $level).'<ul class="ullevel1">'."\n";
// Do we have to add an extra entry that is not into menu array ?
if (($canonrelurl != $canonnexturl && !in_array($val['mainmenu'], array('tools')))
|| (strpos($canonrelurl, '/product/index.php') !== false || strpos($canonrelurl, '/compta/bank/list.php') !== false)) {
print str_pad('', $level).'<li class="lilevel1 ui-btn-icon-right ui-btn">'; // ui-btn to highlight on clic
print str_repeat(' ', $level).'<li class="lilevel1 ui-btn-icon-right ui-btn">'; // ui-btn to highlight on clic
print '<a href="'.$relurl.'">';
if ($val['level'] == 0) {
@ -291,7 +291,7 @@ class MenuManager
$newlinelevel = ($val2['level'] + 1);
if ($newlinelevel > $lastlinelevel) {
print str_pad('', $newlinelevel).'<ul class="ullevel'.$newlinelevel.'" xx>'."\n";
print str_repeat(' ', $newlinelevel).'<ul class="ullevel'.$newlinelevel.'" xx>'."\n";
}
$lastlinelevel = ($val2['level'] + 1);
@ -331,7 +331,7 @@ class MenuManager
// Show entry li level $val2['level']+1
// @phan-suppress-next-line PhanParamSuspiciousOrder
print str_pad('', ($val2['level'] + 1));
print str_repeat(' ', ($val2['level'] + 1));
print '<li class="lilevel'.($val2['level'] + 1);
if ($val2['level'] == 0) {
print ' ui-btn-icon-right ui-btn'; // ui-btn to highlight on clic
@ -359,7 +359,7 @@ class MenuManager
if ($val2['level'] == 0 && !empty($val2['prefix'])) {
print $val2['prefix']; // the picto must have class="pictofixedwidth paddingright"
} else {
print '<i class="fa fa-does-not-exists fa-fw paddingright pictofixedwidth level'.($val2['level']+1).'"></i>';
print '<i class="fa fa-does-not-exists fa-fw paddingright pictofixedwidth level'.($val2['level'] + 1).'"></i>';
}
print $val2['titre'];
@ -379,8 +379,8 @@ class MenuManager
print '</li>'."\n";
$fromcursor = 0;
while ($fromcursor < ($currentlevel - $nextlevel)) {
print str_pad('', $currentlevel - $fromcursor).'</ul>'."\n";
print str_pad('', $currentlevel - $fromcursor - 1).'</li>'."\n"; // end level $val2['level']+1
print str_repeat(' ', $currentlevel - $fromcursor).'</ul>'."\n";
print str_repeat(' ', $currentlevel - $fromcursor - 1).'</li>'."\n"; // end level $val2['level']+1
$fromcursor++;
}
} else {
@ -389,8 +389,8 @@ class MenuManager
}
}
print str_pad('', $level).'</ul>'."\n"; // end ul level 1
print str_pad('', $level - 1).'</li>'."\n"; // end ul level 1
print str_repeat(' ', $level).'</ul>'."\n"; // end ul level 1
print str_repeat(' ', $level - 1).'</li>'."\n"; // end ul level 1
} elseif ($val['enabled'] == 2) {
print '<li class="lilevel0">';

View file

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2005-2013 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2007-2009 Regis Houssin <regis.houssin@inodbox.com>
* Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024-2025 MDW <mdeweerd@users.noreply.github.com>
* Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
*
* This program is free software; you can redistribute it and/or modify
@ -246,12 +246,12 @@ class MenuManager
// Start a new ul level 1
$level = 1;
print str_pad('', $level).'<ul class="ullevel1">'."\n";
print str_repeat(' ', $level).'<ul class="ullevel1">'."\n";
// Do we have to add an extra entry that is not into menu array ?
if (($canonrelurl != $canonnexturl && !in_array($val['mainmenu'], array('tools')))
|| (strpos($canonrelurl, '/product/index.php') !== false || strpos($canonrelurl, '/compta/bank/list.php') !== false)) {
print str_pad('', $level).'<li class="lilevel1 ui-btn-icon-right ui-btn">'; // ui-btn to highlight on clic
print str_repeat(' ', $level).'<li class="lilevel1 ui-btn-icon-right ui-btn">'; // ui-btn to highlight on clic
print '<a href="'.$relurl.'">';
if ($val['level'] == 0) {
@ -283,7 +283,7 @@ class MenuManager
$newlinelevel = ($val2['level'] + 1);
if ($newlinelevel > $lastlinelevel) {
print str_pad('', $newlinelevel).'<ul class="ullevel'.$newlinelevel.'" xx>'."\n";
print str_repeat(' ', $newlinelevel).'<ul class="ullevel'.$newlinelevel.'" xx>'."\n";
}
$lastlinelevel = ($val2['level'] + 1);
@ -322,7 +322,7 @@ class MenuManager
// Show entry li level $val2['level']+1
// @phan-suppress-next-line PhanParamSuspiciousOrder
print str_pad('', ($val2['level'] + 1));
print str_repeat(' ', ($val2['level'] + 1));
print '<li class="lilevel'.($val2['level'] + 1);
if ($val2['level'] == 0) {
print ' ui-btn-icon-right ui-btn'; // ui-btn to highlight on clic
@ -351,7 +351,7 @@ class MenuManager
if ($val2['level'] == 0 && !empty($val2['prefix'])) {
print $val2['prefix']; // the picto must have class="pictofixedwidth paddingright"
} else {
print '<i class="fa fa-does-not-exists fa-fw paddingright pictofixedwidth level'.($val2['level']+1).'"></i>';
print '<i class="fa fa-does-not-exists fa-fw paddingright pictofixedwidth level'.($val2['level'] + 1).'"></i>';
}
print $val2['titre'];
@ -370,8 +370,8 @@ class MenuManager
print '</li>'."\n";
$fromcursor = 0;
while ($fromcursor < ($currentlevel - $nextlevel)) {
print str_pad('', $currentlevel - $fromcursor).'</ul>'."\n";
print str_pad('', $currentlevel - $fromcursor - 1).'</li>'."\n"; // end level $val2['level']+1
print str_repeat(' ', $currentlevel - $fromcursor).'</ul>'."\n";
print str_repeat(' ', $currentlevel - $fromcursor - 1).'</li>'."\n"; // end level $val2['level']+1
$fromcursor++;
}
} else {
@ -381,8 +381,8 @@ class MenuManager
//var_dump($submenu);
}
print str_pad('', $level).'</ul>'."\n"; // end ul level 1
print str_pad('', $level - 1).'</li>'."\n"; // end ul level 1
print str_repeat(' ', $level).'</ul>'."\n"; // end ul level 1
print str_repeat(' ', $level - 1).'</li>'."\n"; // end ul level 1
} elseif ($val['enabled'] == 2) {
print '<li class="lilevel0">';