Check for empty SLA tags so we skip bad entries (#13679)

* Check for empty SLA tags so we skip bad entries

* getSlaTag always return string

* accidentally left line

* Update phpstan-baseline.neon

Co-authored-by: Tony Murray <murraytony@gmail.com>
This commit is contained in:
Neil Lathwood
2022-01-26 14:32:29 +00:00
committed by GitHub
parent f652a5f390
commit 113cd1d98e
2 changed files with 4 additions and 9 deletions

View File

@@ -336,7 +336,7 @@ class Cisco extends OS implements OSDiscovery, SlaDiscovery, ProcessorDiscovery,
return $slas; return $slas;
} }
private function getSlaTag($data) private function getSlaTag($data): string
{ {
if (! empty($data['rttMonCtrlAdminTag'])) { if (! empty($data['rttMonCtrlAdminTag'])) {
return $data['rttMonCtrlAdminTag']; return $data['rttMonCtrlAdminTag'];
@@ -344,11 +344,11 @@ class Cisco extends OS implements OSDiscovery, SlaDiscovery, ProcessorDiscovery,
switch ($data['rttMonCtrlAdminRttType']) { switch ($data['rttMonCtrlAdminRttType']) {
case 'http': case 'http':
return $data['rttMonEchoAdminURL']; return $data['rttMonEchoAdminURL'] ?? '';
case 'dns': case 'dns':
return $data['rttMonEchoAdminTargetAddressString']; return $data['rttMonEchoAdminTargetAddressString'] ?? '';
case 'echo': case 'echo':
return IP::fromHexString($data['rttMonEchoAdminTargetAddress'], true); return IP::fromHexString($data['rttMonEchoAdminTargetAddress'], true) ?? '';
case 'jitter': case 'jitter':
$tag = IP::fromHexString($data['rttMonEchoAdminTargetAddress'], true) . ':' . $data['rttMonEchoAdminTargetPort']; $tag = IP::fromHexString($data['rttMonEchoAdminTargetAddress'], true) . ':' . $data['rttMonEchoAdminTargetPort'];
if (isset($data['rttMonEchoAdminCodecType']) && $data['rttMonEchoAdminCodecType'] != 'notApplicable') { if (isset($data['rttMonEchoAdminCodecType']) && $data['rttMonEchoAdminCodecType'] != 'notApplicable') {

View File

@@ -4290,11 +4290,6 @@ parameters:
count: 1 count: 1
path: LibreNMS/OS/Shared/Cisco.php path: LibreNMS/OS/Shared/Cisco.php
-
message: "#^Method LibreNMS\\\\OS\\\\Shared\\\\Cisco\\:\\:getSlaTag\\(\\) has no return type specified\\.$#"
count: 1
path: LibreNMS/OS/Shared/Cisco.php
- -
message: "#^Method LibreNMS\\\\OS\\\\Shared\\\\Cisco\\:\\:getSlaTag\\(\\) has parameter \\$data with no type specified\\.$#" message: "#^Method LibreNMS\\\\OS\\\\Shared\\\\Cisco\\:\\:getSlaTag\\(\\) has parameter \\$data with no type specified\\.$#"
count: 1 count: 1