Skip to content

Commit

Permalink
Fix StyleCI and syntax errors
Browse files Browse the repository at this point in the history
  • Loading branch information
mpikzink committed Jan 6, 2025
1 parent 80b29af commit b2fe196
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 9 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);

Check failure on line 24 in LibreNMS/Billing.php

View workflow job for this annotation

GitHub Actions / PHP Static Analysis (8.3)

Parameter #3 $pad of static method Illuminate\Support\Str::padLeft() expects string, int given.
$year = date('Y');
$month = date('m');

Expand Down
2 changes: 1 addition & 1 deletion LibreNMS/OS/Shared/Cisco.php
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ public function pollNac()
foreach ($portAuthSessionEntry as $index => $portAuthSessionEntryParameters) {
[$ifIndex, $auth_id] = explode('.', str_replace("'", '', $index));
$session_info = $cafSessionMethodsInfoEntry->get($ifIndex . '.' . $auth_id);
$mac_address = Mac::parse($portAuthSessionEntryParameters['cafSessionClientMacAddress'])->hex());
$mac_address = Mac::parse($portAuthSessionEntryParameters['cafSessionClientMacAddress'])->hex();

$nac->put($mac_address, new PortsNac([
'port_id' => $ifIndex_map->get($ifIndex, 0),
Expand Down
1 change: 0 additions & 1 deletion html/data.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

use App\Models\Port;


/**
* LibreNMS
*
Expand Down
7 changes: 5 additions & 2 deletions includes/common.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*/

use App\Models\Device;
use App\Models\Port;
use LibreNMS\Config;
use LibreNMS\Enum\Severity;
use LibreNMS\Exceptions\InvalidIpException;
Expand Down Expand Up @@ -164,9 +165,11 @@ function get_port_by_index_cache($device_id, $ifIndex)
return $port;
}

function get_port_by_ifIndex($device_id, $ifIndex)
function get_port_by_ifIndex(int $device_id, int $ifIndex): Port
{
return dbFetchRow('SELECT * FROM `ports` WHERE `device_id` = ? AND `ifIndex` = ?', [$device_id, $ifIndex]);
return Port::where('device_id', $device_id)
->where('ifIndex', $ifIndex)
->first();
}

function ifclass($ifOperStatus, $ifAdminStatus)
Expand Down
2 changes: 1 addition & 1 deletion includes/discovery/fdb-table/jetstream.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
$port = $macData['dot1qTpFdbPort'];
//try both variation with & without space
$port_id = find_port_id('gigabitEthernet 1/0/' . $port, 'gigabitEthernet1/0/' . $port, $device['device_id']) ?? 0;
$mac_address = ::parse($mac)->hex();
$mac_address = Mac::parse($mac)->hex();
if (strlen($mac_address) != 12) {
d_echo("MAC address padding failed for $mac\n");
continue;
Expand Down
2 changes: 1 addition & 1 deletion includes/html/functions.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ function bill_permitted($bill_id)
function port_permitted($port_id, $device_id = null)
{
if (! is_numeric($device_id)) {
$device_id = Device::whereHas('ports',fn($p) => $p->port_id = $port_id)->device_id;
$device_id = Device::whereHas('ports', fn ($p) => $p->port_id = $port_id)->device_id;
}

if (device_permitted($device_id)) {
Expand Down
1 change: 1 addition & 0 deletions includes/html/table/eventlog.inc.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php

use App\Models\Port;

/*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
Expand Down
3 changes: 2 additions & 1 deletion scripts/new-os.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env php
<?php

use App\Models\Device;
use LibreNMS\Config;
use LibreNMS\Modules\Core;
use LibreNMS\Util\Debug;
Expand All @@ -15,7 +16,7 @@
$vendor = $options['v'];
Debug::set(isset($options['d']));

$device_id = ctype_digit($options['h']) ? $options['h'] : Device::find($options['h'])->device_id;
$device_id = ctype_digit($options['h']) ? $options['h'] : Device::findByHostname($options['h'])->device_id;
$device = device_by_id_cache($device_id);
$definition_file = Config::get('install_dir') . "/includes/definitions/{$options['o']}.yaml";
$discovery_file = Config::get('install_dir') . "/includes/definitions/discovery/{$options['o']}.yaml";
Expand Down
2 changes: 1 addition & 1 deletion scripts/test-template.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
$runAlerts = new RunAlerts();

$template_id = $options['t'];
$device_id = ctype_digit($options['h']) ? $options['h'] : Device::find($options['h'])->device_id;
$device_id = ctype_digit($options['h']) ? $options['h'] : Device::findByHostname($options['h'])->device_id;
$rule_id = (int) $options['r'];

$where = 'alerts.device_id=' . $device_id . ' && alerts.rule_id=' . $rule_id;
Expand Down

0 comments on commit b2fe196

Please sign in to comment.