Skip to content

Commit 08b552a

Browse files
murrantStyleCIBot
andauthored
Rector code cleanup (librenms#18390)
* Add rector with initial config * Run rector * Apply fixes from StyleCI --------- Co-authored-by: StyleCI Bot <[email protected]>
1 parent fa4bb69 commit 08b552a

File tree

288 files changed

+677
-593
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

288 files changed

+677
-593
lines changed

LibreNMS/Alert/AlertUtil.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ public static function findContactsSysContact(array $results): array
170170

171171
public static function findContactsOwners(array $results): array
172172
{
173-
return User::whereNot('email', '')->where(function (Builder $query) use ($results) {
173+
return User::whereNot('email', '')->where(function (Builder $query) use ($results): void {
174174
if ($device_ids = array_filter(Arr::pluck($results, 'device_id'))) {
175175
$query->orWhereHas('devicesOwned', fn ($q) => $q->whereIn('devices_perms.device_id', $device_ids));
176176
}

LibreNMS/Alert/Template.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public function getTemplate($obj = null)
4646
// Return the cached template information.
4747
return $this->template;
4848
}
49-
$this->template = AlertTemplate::whereHas('map', function ($query) use ($obj) {
49+
$this->template = AlertTemplate::whereHas('map', function ($query) use ($obj): void {
5050
$query->where('alert_rule_id', '=', $obj['rule_id']);
5151
})->first();
5252
if (! $this->template) {

LibreNMS/Alert/Transport/Elasticsearch.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public function deliverAlert(array $alert_data): bool
6464
'entity_descr' => $alert_data['sysDescr'],
6565
];
6666

67-
foreach ($alert_data['faults'] as $k => $v) {
67+
foreach ($alert_data['faults'] as $v) {
6868
$data['message'] = $v['string'];
6969
switch (true) {
7070
case array_key_exists('port_id', $v):

LibreNMS/Alert/Transport/Pagerduty.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public function deliverAlert(array $alert_data): bool
5454
'group' => (string) \DeviceCache::get($alert_data['device_id'])->groups->pluck('name'),
5555
'source' => $alert_data['hostname'],
5656
'severity' => $alert_data['severity'],
57-
'summary' => ($alert_data['title'] ? $alert_data['title'] : $alert_data['name'] . ' on ' . $alert_data['hostname']),
57+
'summary' => ($alert_data['title'] ?: $alert_data['name'] . ' on ' . $alert_data['hostname']),
5858
],
5959
];
6060

LibreNMS/Alert/Transport/Victorops.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public function deliverAlert(array $alert_data): bool
5454
},
5555
};
5656

57-
foreach ($alert_data['faults'] as $fault => $data) {
57+
foreach ($alert_data['faults'] as $data) {
5858
$protocol['state_message'] .= $data['string'];
5959
}
6060

LibreNMS/Alert/Transport/Zenduty.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function deliverAlert(array $alert_data): bool
4444
$alert_type = $alert_data['severity'];
4545
}
4646
// Set the standard data ZD expects to see
47-
$msg = (json_decode($alert_data['msg'], true)) ? json_decode($alert_data['msg'], true) : $alert_data['msg'];
47+
$msg = json_decode($alert_data['msg'], true) ?: $alert_data['msg'];
4848
$data = [
4949
'message' => $alert_data['title'],
5050
'alert_type' => $alert_type,

LibreNMS/Alerting/QueryBuilderFluentParser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public function toQuery()
6161
*/
6262
protected function parseGroupToQuery($query, $rule, $parent_condition = null)
6363
{
64-
return $query->where(function ($query) use ($rule) {
64+
return $query->where(function ($query) use ($rule): void {
6565
foreach ($rule['rules'] as $group_rule) {
6666
if (array_key_exists('condition', $group_rule)) {
6767
$this->parseGroupToQuery($query, $group_rule, $rule['condition']);

LibreNMS/Authentication/ActiveDirectoryCommon.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ protected function sidFromLdap($sid)
4444
if (PHP_INT_SIZE <= 4) {
4545
for ($i = 1; $i <= count($subAuths); $i++) {
4646
if ($subAuths[$i] < 0) {
47-
$subAuths[$i] = $subAuths[$i] + 0x100000000;
47+
$subAuths[$i] += 0x100000000;
4848
}
4949
}
5050
}

LibreNMS/Component.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ public function setComponentPrefs($device_id, $updated)
224224
\App\Models\Component::whereIntegerInRaw('id', array_keys($updated))
225225
->with('prefs')
226226
->get()
227-
->each(function (\App\Models\Component $component) use ($device_id, $updated) {
227+
->each(function (\App\Models\Component $component) use ($device_id, $updated): void {
228228
$update = $updated[$component->id];
229229
unset($update['type']); // can't change type
230230

LibreNMS/Data/Source/Fping.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public function bulkPing(array $hosts, callable $callback): void
115115
Log::debug('[FPING] ' . $process->getCommandLine() . PHP_EOL);
116116

117117
$partial = '';
118-
$process->run(function ($type, $output) use ($callback, &$partial) {
118+
$process->run(function ($type, $output) use ($callback, &$partial): void {
119119
// stdout contains individual ping responses, stderr contains summaries
120120
if ($type == Process::ERR) {
121121
$lines = explode(PHP_EOL, $output);

0 commit comments

Comments
 (0)