PHPStan: Enable more checks (#14318)
* PHPStan: Enable more checks * Fixes * Fixes * Deprecation fixes
This commit is contained in:
parent
6cc9694780
commit
152497a098
|
@ -76,8 +76,8 @@ jobs:
|
||||||
|
|
||||||
-
|
-
|
||||||
name: Run PHPStan (Deprecated functions)
|
name: Run PHPStan (Deprecated functions)
|
||||||
run: ./vendor/bin/phpstan analyze --no-interaction --no-progress --error-format=github --memory-limit=4G --configuration=phpstan-deprecated.neon
|
run: ./vendor/bin/phpstan analyze --no-interaction --no-progress --memory-limit=4G --configuration=phpstan-deprecated.neon
|
||||||
|
|
||||||
-
|
-
|
||||||
name: Run PHPStan
|
name: Run PHPStan
|
||||||
run: ./vendor/bin/phpstan analyze --no-interaction --no-progress --error-format=github --memory-limit=4G
|
run: ./vendor/bin/phpstan analyze --no-interaction --no-progress --memory-limit=4G
|
||||||
|
|
|
@ -39,7 +39,7 @@ class Elasticsearch extends Transport
|
||||||
{
|
{
|
||||||
$es_host = '127.0.0.1';
|
$es_host = '127.0.0.1';
|
||||||
$es_port = 9200;
|
$es_port = 9200;
|
||||||
$index = strftime('librenms-%Y.%m.%d');
|
$index = date("\l\i\b\\r\\e\\n\m\s\-Y.m.d");
|
||||||
$type = 'alert';
|
$type = 'alert';
|
||||||
$severity = $obj['severity'];
|
$severity = $obj['severity'];
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ class Elasticsearch extends Transport
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! empty($opts['es_index'])) {
|
if (! empty($opts['es_index'])) {
|
||||||
$index = strftime($opts['es_index']);
|
$index = date($opts['es_index']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$host = $es_host . ':' . $es_port . '/' . $index . '/' . $type;
|
$host = $es_host . ':' . $es_port . '/' . $index . '/' . $type;
|
||||||
|
@ -222,7 +222,7 @@ class Elasticsearch extends Transport
|
||||||
[
|
[
|
||||||
'title' => 'Index Pattern',
|
'title' => 'Index Pattern',
|
||||||
'name' => 'es-pattern',
|
'name' => 'es-pattern',
|
||||||
'descr' => 'Elasticsearch Index Pattern',
|
'descr' => 'Elasticsearch Index Pattern | Default: \l\i\b\\r\\e\\n\m\s\-Y.m.d | Format: https://www.php.net/manual/en/function.date.php',
|
||||||
'type' => 'text',
|
'type' => 'text',
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
|
|
|
@ -16,7 +16,7 @@ class Linenotify extends Transport
|
||||||
{
|
{
|
||||||
$opts['line-notify-access-token'] = $this->config['line-notify-access-token'];
|
$opts['line-notify-access-token'] = $this->config['line-notify-access-token'];
|
||||||
|
|
||||||
return $this->contactLineNotify($obj, $opts);
|
return $this->contactLinenotify($obj, $opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function contactLinenotify($obj, $opts)
|
private function contactLinenotify($obj, $opts)
|
||||||
|
|
|
@ -27,7 +27,7 @@ class Twilio extends Transport
|
||||||
$twilio_opts['sender'] = $this->config['twilio-sender'];
|
$twilio_opts['sender'] = $this->config['twilio-sender'];
|
||||||
$twilio_opts['to'] = $this->config['twilio-to'];
|
$twilio_opts['to'] = $this->config['twilio-to'];
|
||||||
|
|
||||||
return $this->contacttwilio($obj, $twilio_opts);
|
return $this->contactTwilio($obj, $twilio_opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function contactTwilio($obj, $opts)
|
public static function contactTwilio($obj, $opts)
|
||||||
|
|
|
@ -124,10 +124,10 @@ class SSOAuthorizer extends MysqlAuthorizer
|
||||||
foreach ($proxies as $value) {
|
foreach ($proxies as $value) {
|
||||||
$proxy = IP::parse($value);
|
$proxy = IP::parse($value);
|
||||||
if ($proxies == '8.8.8.0/25') {
|
if ($proxies == '8.8.8.0/25') {
|
||||||
dd($source->innetwork((string) $proxy));
|
dd($source->inNetwork((string) $proxy));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($source->innetwork((string) $proxy)) {
|
if ($source->inNetwork((string) $proxy)) {
|
||||||
// Proxy matches trusted subnet
|
// Proxy matches trusted subnet
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -460,7 +460,7 @@ class Rrd extends BaseDatastore
|
||||||
public function getRrdFiles($device)
|
public function getRrdFiles($device)
|
||||||
{
|
{
|
||||||
if ($this->rrdcached) {
|
if ($this->rrdcached) {
|
||||||
$filename = sprintf('/%s', self::safename($device['hostname']));
|
$filename = sprintf('/%s', self::safeName($device['hostname']));
|
||||||
$rrd_files = $this->command('list', $filename, '');
|
$rrd_files = $this->command('list', $filename, '');
|
||||||
// Command output is an array, create new array with each filename as a item in array.
|
// Command output is an array, create new array with each filename as a item in array.
|
||||||
$rrd_files_array = explode("\n", trim($rrd_files[0]));
|
$rrd_files_array = explode("\n", trim($rrd_files[0]));
|
||||||
|
|
|
@ -28,7 +28,6 @@ namespace LibreNMS\Device;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
use LibreNMS\Interfaces\Discovery\DiscoveryItem;
|
use LibreNMS\Interfaces\Discovery\DiscoveryItem;
|
||||||
use LibreNMS\Interfaces\Discovery\DiscoveryModule;
|
use LibreNMS\Interfaces\Discovery\DiscoveryModule;
|
||||||
use LibreNMS\Interfaces\Discovery\ProcessorDiscovery;
|
|
||||||
use LibreNMS\Interfaces\Polling\PollerModule;
|
use LibreNMS\Interfaces\Polling\PollerModule;
|
||||||
use LibreNMS\Interfaces\Polling\ProcessorPolling;
|
use LibreNMS\Interfaces\Polling\ProcessorPolling;
|
||||||
use LibreNMS\Model;
|
use LibreNMS\Model;
|
||||||
|
@ -142,7 +141,7 @@ class Processor extends Model implements DiscoveryModule, PollerModule, Discover
|
||||||
$processors = self::processYaml($os);
|
$processors = self::processYaml($os);
|
||||||
|
|
||||||
// if no processors found, check OS discovery (which will fall back to HR and UCD if not implemented
|
// if no processors found, check OS discovery (which will fall back to HR and UCD if not implemented
|
||||||
if (empty($processors) && $os instanceof ProcessorDiscovery) {
|
if (empty($processors)) {
|
||||||
$processors = $os->discoverProcessors();
|
$processors = $os->discoverProcessors();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -144,7 +144,7 @@ class Isis implements Module
|
||||||
'isisISAdjLastUpTime' => $this->parseAdjacencyTime($adjacency_data),
|
'isisISAdjLastUpTime' => $this->parseAdjacencyTime($adjacency_data),
|
||||||
'isisISAdjAreaAddress' => str_replace(' ', '.', trim($adjacency_data['isisISAdjAreaAddress'] ?? '')),
|
'isisISAdjAreaAddress' => str_replace(' ', '.', trim($adjacency_data['isisISAdjAreaAddress'] ?? '')),
|
||||||
'isisISAdjIPAddrType' => $adjacency_data['isisISAdjIPAddrType'] ?? '',
|
'isisISAdjIPAddrType' => $adjacency_data['isisISAdjIPAddrType'] ?? '',
|
||||||
'isisISAdjIPAddrAddress' => (string) IP::fromHexstring($adjacency_data['isisISAdjIPAddrAddress'] ?? null, true),
|
'isisISAdjIPAddrAddress' => (string) IP::fromHexString($adjacency_data['isisISAdjIPAddrAddress'] ?? null, true),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,6 @@ use App\Models\Mempool;
|
||||||
use App\Observers\MempoolObserver;
|
use App\Observers\MempoolObserver;
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use LibreNMS\DB\SyncsModels;
|
use LibreNMS\DB\SyncsModels;
|
||||||
use LibreNMS\Interfaces\Discovery\MempoolsDiscovery;
|
|
||||||
use LibreNMS\Interfaces\Module;
|
use LibreNMS\Interfaces\Module;
|
||||||
use LibreNMS\Interfaces\Polling\MempoolsPolling;
|
use LibreNMS\Interfaces\Polling\MempoolsPolling;
|
||||||
use LibreNMS\OS;
|
use LibreNMS\OS;
|
||||||
|
@ -52,25 +51,23 @@ class Mempools implements Module
|
||||||
|
|
||||||
public function discover(OS $os): void
|
public function discover(OS $os): void
|
||||||
{
|
{
|
||||||
if ($os instanceof MempoolsDiscovery) {
|
$mempools = $os->discoverMempools()->filter(function (Mempool $mempool) {
|
||||||
$mempools = $os->discoverMempools()->filter(function (Mempool $mempool) {
|
if ($mempool->isValid()) {
|
||||||
if ($mempool->isValid()) {
|
return true;
|
||||||
return true;
|
}
|
||||||
}
|
Log::debug("Rejecting Mempool $mempool->mempool_index $mempool->mempool_descr: Invalid total value");
|
||||||
Log::debug("Rejecting Mempool $mempool->mempool_index $mempool->mempool_descr: Invalid total value");
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
$this->calculateAvailable($mempools);
|
$this->calculateAvailable($mempools);
|
||||||
|
|
||||||
MempoolObserver::observe('\App\Models\Mempool');
|
MempoolObserver::observe('\App\Models\Mempool');
|
||||||
$this->syncModels($os->getDevice(), 'mempools', $mempools);
|
$this->syncModels($os->getDevice(), 'mempools', $mempools);
|
||||||
|
|
||||||
echo PHP_EOL;
|
echo PHP_EOL;
|
||||||
$mempools->each(function ($mempool) {
|
$mempools->each(function ($mempool) {
|
||||||
$this->printMempool($mempool);
|
$this->printMempool($mempool);
|
||||||
});
|
});
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function poll(OS $os): void
|
public function poll(OS $os): void
|
||||||
|
|
|
@ -29,11 +29,7 @@ use App\Models\Device;
|
||||||
use App\Models\PortStp;
|
use App\Models\PortStp;
|
||||||
use App\Observers\ModuleModelObserver;
|
use App\Observers\ModuleModelObserver;
|
||||||
use LibreNMS\DB\SyncsModels;
|
use LibreNMS\DB\SyncsModels;
|
||||||
use LibreNMS\Interfaces\Discovery\StpInstanceDiscovery;
|
|
||||||
use LibreNMS\Interfaces\Discovery\StpPortDiscovery;
|
|
||||||
use LibreNMS\Interfaces\Module;
|
use LibreNMS\Interfaces\Module;
|
||||||
use LibreNMS\Interfaces\Polling\StpInstancePolling;
|
|
||||||
use LibreNMS\Interfaces\Polling\StpPortPolling;
|
|
||||||
use LibreNMS\OS;
|
use LibreNMS\OS;
|
||||||
|
|
||||||
class Stp implements Module
|
class Stp implements Module
|
||||||
|
@ -52,40 +48,33 @@ class Stp implements Module
|
||||||
{
|
{
|
||||||
$device = $os->getDevice();
|
$device = $os->getDevice();
|
||||||
|
|
||||||
if ($os instanceof StpInstanceDiscovery) {
|
echo 'Instances: ';
|
||||||
echo 'Instances: ';
|
$instances = $os->discoverStpInstances();
|
||||||
$instances = $os->discoverStpInstances();
|
ModuleModelObserver::observe(\App\Models\Stp::class);
|
||||||
ModuleModelObserver::observe(\App\Models\Stp::class);
|
$this->syncModels($device, 'stpInstances', $instances);
|
||||||
$this->syncModels($device, 'stpInstances', $instances);
|
|
||||||
|
|
||||||
if ($os instanceof StpPortDiscovery) {
|
echo "\nPorts: ";
|
||||||
echo "\nPorts: ";
|
$ports = $os->discoverStpPorts($instances);
|
||||||
$ports = $os->discoverStpPorts($instances);
|
ModuleModelObserver::observe(PortStp::class);
|
||||||
ModuleModelObserver::observe(PortStp::class);
|
$this->syncModels($device, 'stpPorts', $ports);
|
||||||
$this->syncModels($device, 'stpPorts', $ports);
|
|
||||||
}
|
echo PHP_EOL;
|
||||||
echo PHP_EOL;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function poll(OS $os): void
|
public function poll(OS $os): void
|
||||||
{
|
{
|
||||||
$device = $os->getDevice();
|
$device = $os->getDevice();
|
||||||
|
|
||||||
if ($os instanceof StpInstancePolling) {
|
echo 'Instances: ';
|
||||||
echo 'Instances: ';
|
$instances = $device->stpInstances;
|
||||||
$instances = $device->stpInstances;
|
$instances = $os->pollStpInstances($instances);
|
||||||
$instances = $os->pollStpInstances($instances);
|
ModuleModelObserver::observe(\App\Models\Stp::class);
|
||||||
ModuleModelObserver::observe(\App\Models\Stp::class);
|
$this->syncModels($device, 'stpInstances', $instances);
|
||||||
$this->syncModels($device, 'stpInstances', $instances);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($os instanceof StpPortPolling) {
|
echo "\nPorts: ";
|
||||||
echo "\nPorts: ";
|
$ports = $device->stpPorts;
|
||||||
$ports = $device->stpPorts;
|
ModuleModelObserver::observe(PortStp::class);
|
||||||
ModuleModelObserver::observe(PortStp::class);
|
$this->syncModels($device, 'stpPorts', $ports);
|
||||||
$this->syncModels($device, 'stpPorts', $ports);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function cleanup(Device $device): void
|
public function cleanup(Device $device): void
|
||||||
|
|
|
@ -92,7 +92,7 @@ class Ciscowlc extends Cisco implements
|
||||||
d_echo($ap->toArray());
|
d_echo($ap->toArray());
|
||||||
|
|
||||||
// if there is a numeric channel, assume the rest of the data is valid, I guess
|
// if there is a numeric channel, assume the rest of the data is valid, I guess
|
||||||
if (! is_numeric($ap->channel)) {
|
if (! is_numeric($channel)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ class Ifotec extends OS implements OSDiscovery
|
||||||
if (Str::startsWith($device->sysObjectID, '.1.3.6.1.4.1.21362.100.')) {
|
if (Str::startsWith($device->sysObjectID, '.1.3.6.1.4.1.21362.100.')) {
|
||||||
$ifoSysProductIndex = snmp_get($this->getDeviceArray(), 'ifoSysProductIndex.0', '-Oqv', 'IFOTEC-SMI');
|
$ifoSysProductIndex = snmp_get($this->getDeviceArray(), 'ifoSysProductIndex.0', '-Oqv', 'IFOTEC-SMI');
|
||||||
|
|
||||||
if ($ifoSysProductIndex !== null) {
|
if ($ifoSysProductIndex !== false) {
|
||||||
$oids = [
|
$oids = [
|
||||||
'ifoSysSerialNumber.' . $ifoSysProductIndex,
|
'ifoSysSerialNumber.' . $ifoSysProductIndex,
|
||||||
'ifoSysFirmware.' . $ifoSysProductIndex,
|
'ifoSysFirmware.' . $ifoSysProductIndex,
|
||||||
|
|
|
@ -107,7 +107,7 @@ class Iosxe extends Ciscowlc implements
|
||||||
'isisISAdjAreaAddress' => implode(',', array_map([$this, 'formatIsIsId'], $adjacency_data['CISCO-IETF-ISIS-MIB::ciiISAdjAreaAddress'] ?? [])),
|
'isisISAdjAreaAddress' => implode(',', array_map([$this, 'formatIsIsId'], $adjacency_data['CISCO-IETF-ISIS-MIB::ciiISAdjAreaAddress'] ?? [])),
|
||||||
'isisISAdjIPAddrType' => implode(',', $adjacency_data['CISCO-IETF-ISIS-MIB::ciiISAdjIPAddrType'] ?? []),
|
'isisISAdjIPAddrType' => implode(',', $adjacency_data['CISCO-IETF-ISIS-MIB::ciiISAdjIPAddrType'] ?? []),
|
||||||
'isisISAdjIPAddrAddress' => implode(',', array_map(function ($ip) {
|
'isisISAdjIPAddrAddress' => implode(',', array_map(function ($ip) {
|
||||||
return (string) IP::fromHexstring($ip, true);
|
return (string) IP::fromHexString($ip, true);
|
||||||
}, $adjacency_data['CISCO-IETF-ISIS-MIB::ciiISAdjIPAddrAddress'] ?? [])),
|
}, $adjacency_data['CISCO-IETF-ISIS-MIB::ciiISAdjIPAddrAddress'] ?? [])),
|
||||||
]));
|
]));
|
||||||
}
|
}
|
||||||
|
|
|
@ -431,7 +431,7 @@ class Cisco extends OS implements
|
||||||
|
|
||||||
// Lets process each SLA
|
// Lets process each SLA
|
||||||
$unixtime = intval(($data[$sla_nr]['rttMonLatestRttOperTime'] / 100 + $time_offset));
|
$unixtime = intval(($data[$sla_nr]['rttMonLatestRttOperTime'] / 100 + $time_offset));
|
||||||
$time = strftime('%Y-%m-%d %H:%M:%S', $unixtime);
|
$time = date('Y-m-d H:i:s', $unixtime);
|
||||||
|
|
||||||
// Save data
|
// Save data
|
||||||
$sla->rtt = $data[$sla_nr]['rttMonLatestRttOperCompletionTime'];
|
$sla->rtt = $data[$sla_nr]['rttMonLatestRttOperCompletionTime'];
|
||||||
|
|
|
@ -40,7 +40,7 @@ trait FrogfootResources
|
||||||
return [
|
return [
|
||||||
Processor::discover(
|
Processor::discover(
|
||||||
$this->getName(),
|
$this->getName(),
|
||||||
$this->getDeviceID(),
|
$this->getDeviceId(),
|
||||||
'1.3.6.1.4.1.10002.1.1.1.4.2.1.3.2',
|
'1.3.6.1.4.1.10002.1.1.1.4.2.1.3.2',
|
||||||
0
|
0
|
||||||
),
|
),
|
||||||
|
|
|
@ -260,6 +260,7 @@ class Proc
|
||||||
*/
|
*/
|
||||||
public function isRunning()
|
public function isRunning()
|
||||||
{
|
{
|
||||||
|
/* @phpstan-ignore-next-line */
|
||||||
if (! is_resource($this->_process)) {
|
if (! is_resource($this->_process)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,7 +75,6 @@ class Clean
|
||||||
*/
|
*/
|
||||||
public static function html($value, $purifier_config = [])
|
public static function html($value, $purifier_config = [])
|
||||||
{
|
{
|
||||||
/** @var HTMLPurifier $purifier */
|
|
||||||
static $purifier;
|
static $purifier;
|
||||||
|
|
||||||
// If $purifier_config is non-empty then we don't want
|
// If $purifier_config is non-empty then we don't want
|
||||||
|
|
|
@ -74,7 +74,7 @@ class AboutController extends Controller
|
||||||
'version_local' => $version->local(),
|
'version_local' => $version->local(),
|
||||||
'version_database' => $version->databaseServer(),
|
'version_database' => $version->databaseServer(),
|
||||||
'version_php' => phpversion(),
|
'version_php' => phpversion(),
|
||||||
'version_laravel' => App::VERSION(),
|
'version_laravel' => App::version(),
|
||||||
'version_python' => $version->python(),
|
'version_python' => $version->python(),
|
||||||
'version_webserver' => $request->server('SERVER_SOFTWARE'),
|
'version_webserver' => $request->server('SERVER_SOFTWARE'),
|
||||||
'version_rrdtool' => Rrd::version(),
|
'version_rrdtool' => Rrd::version(),
|
||||||
|
|
|
@ -59,7 +59,7 @@ class VmInfoController implements DeviceTab
|
||||||
|
|
||||||
private static function getVms(Device $device)
|
private static function getVms(Device $device)
|
||||||
{
|
{
|
||||||
return $device->vmInfo()
|
return $device->vminfo()
|
||||||
->select('vmwVmDisplayName', 'vmwVmState', 'vmwVmGuestOS', 'vmwVmMemSize', 'vmwVmCpus')
|
->select('vmwVmDisplayName', 'vmwVmState', 'vmwVmGuestOS', 'vmwVmMemSize', 'vmwVmCpus')
|
||||||
->with('parentDevice')
|
->with('parentDevice')
|
||||||
->orderBy('vmwVmDisplayName')
|
->orderBy('vmwVmDisplayName')
|
||||||
|
|
|
@ -65,7 +65,7 @@ class DeviceGroup extends BaseModel
|
||||||
public function updateDevices()
|
public function updateDevices()
|
||||||
{
|
{
|
||||||
if ($this->type == 'dynamic') {
|
if ($this->type == 'dynamic') {
|
||||||
$this->devices()->sync(QueryBuilderFluentParser::fromJSON($this->rules)->toQuery()
|
$this->devices()->sync(QueryBuilderFluentParser::fromJson($this->rules)->toQuery()
|
||||||
->distinct()->pluck('devices.device_id'));
|
->distinct()->pluck('devices.device_id'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,7 +91,7 @@ class ServiceTemplate extends BaseModel
|
||||||
public function updateDevices()
|
public function updateDevices()
|
||||||
{
|
{
|
||||||
if ($this->type == 'dynamic') {
|
if ($this->type == 'dynamic') {
|
||||||
$this->devices()->sync(QueryBuilderFluentParser::fromJSON($this->rules)->toQuery()
|
$this->devices()->sync(QueryBuilderFluentParser::fromJson($this->rules)->toQuery()
|
||||||
->distinct()->pluck('devices.device_id'));
|
->distinct()->pluck('devices.device_id'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,9 +99,6 @@ class UserPref extends BaseModel
|
||||||
{
|
{
|
||||||
/** @var array */
|
/** @var array */
|
||||||
$keys = $this->getKeyName();
|
$keys = $this->getKeyName();
|
||||||
if (! is_array($keys)) {
|
|
||||||
return parent::setKeysForSaveQuery($query);
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach ($keys as $keyName) {
|
foreach ($keys as $keyName) {
|
||||||
$query->where($keyName, '=', $this->getKeyForSaveQuery($keyName));
|
$query->where($keyName, '=', $this->getKeyForSaveQuery($keyName));
|
||||||
|
|
|
@ -46,6 +46,7 @@ class ErrorReportingProvider extends \Facade\Ignition\IgnitionServiceProvider
|
||||||
|
|
||||||
public function boot(): void
|
public function boot(): void
|
||||||
{
|
{
|
||||||
|
/* @phpstan-ignore-next-line */
|
||||||
if (! method_exists(\Facade\FlareClient\Flare::class, 'filterReportsUsing')) {
|
if (! method_exists(\Facade\FlareClient\Flare::class, 'filterReportsUsing')) {
|
||||||
Log::debug("Flare client too old, disabling Ignition to avoid bug.\n");
|
Log::debug("Flare client too old, disabling Ignition to avoid bug.\n");
|
||||||
|
|
||||||
|
|
|
@ -353,8 +353,8 @@ function getHistoricTransferGraphData($bill_id)
|
||||||
$allowed_val = null;
|
$allowed_val = null;
|
||||||
|
|
||||||
foreach (dbFetchRows('SELECT * FROM `bill_history` WHERE `bill_id` = ? ORDER BY `bill_datefrom` DESC LIMIT 12', [$bill_id]) as $data) {
|
foreach (dbFetchRows('SELECT * FROM `bill_history` WHERE `bill_id` = ? ORDER BY `bill_datefrom` DESC LIMIT 12', [$bill_id]) as $data) {
|
||||||
$datefrom = strftime('%Y-%m-%d', strtotime($data['bill_datefrom']));
|
$datefrom = date('Y-m-d', strtotime($data['bill_datefrom']));
|
||||||
$dateto = strftime('%Y-%m-%d', strtotime($data['bill_dateto']));
|
$dateto = date('Y-m-d', strtotime($data['bill_dateto']));
|
||||||
$datelabel = $datefrom . ' - ' . $dateto;
|
$datelabel = $datefrom . ' - ' . $dateto;
|
||||||
|
|
||||||
array_push($ticklabels, $datelabel);
|
array_push($ticklabels, $datelabel);
|
||||||
|
@ -421,7 +421,7 @@ function getBillingBandwidthGraphData($bill_id, $bill_hist_id, $from, $to, $imgt
|
||||||
$average = 0;
|
$average = 0;
|
||||||
if ($imgtype == 'day') {
|
if ($imgtype == 'day') {
|
||||||
foreach (dbFetch('SELECT DISTINCT UNIX_TIMESTAMP(timestamp) as timestamp, SUM(delta) as traf_total, SUM(in_delta) as traf_in, SUM(out_delta) as traf_out FROM bill_data WHERE `bill_id` = ? AND `timestamp` >= FROM_UNIXTIME(?) AND `timestamp` <= FROM_UNIXTIME(?) GROUP BY DATE(timestamp) ORDER BY timestamp ASC', [$bill_id, $from, $to]) as $data) {
|
foreach (dbFetch('SELECT DISTINCT UNIX_TIMESTAMP(timestamp) as timestamp, SUM(delta) as traf_total, SUM(in_delta) as traf_in, SUM(out_delta) as traf_out FROM bill_data WHERE `bill_id` = ? AND `timestamp` >= FROM_UNIXTIME(?) AND `timestamp` <= FROM_UNIXTIME(?) GROUP BY DATE(timestamp) ORDER BY timestamp ASC', [$bill_id, $from, $to]) as $data) {
|
||||||
array_push($ticklabels, strftime('%Y-%m-%d', $data['timestamp']));
|
array_push($ticklabels, date('Y-m-d', $data['timestamp']));
|
||||||
array_push($in_data, isset($data['traf_in']) ? $data['traf_in'] : 0);
|
array_push($in_data, isset($data['traf_in']) ? $data['traf_in'] : 0);
|
||||||
array_push($out_data, isset($data['traf_out']) ? $data['traf_out'] : 0);
|
array_push($out_data, isset($data['traf_out']) ? $data['traf_out'] : 0);
|
||||||
array_push($tot_data, isset($data['traf_total']) ? $data['traf_total'] : 0);
|
array_push($tot_data, isset($data['traf_total']) ? $data['traf_total'] : 0);
|
||||||
|
@ -431,7 +431,7 @@ function getBillingBandwidthGraphData($bill_id, $bill_hist_id, $from, $to, $imgt
|
||||||
$ave_count = count($tot_data);
|
$ave_count = count($tot_data);
|
||||||
|
|
||||||
// Add empty items for the days not yet passed
|
// Add empty items for the days not yet passed
|
||||||
$days = (strftime('%e', date($to - $from)) - $ave_count - 1);
|
$days = (date('j', date($to - $from)) - $ave_count - 1);
|
||||||
for ($x = 0; $x < $days; $x++) {
|
for ($x = 0; $x < $days; $x++) {
|
||||||
array_push($ticklabels, '');
|
array_push($ticklabels, '');
|
||||||
array_push($in_data, 0);
|
array_push($in_data, 0);
|
||||||
|
|
|
@ -38,18 +38,7 @@ function read_var($name, &$array, $default = null)
|
||||||
{
|
{
|
||||||
if (isset($array[$name])) {
|
if (isset($array[$name])) {
|
||||||
if (is_array($array[$name])) {
|
if (is_array($array[$name])) {
|
||||||
if (get_magic_quotes_gpc()) {
|
return $array[$name];
|
||||||
$ret = [];
|
|
||||||
foreach ($array[$name] as $k => $v) {
|
|
||||||
$ret[stripslashes($k)] = stripslashes($v);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $ret;
|
|
||||||
} else {
|
|
||||||
return $array[$name];
|
|
||||||
}
|
|
||||||
} elseif (is_string($array[$name]) && get_magic_quotes_gpc()) {
|
|
||||||
return stripslashes($array[$name]);
|
|
||||||
} else {
|
} else {
|
||||||
return $array[$name];
|
return $array[$name];
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,9 +17,9 @@ for ($i = 0; $i < count($graph_data['ticklabels']); $i++) {
|
||||||
|
|
||||||
if (date('m', $start) == date('m', $end) && date('d', $start == 1)) {
|
if (date('m', $start) == date('m', $end) && date('d', $start == 1)) {
|
||||||
// Calendar months, omit the date and the end!
|
// Calendar months, omit the date and the end!
|
||||||
$graph_data['ticklabels'][$i] = strftime('%b %Y', $start);
|
$graph_data['ticklabels'][$i] = date('M Y', $start);
|
||||||
} else {
|
} else {
|
||||||
$graph_data['ticklabels'][$i] = strftime('%e %b %Y', $start) . "\n" . strftime('%e %b %Y', $end);
|
$graph_data['ticklabels'][$i] = date('j M Y', $start) . "\n" . date('j M Y', $end);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ for ($i = 0; $i < count($graph_data['ticklabels']); $i++) {
|
||||||
$date = strtotime($graph_data['ticklabels'][$i]);
|
$date = strtotime($graph_data['ticklabels'][$i]);
|
||||||
|
|
||||||
if ($vars['imgtype'] === 'day') {
|
if ($vars['imgtype'] === 'day') {
|
||||||
$graph_data['ticklabels'][$i] = strftime("%e\n%b", $date);
|
$graph_data['ticklabels'][$i] = date("j\nM", $date);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -104,7 +104,7 @@ foreach (dbFetchRows('SELECT * FROM `bill_history` WHERE `bill_id` = ? ORDER BY
|
||||||
echo '
|
echo '
|
||||||
<tr>
|
<tr>
|
||||||
<td></td>
|
<td></td>
|
||||||
<td><span style="font-weight: bold;" class="interface">' . strftime('%Y-%m-%d', strtotime($datefrom)) . ' to ' . strftime('%Y-%m-%d', strtotime($dateto)) . "</span></td>
|
<td><span style="font-weight: bold;" class="interface">' . date('Y-m-d', strtotime($datefrom)) . ' to ' . date('Y-m-d', strtotime($dateto)) . "</span></td>
|
||||||
<td>$type</td>
|
<td>$type</td>
|
||||||
<td>$allowed</td>
|
<td>$allowed</td>
|
||||||
<td>$in</td>
|
<td>$in</td>
|
||||||
|
|
|
@ -143,7 +143,7 @@ foreach (dbFetchRows($sql, $param) as $bill) {
|
||||||
$overuse_formatted = (($overuse <= 0) ? '-' : "<span style='color: #${background['left']}; font-weight: bold;'>$overuse_formatted</span>");
|
$overuse_formatted = (($overuse <= 0) ? '-' : "<span style='color: #${background['left']}; font-weight: bold;'>$overuse_formatted</span>");
|
||||||
|
|
||||||
$bill_name = "<a href='$url'><span style='font-weight: bold;' class='interface'>${bill['bill_name']}</span></a><br />" .
|
$bill_name = "<a href='$url'><span style='font-weight: bold;' class='interface'>${bill['bill_name']}</span></a><br />" .
|
||||||
strftime('%F', strtotime($datefrom)) . ' to ' . strftime('%F', strtotime($dateto));
|
date('Y-m-d', strtotime($datefrom)) . ' to ' . date('Y-m-d', strtotime($dateto));
|
||||||
$bar = print_percentage_bar(250, 20, $percent, null, 'ffffff', $background['left'], $percent . '%', 'ffffff', $background['right']);
|
$bar = print_percentage_bar(250, 20, $percent, null, 'ffffff', $background['left'], $percent . '%', 'ffffff', $background['right']);
|
||||||
$actions = '';
|
$actions = '';
|
||||||
|
|
||||||
|
|
|
@ -87,7 +87,7 @@ function parse_rss($feed)
|
||||||
'title'=>$item['title'],
|
'title'=>$item['title'],
|
||||||
'body'=>$item['description'],
|
'body'=>$item['description'],
|
||||||
'checksum'=>hash('sha512', $item['title'] . $item['description']),
|
'checksum'=>hash('sha512', $item['title'] . $item['description']),
|
||||||
'datetime'=>strftime('%F', strtotime($item['pubDate']) ?: time()),
|
'datetime'=>date('Y-m-d', strtotime($item['pubDate']) ?: time()),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,7 +111,7 @@ function parse_atom($feed)
|
||||||
'title'=>$item['title'],
|
'title'=>$item['title'],
|
||||||
'body'=>$item['content'],
|
'body'=>$item['content'],
|
||||||
'checksum'=>hash('sha512', $item['title'] . $item['content']),
|
'checksum'=>hash('sha512', $item['title'] . $item['content']),
|
||||||
'datetime'=>strftime('%F', strtotime($item['updated']) ?: time()),
|
'datetime'=>date('Y-m-d', strtotime($item['updated']) ?: time()),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,7 +136,7 @@ function new_notification($title, $message, $severity = 0, $source = 'adhoc', $d
|
||||||
'severity' => $severity,
|
'severity' => $severity,
|
||||||
'source' => $source,
|
'source' => $source,
|
||||||
'checksum' => hash('sha512', $title . $message),
|
'checksum' => hash('sha512', $title . $message),
|
||||||
'datetime' => strftime('%F', is_null($date) ? time() : strtotime($date)),
|
'datetime' => date('Y-m-d', is_null($date) ? time() : strtotime($date)),
|
||||||
];
|
];
|
||||||
|
|
||||||
if (dbFetchCell('SELECT 1 FROM `notifications` WHERE `checksum` = ?', [$notif['checksum']]) != 1) {
|
if (dbFetchCell('SELECT 1 FROM `notifications` WHERE `checksum` = ?', [$notif['checksum']]) != 1) {
|
||||||
|
|
|
@ -415,11 +415,6 @@ parameters:
|
||||||
count: 1
|
count: 1
|
||||||
path: LibreNMS/Alert/Transport/Linenotify.php
|
path: LibreNMS/Alert/Transport/Linenotify.php
|
||||||
|
|
||||||
-
|
|
||||||
message: "#^Method LibreNMS\\\\Alert\\\\Transport\\\\Linenotify\\:\\:contactLinenotify\\(\\) is unused\\.$#"
|
|
||||||
count: 1
|
|
||||||
path: LibreNMS/Alert/Transport/Linenotify.php
|
|
||||||
|
|
||||||
-
|
-
|
||||||
message: "#^Method LibreNMS\\\\Alert\\\\Transport\\\\Mail\\:\\:contactMail\\(\\) has no return type specified\\.$#"
|
message: "#^Method LibreNMS\\\\Alert\\\\Transport\\\\Mail\\:\\:contactMail\\(\\) has no return type specified\\.$#"
|
||||||
count: 1
|
count: 1
|
||||||
|
|
|
@ -3,26 +3,25 @@ includes:
|
||||||
- phpstan-baseline-deprecated.neon
|
- phpstan-baseline-deprecated.neon
|
||||||
|
|
||||||
parameters:
|
parameters:
|
||||||
phpVersion: 70300
|
|
||||||
|
|
||||||
customRulesetUsed: true
|
customRulesetUsed: true
|
||||||
reportUnmatchedIgnoredErrors: false
|
reportUnmatchedIgnoredErrors: false
|
||||||
resultCachePath: %tmpDir%/resultCache-deprecated.php
|
resultCachePath: %tmpDir%/resultCache-deprecated.php
|
||||||
|
|
||||||
paths:
|
paths:
|
||||||
- LibreNMS
|
- app
|
||||||
- bootstrap
|
- bootstrap
|
||||||
- cache
|
- cache
|
||||||
- html
|
|
||||||
- storage
|
|
||||||
- app
|
|
||||||
- config
|
- config
|
||||||
- database
|
- database
|
||||||
- doc
|
- doc
|
||||||
|
- html
|
||||||
- includes
|
- includes
|
||||||
|
- LibreNMS
|
||||||
- licenses
|
- licenses
|
||||||
- misc
|
- misc
|
||||||
- resources
|
- resources
|
||||||
- routes
|
- routes
|
||||||
- sql-schema
|
- sql-schema
|
||||||
|
- storage
|
||||||
- tests
|
- tests
|
||||||
|
|
11
phpstan.neon
11
phpstan.neon
|
@ -24,8 +24,19 @@ parameters:
|
||||||
checkMissingIterableValueType: false
|
checkMissingIterableValueType: false
|
||||||
treatPhpDocTypesAsCertain: false
|
treatPhpDocTypesAsCertain: false
|
||||||
|
|
||||||
|
checkFunctionNameCase: true
|
||||||
|
checkInternalClassCaseSensitivity: true
|
||||||
|
|
||||||
|
checkModelProperties: true
|
||||||
|
|
||||||
|
checkAlwaysTrueCheckTypeFunctionCall: true
|
||||||
|
checkAlwaysTrueInstanceof: true
|
||||||
|
checkAlwaysTrueStrictComparison: true
|
||||||
|
|
||||||
ignoreErrors:
|
ignoreErrors:
|
||||||
- '#Unsafe usage of new static#'
|
- '#Unsafe usage of new static#'
|
||||||
|
|
||||||
parallel:
|
parallel:
|
||||||
processTimeout: 300.0
|
processTimeout: 300.0
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ if (php_sapi_name() === 'cli') {
|
||||||
require realpath(__DIR__ . '/..') . '/includes/init.php';
|
require realpath(__DIR__ . '/..') . '/includes/init.php';
|
||||||
|
|
||||||
$return = \Artisan::call('smokeping:generate --targets --no-header --no-dns --single-process --compat');
|
$return = \Artisan::call('smokeping:generate --targets --no-header --no-dns --single-process --compat');
|
||||||
echo \Artisan::Output();
|
echo \Artisan::output();
|
||||||
|
|
||||||
exit($return);
|
exit($return);
|
||||||
}
|
}
|
||||||
|
|
|
@ -139,7 +139,7 @@ class MibTest extends TestCase
|
||||||
if ($file->isDir()) {
|
if ($file->isDir()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$mib_path = str_replace(Config::get('mib_dir') . '/', '', $file->getPathName());
|
$mib_path = str_replace(Config::get('mib_dir') . '/', '', $file->getPathname());
|
||||||
$file_list[$mib_path] = [
|
$file_list[$mib_path] = [
|
||||||
str_replace(Config::get('install_dir'), '.', $file->getPath()),
|
str_replace(Config::get('install_dir'), '.', $file->getPath()),
|
||||||
$file->getFilename(),
|
$file->getFilename(),
|
||||||
|
|
|
@ -342,7 +342,7 @@ class SmokepingCliTest extends DBTestCase
|
||||||
|
|
||||||
// Disable DNS lookups
|
// Disable DNS lookups
|
||||||
\Artisan::call('smokeping:generate --targets --no-header --no-dns --single-process --compat');
|
\Artisan::call('smokeping:generate --targets --no-header --no-dns --single-process --compat');
|
||||||
$new = \Artisan::Output();
|
$new = \Artisan::output();
|
||||||
$old = $this->legacyAlgo($data);
|
$old = $this->legacyAlgo($data);
|
||||||
|
|
||||||
$this->assertEquals($this->canonicalise($new), $this->canonicalise($old));
|
$this->assertEquals($this->canonicalise($new), $this->canonicalise($old));
|
||||||
|
|
|
@ -4,3 +4,8 @@ parameters:
|
||||||
- "#^Method LibreNMS\\\\Authentication\\\\LdapAuthorizer\\:\\:getLdapConnection\\(\\) has invalid return type LDAP\\\\Connection\\.$#"
|
- "#^Method LibreNMS\\\\Authentication\\\\LdapAuthorizer\\:\\:getLdapConnection\\(\\) has invalid return type LDAP\\\\Connection\\.$#"
|
||||||
|
|
||||||
- "#^Parameter \\#1 \\$ldap of function ldap_.* expects (array\\|)?resource, LDAP\\\\Connection given\\.$#"
|
- "#^Parameter \\#1 \\$ldap of function ldap_.* expects (array\\|)?resource, LDAP\\\\Connection given\\.$#"
|
||||||
|
|
||||||
|
-
|
||||||
|
message: "#^Call to an undefined static method Illuminate\\\\Support\\\\Facades\\\\Redis\\:\\:ping()\\.$#"
|
||||||
|
count: 1
|
||||||
|
path: ../../LibreNMS/Validations/Poller/CheckRedis.php
|
||||||
|
|
Loading…
Reference in New Issue