mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Apply code style
This commit is contained in:
@@ -83,7 +83,7 @@ class AlertDB
|
||||
//Our first table has no valid glue, append the 'devices' table to it!
|
||||
array_unshift($tables, 'devices');
|
||||
}
|
||||
$x = sizeof($tables) - 1;
|
||||
$x = count($tables) - 1;
|
||||
$i = 0;
|
||||
$join = '';
|
||||
while ($i < $x) {
|
||||
|
||||
@@ -77,7 +77,7 @@ class AlertRules
|
||||
$qry[$i]['ip'] = inet6_ntop($qry[$i]['ip']);
|
||||
}
|
||||
}
|
||||
$s = sizeof($qry);
|
||||
$s = count($qry);
|
||||
if ($s == 0 && $inv === false) {
|
||||
$doalert = false;
|
||||
} elseif ($s > 0 && $inv === false) {
|
||||
|
||||
@@ -226,7 +226,7 @@ class RunAlerts
|
||||
return 'none';
|
||||
}
|
||||
|
||||
return join(' ', $ret);
|
||||
return implode(' ', $ret);
|
||||
}
|
||||
|
||||
public function clearStaleAlerts()
|
||||
@@ -329,8 +329,8 @@ class RunAlerts
|
||||
$chk[$i]['ip'] = inet6_ntop($chk[$i]['ip']);
|
||||
}
|
||||
}
|
||||
$o = sizeof($alert['details']['rule']);
|
||||
$n = sizeof($chk);
|
||||
$o = count($alert['details']['rule']);
|
||||
$n = count($chk);
|
||||
$ret = 'Alert #' . $alert['id'];
|
||||
$state = AlertState::CLEAR;
|
||||
if ($n > $o) {
|
||||
|
||||
@@ -123,7 +123,7 @@ class LdapAuthorizationAuthorizer extends AuthorizerBase
|
||||
}
|
||||
|
||||
// Find all defined groups $username is in
|
||||
$filter = '(&(|(cn=' . join(')(cn=', array_keys(Config::get('auth_ldap_groups'))) . '))(' . Config::get('auth_ldap_groupmemberattr') . '=' . $this->getMembername($username) . '))';
|
||||
$filter = '(&(|(cn=' . implode(')(cn=', array_keys(Config::get('auth_ldap_groups'))) . '))(' . Config::get('auth_ldap_groupmemberattr') . '=' . $this->getMembername($username) . '))';
|
||||
$search = ldap_search($this->ldap_connection, Config::get('auth_ldap_groupbase'), $filter);
|
||||
$entries = ldap_get_entries($this->ldap_connection, $search);
|
||||
|
||||
|
||||
@@ -211,7 +211,7 @@ class SSOAuthorizer extends MysqlAuthorizer
|
||||
if (isset($config_map[$value])) {
|
||||
$map = $config_map[$value];
|
||||
|
||||
if (is_integer($map) && $level < $map) {
|
||||
if (is_int($map) && $level < $map) {
|
||||
$level = $map;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ class TwoFactor
|
||||
$bin = str_split($bin, 5);
|
||||
$ret = '';
|
||||
$x = -1;
|
||||
while (++$x < sizeof($bin)) {
|
||||
while (++$x < count($bin)) {
|
||||
$ret .= self::$base32_enc[(int) base_convert(str_pad($bin[$x], 5, '0'), 2, 10)];
|
||||
}
|
||||
|
||||
|
||||
@@ -272,13 +272,13 @@ class Rrd extends BaseDatastore
|
||||
*/
|
||||
public function proxmoxName($pmxcluster, $vmid, $vmport)
|
||||
{
|
||||
$pmxcdir = join('/', [$this->rrd_dir, 'proxmox', self::safeName($pmxcluster)]);
|
||||
$pmxcdir = implode('/', [$this->rrd_dir, 'proxmox', self::safeName($pmxcluster)]);
|
||||
// this is not needed for remote rrdcached
|
||||
if (! is_dir($pmxcdir)) {
|
||||
mkdir($pmxcdir, 0775, true);
|
||||
}
|
||||
|
||||
return join('/', [$pmxcdir, self::safeName($vmid . '_netif_' . $vmport . '.rrd')]);
|
||||
return implode('/', [$pmxcdir, self::safeName($vmid . '_netif_' . $vmport . '.rrd')]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+4
-4
@@ -150,7 +150,7 @@ class IRCBot
|
||||
}
|
||||
}
|
||||
|
||||
return $this->log('Cached ' . sizeof($this->external) . ' commands.');
|
||||
return $this->log('Cached ' . count($this->external) . ' commands.');
|
||||
}
|
||||
|
||||
//end load_external()
|
||||
@@ -673,7 +673,7 @@ class IRCBot
|
||||
|
||||
private function ircRaw($params)
|
||||
{
|
||||
return fputs($this->socket['irc'], $params . "\r\n");
|
||||
return fwrite($this->socket['irc'], $params . "\r\n");
|
||||
}
|
||||
|
||||
//end irc_raw()
|
||||
@@ -770,9 +770,9 @@ class IRCBot
|
||||
|
||||
private function _help($params)
|
||||
{
|
||||
$msg = join(', ', $this->commands);
|
||||
$msg = implode(', ', $this->commands);
|
||||
if (count($this->external) > 0) {
|
||||
$msg .= ', ' . join(', ', array_keys($this->external));
|
||||
$msg .= ', ' . implode(', ', array_keys($this->external));
|
||||
}
|
||||
|
||||
return $this->respond("Available commands: $msg");
|
||||
|
||||
@@ -137,7 +137,7 @@ class ArubaInstant extends OS implements
|
||||
// fetch the MAC addresses of currently connected clients, then count them to get an overall total
|
||||
$client_data = $this->getCacheTable('aiClientMACAddress', $ai_mib);
|
||||
|
||||
$total_clients = sizeof($client_data);
|
||||
$total_clients = count($client_data);
|
||||
|
||||
$combined_oid = sprintf('%s::%s', $ai_mib, 'aiClientMACAddress');
|
||||
$oid = snmp_translate($combined_oid, 'ALL', 'arubaos', '-On');
|
||||
@@ -160,7 +160,7 @@ class ArubaInstant extends OS implements
|
||||
$ai_mib = 'AI-AP-MIB';
|
||||
$ap_data = $this->getCacheTable('aiAPSerialNum', $ai_mib);
|
||||
|
||||
$total_aps = sizeof($ap_data);
|
||||
$total_aps = count($ap_data);
|
||||
|
||||
$combined_oid = sprintf('%s::%s', $ai_mib, 'aiAPSerialNum');
|
||||
$oid = snmp_translate($combined_oid, 'ALL', 'arubaos', '-On');
|
||||
@@ -307,14 +307,14 @@ class ArubaInstant extends OS implements
|
||||
}
|
||||
} else {
|
||||
// version is lower than 8.4.0.0
|
||||
if (! empty($sensors) && sizeof($sensors) == 1) {
|
||||
if (! empty($sensors) && count($sensors) == 1) {
|
||||
$ai_mib = 'AI-AP-MIB';
|
||||
$client_data = $this->getCacheTable('aiClientMACAddress', $ai_mib);
|
||||
|
||||
if (empty($client_data)) {
|
||||
$total_clients = 0;
|
||||
} else {
|
||||
$total_clients = sizeof($client_data);
|
||||
$total_clients = count($client_data);
|
||||
}
|
||||
|
||||
$data[$sensors[0]['sensor_id']] = $total_clients;
|
||||
@@ -335,14 +335,14 @@ class ArubaInstant extends OS implements
|
||||
public function pollWirelessApCount(array $sensors)
|
||||
{
|
||||
$data = [];
|
||||
if (! empty($sensors) && sizeof($sensors) == 1) {
|
||||
if (! empty($sensors) && count($sensors) == 1) {
|
||||
$ai_mib = 'AI-AP-MIB';
|
||||
$ap_data = $this->getCacheTable('aiAPSerialNum', $ai_mib);
|
||||
|
||||
$total_aps = 0;
|
||||
|
||||
if (! empty($ap_data)) {
|
||||
$total_aps = sizeof($ap_data);
|
||||
$total_aps = count($ap_data);
|
||||
}
|
||||
|
||||
$data[$sensors[0]['sensor_id']] = $total_aps;
|
||||
|
||||
@@ -27,8 +27,7 @@ use App\Models\Device;
|
||||
use LibreNMS\Interfaces\Discovery\OSDiscovery;
|
||||
use LibreNMS\OS;
|
||||
|
||||
class Beagleboard extends OS implements
|
||||
OSDiscovery
|
||||
class Beagleboard extends OS implements OSDiscovery
|
||||
{
|
||||
/**
|
||||
* Retrieve basic information about the OS / device
|
||||
|
||||
@@ -34,7 +34,7 @@ class Stellar extends OS implements
|
||||
if (empty($client_ws_data)) {
|
||||
$total_clients = 0;
|
||||
} else {
|
||||
$total_clients = sizeof($client_ws_data);
|
||||
$total_clients = count($client_ws_data);
|
||||
}
|
||||
|
||||
$combined_oid = sprintf('%s::%s', $device['hardware'], 'apClientWlanService');
|
||||
@@ -75,7 +75,7 @@ class Stellar extends OS implements
|
||||
if (empty($client_ws_data)) {
|
||||
$total_clients = 0;
|
||||
} else {
|
||||
$total_clients = sizeof($client_ws_data);
|
||||
$total_clients = count($client_ws_data);
|
||||
}
|
||||
|
||||
foreach ($sensors as $sensor) {
|
||||
|
||||
+2
-2
@@ -226,7 +226,7 @@ class Vrp extends OS implements
|
||||
|
||||
$foundid = 0;
|
||||
|
||||
for ($z = 0; $z < sizeof($ap_db); $z++) {
|
||||
for ($z = 0; $z < count($ap_db); $z++) {
|
||||
if ($ap_db[$z]['name'] == $name && $ap_db[$z]['radio_number'] == $radionum) {
|
||||
$foundid = $ap_db[$z]['accesspoint_id'];
|
||||
$ap_db[$z]['seen'] = 1;
|
||||
@@ -276,7 +276,7 @@ class Vrp extends OS implements
|
||||
}//end foreach 1
|
||||
}//end foreach 2
|
||||
|
||||
for ($z = 0; $z < sizeof($ap_db); $z++) {
|
||||
for ($z = 0; $z < count($ap_db); $z++) {
|
||||
if (! isset($ap_db[$z]['seen']) && $ap_db[$z]['deleted'] == 0) {
|
||||
dbUpdate(['deleted' => 1], 'access_points', '`accesspoint_id` = ?', [$ap_db[$z]['accesspoint_id']]);
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ class ObjectCache implements ArrayAccess
|
||||
return $GLOBALS['_ObjCache'][$this->obj][$obj]['value'];
|
||||
} else {
|
||||
$GLOBALS['_ObjCache'][$this->obj][$obj]['value'] = dbFetchRows($this->data[$obj]['query'], isset($this->data[$obj]['params']) ? $this->data[$obj]['params'] : []);
|
||||
if (sizeof($GLOBALS['_ObjCache'][$this->obj][$obj]['value']) == 1 && sizeof($GLOBALS['_ObjCache'][$this->obj][$obj]['value'][0]) == 1) {
|
||||
if (count($GLOBALS['_ObjCache'][$this->obj][$obj]['value']) == 1 && count($GLOBALS['_ObjCache'][$this->obj][$obj]['value'][0]) == 1) {
|
||||
$GLOBALS['_ObjCache'][$this->obj][$obj]['value'] = current($GLOBALS['_ObjCache'][$this->obj][$obj]['value'][0]);
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ class System extends BaseValidation
|
||||
protected static $RUN_BY_DEFAULT = true;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function validate(Validator $validator): void
|
||||
{
|
||||
|
||||
@@ -79,7 +79,7 @@ class SmokepingGenerateCommand extends LnmsCommand
|
||||
|
||||
$devices = Device::isNotDisabled()->orderBy('type')->orderBy('hostname')->get();
|
||||
|
||||
if (sizeof($devices) < 1) {
|
||||
if (count($devices) < 1) {
|
||||
$this->error(__('commands.smokeping:generate.no-devices'));
|
||||
|
||||
return 3;
|
||||
|
||||
@@ -72,7 +72,7 @@ class LegacyController extends Controller
|
||||
}
|
||||
|
||||
// create and set the title
|
||||
$title = join(' - ', $pagetitle);
|
||||
$title = implode(' - ', $pagetitle);
|
||||
$html .= "<script type=\"text/javascript\">\ndocument.title = '$title';\n</script>";
|
||||
}
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ class MempoolsController extends TableController
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
* @inheritdoc
|
||||
*/
|
||||
protected function baseQuery($request)
|
||||
{
|
||||
|
||||
@@ -61,8 +61,7 @@ class StringHelperTest extends TestCase
|
||||
$this->assertFalse(StringHelpers::isStringable([]));
|
||||
$this->assertFalse(StringHelpers::isStringable((object) []));
|
||||
|
||||
$stringable = new class
|
||||
{
|
||||
$stringable = new class {
|
||||
public function __toString()
|
||||
{
|
||||
return '';
|
||||
@@ -70,8 +69,7 @@ class StringHelperTest extends TestCase
|
||||
};
|
||||
$this->assertTrue(StringHelpers::isStringable($stringable));
|
||||
|
||||
$nonstringable = new class
|
||||
{
|
||||
$nonstringable = new class {
|
||||
};
|
||||
$this->assertFalse(StringHelpers::isStringable($nonstringable));
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ if (PHP_VERSION_ID < 80100) {
|
||||
}
|
||||
|
||||
// If we loaded any extra config
|
||||
if (sizeof($config) > 0) {
|
||||
if (count($config) > 0) {
|
||||
$config['parameters']['reportUnmatchedIgnoredErrors'] = false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user