Skip to content

Commit

Permalink
Fix PHPUnit
Browse files Browse the repository at this point in the history
  • Loading branch information
mpikzink committed Jan 6, 2025
1 parent d8c38ad commit 2b3323e
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion LibreNMS/Billing.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public static function formatBytesShort($value): string

public static function getDates($dayofmonth, $months = 0): array
{
$dayofmonth = Str::padLeft($dayofmonth, 2, 0);
$dayofmonth = Str::padLeft($dayofmonth, 2, '0');
$year = date('Y');
$month = date('m');

Expand Down
2 changes: 1 addition & 1 deletion LibreNMS/OS/Boss.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function discoverProcessors()
'avaya-ers',
$this->getDeviceId(),
".1.3.6.1.4.1.45.1.6.3.8.1.1.6.$index",
Str::padLeft($count, 2, 0),
Str::padLeft($count, 2, '0'),

Check failure on line 86 in LibreNMS/OS/Boss.php

View workflow job for this annotation

GitHub Actions / PHP Static Analysis (8.3)

Parameter #1 $value of static method Illuminate\Support\Str::padLeft() expects string, int<1, max> given.
"Unit $count processor",
1,
$entry['sgProxyCpuCoreBusyPerCent'] ?? null
Expand Down
2 changes: 1 addition & 1 deletion LibreNMS/OS/Sgos.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public function discoverProcessors()
$this->getName(),
$this->getDeviceId(),
".1.3.6.1.4.1.3417.2.11.2.4.1.8.$index",
Str::padLeft($index, 2, 0),
Str::padLeft($index, 2, '0'),
"Processor $count",
1,
$entry['s5ChasUtilCPUUsageLast10Minutes']
Expand Down
2 changes: 1 addition & 1 deletion LibreNMS/Util/IPv6.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public function uncompressed()
$parts = explode(':', $ip, 8);

return implode(':', array_map(function ($section) {
return Str::padLeft($section, 4, 0);
return Str::padLeft($section, 4, '0');
}, $parts));
}

Expand Down
2 changes: 1 addition & 1 deletion includes/common.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ function get_port_by_index_cache($device_id, $ifIndex)
return $port;
}

function get_port_by_ifIndex(int $device_id, int $ifIndex): Port
function get_port_by_ifIndex(int $device_id, int $ifIndex): ?Port
{
return Port::where('device_id', $device_id)
->where('ifIndex', $ifIndex)
Expand Down
12 changes: 6 additions & 6 deletions includes/discovery/cisco-mac-accounting.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
[$if, $direction, $a_a, $a_b, $a_c, $a_d, $a_e, $a_f] = explode('.', $oid);
unset($interface);
$interface = dbFetchRow('SELECT * FROM `ports` WHERE `device_id` = ? AND `ifIndex` = ?', [$device['device_id'], $if]);
$ah_a = Str::padLeft(dechex($a_a), 2, 0);
$ah_b = Str::padLeft(dechex($a_b), 2, 0);
$ah_c = Str::padLeft(dechex($a_c), 2, 0);
$ah_d = Str::padLeft(dechex($a_d), 2, 0);
$ah_e = Str::padLeft(dechex($a_e), 2, 0);
$ah_f = Str::padLeft(dechex($a_f), 2, 0);
$ah_a = Str::padLeft(dechex($a_a), 2, '0');
$ah_b = Str::padLeft(dechex($a_b), 2, '0');
$ah_c = Str::padLeft(dechex($a_c), 2, '0');
$ah_d = Str::padLeft(dechex($a_d), 2, '0');
$ah_e = Str::padLeft(dechex($a_e), 2, '0');
$ah_f = Str::padLeft(dechex($a_f), 2, '0');
$mac = "$ah_a$ah_b$ah_c$ah_d$ah_e$ah_f";

if ($interface) {
Expand Down
8 changes: 4 additions & 4 deletions includes/discovery/ports/zynos.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,22 @@
if ($portNum < 50) {
$portNum++;
//Leading 0 for single digits
$ifName = '1/' . Str::padLeft($portNum, 2, 0);
$ifName = '1/' . Str::padLeft($portNum, 2, '0');
}
if ($portNum > 63 && $portNum < 128) {
$portNum = $portNum - 63;
//Leading 0 for single digits
$ifName = '2/' . Str::padLeft($portNum, 2, 0);
$ifName = '2/' . Str::padLeft($portNum, 2, '0');
}
if ($portNum > 127 && $portNum < 192) {
$portNum = $portNum - 127;
//Leading 0 for single digits
$ifName = '3/' . Str::padLeft($portNum, 2, 0);
$ifName = '3/' . Str::padLeft($portNum, 2, '0');
}
if ($portNum > 191) {
$portNum = $portNum - 191;
//Leading 0 for single digits
$ifName = '4/' . Str::padLeft($portNum, 2, 0);
$ifName = '4/' . Str::padLeft($portNum, 2, '0');
}
} else {
//Set port number to match current
Expand Down
2 changes: 1 addition & 1 deletion includes/discovery/sensors/temperature/areca.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
$temperature = snmp_get($device, $temperature_oid, '-Oqv', '');
$descr = "Hard disk $temperature_id";
if ($temperature != -128) { // -128 = not measured/present
discover_sensor(null, 'temperature', $device, $temperature_oid, Str::padLeft($temperature_id, 2, 0), 'areca', $descr, '1', '1', null, null, null, null, $temperature);
discover_sensor(null, 'temperature', $device, $temperature_oid, Str::padLeft($temperature_id, 2, '0'), 'areca', $descr, '1', '1', null, null, null, null, $temperature);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion includes/discovery/sensors/temperature/boss.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
// Sensors are reported as 2 * value
$divisor = 2;
$val = (cast_number($val) / $divisor);
discover_sensor(null, 'temperature', $device, $oid, Str::padLeft($i + 1, 2, 0), 'avaya-ers', 'Unit ' . ($i + 1) . ' temperature', $divisor, 1, null, null, null, null, $val);
discover_sensor(null, 'temperature', $device, $oid, Str::padLeft($i + 1, 2, '0'), 'avaya-ers', 'Unit ' . ($i + 1) . ' temperature', $divisor, 1, null, null, null, null, $val);
}
2 changes: 1 addition & 1 deletion includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ function snmp2ipv6($ipv6_snmp)
$ipv6_2 = [];

for ($i = 0; $i <= 15; $i++) {
$ipv6[$i] = Str::padLeft(dechex($ipv6[$i]), 2, 0);
$ipv6[$i] = Str::padLeft(dechex($ipv6[$i]), 2, '0');
}
for ($i = 0; $i <= 15; $i += 2) {
$ipv6_2[] = $ipv6[$i] . $ipv6[$i + 1];
Expand Down
8 changes: 4 additions & 4 deletions includes/polling/ports/os/zynos.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,22 @@
if ($portNum < 50) {
$portNum++;
//Leading 0 for single digits
$ifName = '1/' . Str::padLeft($portNum, 2, 0);
$ifName = '1/' . Str::padLeft($portNum, 2, '0');
}
if ($portNum > 63 && $portNum < 128) {
$portNum = $portNum - 63;
//Leading 0 for single digits
$ifName = '2/' . Str::padLeft($portNum, 2, 0);
$ifName = '2/' . Str::padLeft($portNum, 2, '0');
}
if ($portNum > 127 && $portNum < 192) {
$portNum = $portNum - 127;
//Leading 0 for single digits
$ifName = '3/' . Str::padLeft($portNum, 2, 0);
$ifName = '3/' . Str::padLeft($portNum, 2, '0');
}
if ($portNum > 191) {
$portNum = $portNum - 191;
//Leading 0 for single digits
$ifName = '4/' . Str::padLeft($portNum, 2, 0);
$ifName = '4/' . Str::padLeft($portNum, 2, '0');
}
} else {
//Set port number to match current
Expand Down

0 comments on commit 2b3323e

Please sign in to comment.