From 53d46044c3162a9c1948e2d2a4efe697e5902fb9 Mon Sep 17 00:00:00 2001 From: Jellyfrog Date: Fri, 23 Apr 2021 04:49:33 +0200 Subject: [PATCH] Fix OS sensor array return (#12694) --- LibreNMS/OS/AirosAfLtu.php | 2 ++ LibreNMS/OS/Routeros.php | 5 +++-- phpstan-baseline.neon | 10 ---------- 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/LibreNMS/OS/AirosAfLtu.php b/LibreNMS/OS/AirosAfLtu.php index c89efaa027..7595a1b7f4 100644 --- a/LibreNMS/OS/AirosAfLtu.php +++ b/LibreNMS/OS/AirosAfLtu.php @@ -49,6 +49,8 @@ class AirosAfLtu extends OS implements new WirelessSensor('distance', $this->getDeviceId(), '.1.3.6.1.4.1.41112.1.10.1.4.1.23.' . $index, 'airos-af-ltu', 1, 'Distance', $entry['afLTUStaRemoteDistance'], 1, 1000), //UBNT-AFLTU-MIB::afLTUStaRemoteDistance ]; } + + return []; } /** diff --git a/LibreNMS/OS/Routeros.php b/LibreNMS/OS/Routeros.php index 0f93f64fed..7100fc4e3f 100644 --- a/LibreNMS/OS/Routeros.php +++ b/LibreNMS/OS/Routeros.php @@ -109,7 +109,6 @@ class Routeros extends OS implements { $data = $this->fetchData(); - $sensors = []; foreach ($data as $index => $entry) { if ($entry['mtxrWlApFreq'] == null) { return $this->discoverSensor( @@ -125,6 +124,8 @@ class Routeros extends OS implements ); } } + + return []; } /** @@ -249,7 +250,7 @@ class Routeros extends OS implements return $sensors; } - private function discoverSensor($type, $oid, $num_oid_base) + private function discoverSensor($type, $oid, $num_oid_base): array { $data = $this->fetchData(); $sensors = []; diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 7d80d6c008..7dd2e5a348 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -120,11 +120,6 @@ parameters: count: 2 path: LibreNMS/Modules/Mpls.php - - - message: "#^Method LibreNMS\\\\OS\\\\AirosAfLtu\\:\\:discoverWirelessDistance\\(\\) should return array but return statement is missing\\.$#" - count: 1 - path: LibreNMS/OS/AirosAfLtu.php - - message: "#^Parameter \\#8 \\$multiplier of class LibreNMS\\\\Device\\\\WirelessSensor constructor expects int, null given\\.$#" count: 2 @@ -145,11 +140,6 @@ parameters: count: 1 path: LibreNMS/OS/Ios.php - - - message: "#^Method LibreNMS\\\\OS\\\\Routeros\\:\\:discoverWirelessFrequency\\(\\) should return array but return statement is missing\\.$#" - count: 1 - path: LibreNMS/OS/Routeros.php - - message: "#^Parameter \\#8 \\$multiplier of class LibreNMS\\\\Device\\\\WirelessSensor constructor expects int, null given\\.$#" count: 1