Skip to content

Commit 2a6fc27

Browse files
authored
rector cleanups for deps update (librenms#18511)
1 parent 09f60cc commit 2a6fc27

29 files changed

+38
-38
lines changed

LibreNMS/Data/Store/InfluxDBv2.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ public function write(string $measurement, array $fields, array $tags = [], arra
121121
$device_groups = $device->groups;
122122
foreach ($device_groups as $group) {
123123
// The group name will always be parsed as lowercase, even when uppercase in the GUI.
124-
if (in_array(strtoupper((string) $group->name), array_map('strtoupper', $excluded_groups))) {
124+
if (in_array(strtoupper((string) $group->name), array_map(strtoupper(...), $excluded_groups))) {
125125
Log::warning('Skipped parsing to InfluxDBv2, device is in group: ' . $group->name);
126126

127127
return;

LibreNMS/IRCBot.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public function __construct()
108108
$this->server = $this->config['irc_host'];
109109
if ($this->config['irc_port'][0] == '+') {
110110
$this->ssl = true;
111-
$this->port = substr($this->config['irc_port'], 1);
111+
$this->port = substr((string) $this->config['irc_port'], 1);
112112
} else {
113113
$this->port = $this->config['irc_port'];
114114
}
@@ -118,8 +118,8 @@ public function __construct()
118118
}
119119

120120
if ($this->config['irc_alert_chan']) {
121-
if (strstr($this->config['irc_alert_chan'], ',')) {
122-
$this->config['irc_alert_chan'] = explode(',', $this->config['irc_alert_chan']);
121+
if (strstr((string) $this->config['irc_alert_chan'], ',')) {
122+
$this->config['irc_alert_chan'] = explode(',', (string) $this->config['irc_alert_chan']);
123123
} elseif (! is_array($this->config['irc_alert_chan'])) {
124124
$this->config['irc_alert_chan'] = [$this->config['irc_alert_chan']];
125125
}

LibreNMS/OS.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ public function getCacheByIndex($oid, $mib = null, $snmpflags = '-OQUs')
203203

204204
if (! isset($this->cache['cache_oid'][$oid])) {
205205
$data = snmpwalk_cache_oid($this->getDeviceArray(), $oid, [], $mib, null, $snmpflags);
206-
$this->cache['cache_oid'][$oid] = array_map('current', $data);
206+
$this->cache['cache_oid'][$oid] = array_map(current(...), $data);
207207
}
208208

209209
return $this->cache['cache_oid'][$oid];
@@ -291,7 +291,7 @@ public function getName()
291291
$name = $rf->getShortName();
292292
preg_match_all('/[A-Z][a-z]*/', $name, $segments);
293293

294-
return implode('-', array_map('strtolower', $segments[0]));
294+
return implode('-', array_map(strtolower(...), $segments[0]));
295295
}
296296

297297
/**

LibreNMS/OS/Routeros.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,7 @@ public function discoverVlans(): Collection
689689

690690
foreach (preg_split("/((\r?\n)|(\r\n?))/", (string) $data) as $line) {
691691
if (! empty($line)) {
692-
[$mtType, $vlanId, $mtData] = array_map('trim', explode(',', $line));
692+
[$mtType, $vlanId, $mtData] = array_map(trim(...), explode(',', $line));
693693

694694
if ($mtType == 'N') {
695695
$vlanNames[$vlanId] = $mtData;
@@ -727,7 +727,7 @@ public function discoverVlanPorts(Collection $vlans): Collection
727727

728728
foreach (preg_split("/((\r?\n)|(\r\n?))/", (string) $data) as $line) {
729729
if (! empty($line)) {
730-
[$mtType, $vlanId, $mtData] = array_map('trim', explode(',', $line));
730+
[$mtType, $vlanId, $mtData] = array_map(trim(...), explode(',', $line));
731731

732732
if ($mtType == 'N') { // type 'N' is for vlan name, skip from processing
733733
continue;

LibreNMS/Util/FileCategorizer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ private function osFromFile($file)
157157
private function osFromClass($class)
158158
{
159159
preg_match_all('/[A-Z][a-z0-9]*/', $class, $segments);
160-
$osname = implode('-', array_map('strtolower', $segments[0]));
160+
$osname = implode('-', array_map(strtolower(...), $segments[0]));
161161
$osname = preg_replace(
162162
['/^zero-/', '/^one-/', '/^two-/', '/^three-/', '/^four-/', '/^five-/', '/^six-/', '/^seven-/', '/^eight-/', '/^nine-/'],
163163
['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'],

LibreNMS/Util/IPv6.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public function getNetworkAddress($cidr = null)
125125
}
126126
array_unshift($net_bytes, 'n*'); // add pack format
127127

128-
return self::ntop(call_user_func_array('pack', $net_bytes));
128+
return self::ntop(call_user_func_array(pack(...), $net_bytes));
129129
}
130130

131131
/**
@@ -210,6 +210,6 @@ public function toSnmpIndex()
210210
{
211211
$ipv6_split = str_split(str_replace(':', '', $this->uncompressed()), 2);
212212

213-
return implode('.', array_map('hexdec', $ipv6_split));
213+
return implode('.', array_map(hexdec(...), $ipv6_split));
214214
}
215215
}

LibreNMS/Util/Mac.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ public function vendor(): string
167167
*/
168168
public function oid(): string
169169
{
170-
return implode('.', array_map('hexdec', $this->mac));
170+
return implode('.', array_map(hexdec(...), $this->mac));
171171
}
172172

173173
/**

LibreNMS/Util/StringHelpers.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ public static function bitsToIndices(string $hex_data): array
226226
if (! StringHelpers::isHex($hex_data)) {
227227
// could be malformed
228228
if (preg_match('/^(\d+)(,\d+)*$/', ltrim($hex_data, '0'), $matches)) {
229-
return array_map(fn ($v) => intval($v), explode(',', $matches[0]));
229+
return array_map(intval(...), explode(',', $matches[0]));
230230
}
231231

232232
return [];

LibreNMS/Validator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ public function getResults(?string $validation_group = null): array
143143
return $this->results[$validation_group] ?? [];
144144
}
145145

146-
return array_reduce($this->results, 'array_merge', []);
146+
return array_reduce($this->results, array_merge(...), []);
147147
}
148148

149149
/**

app/Http/Controllers/DeviceGroupController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ public function update(Request $request, DeviceGroup $deviceGroup, ToastInterfac
126126
// sync device_ids from input
127127
$updated = $deviceGroup->devices()->sync($request->get('devices', []));
128128
// check for attached/detached/updated
129-
$devices_updated = array_sum(array_map(fn ($device_ids) => count($device_ids), $updated)) > 0;
129+
$devices_updated = array_sum(array_map(count(...), $updated)) > 0;
130130
} else {
131131
$deviceGroup->rules = json_decode($request->rules);
132132
}

0 commit comments

Comments
 (0)