diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index cae51a7e27..30077972c1 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -76,8 +76,8 @@ jobs: - 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 - 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 diff --git a/LibreNMS/Alert/Transport/Elasticsearch.php b/LibreNMS/Alert/Transport/Elasticsearch.php index 3e3a9a5ab6..0aab6aaafa 100644 --- a/LibreNMS/Alert/Transport/Elasticsearch.php +++ b/LibreNMS/Alert/Transport/Elasticsearch.php @@ -39,7 +39,7 @@ class Elasticsearch extends Transport { $es_host = '127.0.0.1'; $es_port = 9200; - $index = strftime('librenms-%Y.%m.%d'); + $index = date("\l\i\b\\r\\e\\n\m\s\-Y.m.d"); $type = 'alert'; $severity = $obj['severity']; @@ -61,7 +61,7 @@ class Elasticsearch extends Transport } if (! empty($opts['es_index'])) { - $index = strftime($opts['es_index']); + $index = date($opts['es_index']); } $host = $es_host . ':' . $es_port . '/' . $index . '/' . $type; @@ -222,7 +222,7 @@ class Elasticsearch extends Transport [ 'title' => 'Index 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', ], [ diff --git a/LibreNMS/Alert/Transport/Linenotify.php b/LibreNMS/Alert/Transport/Linenotify.php index 2014104ae3..46b3348e68 100644 --- a/LibreNMS/Alert/Transport/Linenotify.php +++ b/LibreNMS/Alert/Transport/Linenotify.php @@ -16,7 +16,7 @@ class Linenotify extends Transport { $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) diff --git a/LibreNMS/Alert/Transport/Twilio.php b/LibreNMS/Alert/Transport/Twilio.php index 23aa7b2d6c..7f88783305 100644 --- a/LibreNMS/Alert/Transport/Twilio.php +++ b/LibreNMS/Alert/Transport/Twilio.php @@ -27,7 +27,7 @@ class Twilio extends Transport $twilio_opts['sender'] = $this->config['twilio-sender']; $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) diff --git a/LibreNMS/Authentication/SSOAuthorizer.php b/LibreNMS/Authentication/SSOAuthorizer.php index e5384c165e..22b92cb415 100644 --- a/LibreNMS/Authentication/SSOAuthorizer.php +++ b/LibreNMS/Authentication/SSOAuthorizer.php @@ -124,10 +124,10 @@ class SSOAuthorizer extends MysqlAuthorizer foreach ($proxies as $value) { $proxy = IP::parse($value); 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 return true; } diff --git a/LibreNMS/Data/Store/Rrd.php b/LibreNMS/Data/Store/Rrd.php index 92dae88252..5ce88c6d64 100644 --- a/LibreNMS/Data/Store/Rrd.php +++ b/LibreNMS/Data/Store/Rrd.php @@ -460,7 +460,7 @@ class Rrd extends BaseDatastore public function getRrdFiles($device) { if ($this->rrdcached) { - $filename = sprintf('/%s', self::safename($device['hostname'])); + $filename = sprintf('/%s', self::safeName($device['hostname'])); $rrd_files = $this->command('list', $filename, ''); // 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])); diff --git a/LibreNMS/Device/Processor.php b/LibreNMS/Device/Processor.php index 429c3276c7..37189b620f 100644 --- a/LibreNMS/Device/Processor.php +++ b/LibreNMS/Device/Processor.php @@ -28,7 +28,6 @@ namespace LibreNMS\Device; use Illuminate\Support\Str; use LibreNMS\Interfaces\Discovery\DiscoveryItem; use LibreNMS\Interfaces\Discovery\DiscoveryModule; -use LibreNMS\Interfaces\Discovery\ProcessorDiscovery; use LibreNMS\Interfaces\Polling\PollerModule; use LibreNMS\Interfaces\Polling\ProcessorPolling; use LibreNMS\Model; @@ -142,7 +141,7 @@ class Processor extends Model implements DiscoveryModule, PollerModule, Discover $processors = self::processYaml($os); // 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(); } diff --git a/LibreNMS/Modules/Isis.php b/LibreNMS/Modules/Isis.php index 1081a6418c..a5cb70ed5b 100644 --- a/LibreNMS/Modules/Isis.php +++ b/LibreNMS/Modules/Isis.php @@ -144,7 +144,7 @@ class Isis implements Module 'isisISAdjLastUpTime' => $this->parseAdjacencyTime($adjacency_data), 'isisISAdjAreaAddress' => str_replace(' ', '.', trim($adjacency_data['isisISAdjAreaAddress'] ?? '')), 'isisISAdjIPAddrType' => $adjacency_data['isisISAdjIPAddrType'] ?? '', - 'isisISAdjIPAddrAddress' => (string) IP::fromHexstring($adjacency_data['isisISAdjIPAddrAddress'] ?? null, true), + 'isisISAdjIPAddrAddress' => (string) IP::fromHexString($adjacency_data['isisISAdjIPAddrAddress'] ?? null, true), ]); } diff --git a/LibreNMS/Modules/Mempools.php b/LibreNMS/Modules/Mempools.php index b5e394ec69..697427174f 100644 --- a/LibreNMS/Modules/Mempools.php +++ b/LibreNMS/Modules/Mempools.php @@ -30,7 +30,6 @@ use App\Models\Mempool; use App\Observers\MempoolObserver; use Illuminate\Support\Collection; use LibreNMS\DB\SyncsModels; -use LibreNMS\Interfaces\Discovery\MempoolsDiscovery; use LibreNMS\Interfaces\Module; use LibreNMS\Interfaces\Polling\MempoolsPolling; use LibreNMS\OS; @@ -52,25 +51,23 @@ class Mempools implements Module public function discover(OS $os): void { - if ($os instanceof MempoolsDiscovery) { - $mempools = $os->discoverMempools()->filter(function (Mempool $mempool) { - if ($mempool->isValid()) { - return true; - } - Log::debug("Rejecting Mempool $mempool->mempool_index $mempool->mempool_descr: Invalid total value"); + $mempools = $os->discoverMempools()->filter(function (Mempool $mempool) { + if ($mempool->isValid()) { + return true; + } + Log::debug("Rejecting Mempool $mempool->mempool_index $mempool->mempool_descr: Invalid total value"); - return false; - }); - $this->calculateAvailable($mempools); + return false; + }); + $this->calculateAvailable($mempools); - MempoolObserver::observe('\App\Models\Mempool'); - $this->syncModels($os->getDevice(), 'mempools', $mempools); + MempoolObserver::observe('\App\Models\Mempool'); + $this->syncModels($os->getDevice(), 'mempools', $mempools); - echo PHP_EOL; - $mempools->each(function ($mempool) { - $this->printMempool($mempool); - }); - } + echo PHP_EOL; + $mempools->each(function ($mempool) { + $this->printMempool($mempool); + }); } public function poll(OS $os): void diff --git a/LibreNMS/Modules/Stp.php b/LibreNMS/Modules/Stp.php index e31f0cadb3..3e373db567 100644 --- a/LibreNMS/Modules/Stp.php +++ b/LibreNMS/Modules/Stp.php @@ -29,11 +29,7 @@ use App\Models\Device; use App\Models\PortStp; use App\Observers\ModuleModelObserver; use LibreNMS\DB\SyncsModels; -use LibreNMS\Interfaces\Discovery\StpInstanceDiscovery; -use LibreNMS\Interfaces\Discovery\StpPortDiscovery; use LibreNMS\Interfaces\Module; -use LibreNMS\Interfaces\Polling\StpInstancePolling; -use LibreNMS\Interfaces\Polling\StpPortPolling; use LibreNMS\OS; class Stp implements Module @@ -52,40 +48,33 @@ class Stp implements Module { $device = $os->getDevice(); - if ($os instanceof StpInstanceDiscovery) { - echo 'Instances: '; - $instances = $os->discoverStpInstances(); - ModuleModelObserver::observe(\App\Models\Stp::class); - $this->syncModels($device, 'stpInstances', $instances); + echo 'Instances: '; + $instances = $os->discoverStpInstances(); + ModuleModelObserver::observe(\App\Models\Stp::class); + $this->syncModels($device, 'stpInstances', $instances); - if ($os instanceof StpPortDiscovery) { - echo "\nPorts: "; - $ports = $os->discoverStpPorts($instances); - ModuleModelObserver::observe(PortStp::class); - $this->syncModels($device, 'stpPorts', $ports); - } - echo PHP_EOL; - } + echo "\nPorts: "; + $ports = $os->discoverStpPorts($instances); + ModuleModelObserver::observe(PortStp::class); + $this->syncModels($device, 'stpPorts', $ports); + + echo PHP_EOL; } public function poll(OS $os): void { $device = $os->getDevice(); - if ($os instanceof StpInstancePolling) { - echo 'Instances: '; - $instances = $device->stpInstances; - $instances = $os->pollStpInstances($instances); - ModuleModelObserver::observe(\App\Models\Stp::class); - $this->syncModels($device, 'stpInstances', $instances); - } + echo 'Instances: '; + $instances = $device->stpInstances; + $instances = $os->pollStpInstances($instances); + ModuleModelObserver::observe(\App\Models\Stp::class); + $this->syncModels($device, 'stpInstances', $instances); - if ($os instanceof StpPortPolling) { - echo "\nPorts: "; - $ports = $device->stpPorts; - ModuleModelObserver::observe(PortStp::class); - $this->syncModels($device, 'stpPorts', $ports); - } + echo "\nPorts: "; + $ports = $device->stpPorts; + ModuleModelObserver::observe(PortStp::class); + $this->syncModels($device, 'stpPorts', $ports); } public function cleanup(Device $device): void diff --git a/LibreNMS/OS/Ciscowlc.php b/LibreNMS/OS/Ciscowlc.php index 5b5279258a..d679a21fa5 100644 --- a/LibreNMS/OS/Ciscowlc.php +++ b/LibreNMS/OS/Ciscowlc.php @@ -92,7 +92,7 @@ class Ciscowlc extends Cisco implements d_echo($ap->toArray()); // 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; } diff --git a/LibreNMS/OS/Ifotec.php b/LibreNMS/OS/Ifotec.php index fd903a310d..7529854c28 100644 --- a/LibreNMS/OS/Ifotec.php +++ b/LibreNMS/OS/Ifotec.php @@ -37,7 +37,7 @@ class Ifotec extends OS implements OSDiscovery if (Str::startsWith($device->sysObjectID, '.1.3.6.1.4.1.21362.100.')) { $ifoSysProductIndex = snmp_get($this->getDeviceArray(), 'ifoSysProductIndex.0', '-Oqv', 'IFOTEC-SMI'); - if ($ifoSysProductIndex !== null) { + if ($ifoSysProductIndex !== false) { $oids = [ 'ifoSysSerialNumber.' . $ifoSysProductIndex, 'ifoSysFirmware.' . $ifoSysProductIndex, diff --git a/LibreNMS/OS/Iosxe.php b/LibreNMS/OS/Iosxe.php index fdce1e97fc..7725847a27 100644 --- a/LibreNMS/OS/Iosxe.php +++ b/LibreNMS/OS/Iosxe.php @@ -107,7 +107,7 @@ class Iosxe extends Ciscowlc implements 'isisISAdjAreaAddress' => implode(',', array_map([$this, 'formatIsIsId'], $adjacency_data['CISCO-IETF-ISIS-MIB::ciiISAdjAreaAddress'] ?? [])), 'isisISAdjIPAddrType' => implode(',', $adjacency_data['CISCO-IETF-ISIS-MIB::ciiISAdjIPAddrType'] ?? []), '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'] ?? [])), ])); } diff --git a/LibreNMS/OS/Shared/Cisco.php b/LibreNMS/OS/Shared/Cisco.php index 20bf37c7fc..d86fa5e46c 100755 --- a/LibreNMS/OS/Shared/Cisco.php +++ b/LibreNMS/OS/Shared/Cisco.php @@ -431,7 +431,7 @@ class Cisco extends OS implements // Lets process each SLA $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 $sla->rtt = $data[$sla_nr]['rttMonLatestRttOperCompletionTime']; diff --git a/LibreNMS/OS/Traits/FrogfootResources.php b/LibreNMS/OS/Traits/FrogfootResources.php index 2c8f183689..487f88d96e 100644 --- a/LibreNMS/OS/Traits/FrogfootResources.php +++ b/LibreNMS/OS/Traits/FrogfootResources.php @@ -40,7 +40,7 @@ trait FrogfootResources return [ Processor::discover( $this->getName(), - $this->getDeviceID(), + $this->getDeviceId(), '1.3.6.1.4.1.10002.1.1.1.4.2.1.3.2', 0 ), diff --git a/LibreNMS/Proc.php b/LibreNMS/Proc.php index c5c5a32cd3..867f4abe99 100644 --- a/LibreNMS/Proc.php +++ b/LibreNMS/Proc.php @@ -260,6 +260,7 @@ class Proc */ public function isRunning() { + /* @phpstan-ignore-next-line */ if (! is_resource($this->_process)) { return false; } diff --git a/LibreNMS/Util/Clean.php b/LibreNMS/Util/Clean.php index 0b8dc675de..e421b56390 100644 --- a/LibreNMS/Util/Clean.php +++ b/LibreNMS/Util/Clean.php @@ -75,7 +75,6 @@ class Clean */ public static function html($value, $purifier_config = []) { - /** @var HTMLPurifier $purifier */ static $purifier; // If $purifier_config is non-empty then we don't want diff --git a/app/Http/Controllers/AboutController.php b/app/Http/Controllers/AboutController.php index 9059720aac..3591fd4cbd 100644 --- a/app/Http/Controllers/AboutController.php +++ b/app/Http/Controllers/AboutController.php @@ -74,7 +74,7 @@ class AboutController extends Controller 'version_local' => $version->local(), 'version_database' => $version->databaseServer(), 'version_php' => phpversion(), - 'version_laravel' => App::VERSION(), + 'version_laravel' => App::version(), 'version_python' => $version->python(), 'version_webserver' => $request->server('SERVER_SOFTWARE'), 'version_rrdtool' => Rrd::version(), diff --git a/app/Http/Controllers/Device/Tabs/VmInfoController.php b/app/Http/Controllers/Device/Tabs/VmInfoController.php index 6974cb7386..3bfb8ec833 100644 --- a/app/Http/Controllers/Device/Tabs/VmInfoController.php +++ b/app/Http/Controllers/Device/Tabs/VmInfoController.php @@ -59,7 +59,7 @@ class VmInfoController implements DeviceTab private static function getVms(Device $device) { - return $device->vmInfo() + return $device->vminfo() ->select('vmwVmDisplayName', 'vmwVmState', 'vmwVmGuestOS', 'vmwVmMemSize', 'vmwVmCpus') ->with('parentDevice') ->orderBy('vmwVmDisplayName') diff --git a/app/Models/DeviceGroup.php b/app/Models/DeviceGroup.php index e932dffb51..b9c64dc7aa 100644 --- a/app/Models/DeviceGroup.php +++ b/app/Models/DeviceGroup.php @@ -65,7 +65,7 @@ class DeviceGroup extends BaseModel public function updateDevices() { 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')); } } diff --git a/app/Models/ServiceTemplate.php b/app/Models/ServiceTemplate.php index 236e65dcf3..e3e7327da3 100644 --- a/app/Models/ServiceTemplate.php +++ b/app/Models/ServiceTemplate.php @@ -91,7 +91,7 @@ class ServiceTemplate extends BaseModel public function updateDevices() { 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')); } } diff --git a/app/Models/UserPref.php b/app/Models/UserPref.php index 4903fea217..17f23d94bd 100644 --- a/app/Models/UserPref.php +++ b/app/Models/UserPref.php @@ -99,9 +99,6 @@ class UserPref extends BaseModel { /** @var array */ $keys = $this->getKeyName(); - if (! is_array($keys)) { - return parent::setKeysForSaveQuery($query); - } foreach ($keys as $keyName) { $query->where($keyName, '=', $this->getKeyForSaveQuery($keyName)); diff --git a/app/Providers/ErrorReportingProvider.php b/app/Providers/ErrorReportingProvider.php index ff5ce6418a..10b383c68d 100644 --- a/app/Providers/ErrorReportingProvider.php +++ b/app/Providers/ErrorReportingProvider.php @@ -46,6 +46,7 @@ class ErrorReportingProvider extends \Facade\Ignition\IgnitionServiceProvider public function boot(): void { + /* @phpstan-ignore-next-line */ if (! method_exists(\Facade\FlareClient\Flare::class, 'filterReportsUsing')) { Log::debug("Flare client too old, disabling Ignition to avoid bug.\n"); diff --git a/includes/billing.php b/includes/billing.php index 36c32e98cf..aebfa8c57f 100644 --- a/includes/billing.php +++ b/includes/billing.php @@ -353,8 +353,8 @@ function getHistoricTransferGraphData($bill_id) $allowed_val = null; 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'])); - $dateto = strftime('%Y-%m-%d', strtotime($data['bill_dateto'])); + $datefrom = date('Y-m-d', strtotime($data['bill_datefrom'])); + $dateto = date('Y-m-d', strtotime($data['bill_dateto'])); $datelabel = $datefrom . ' - ' . $dateto; array_push($ticklabels, $datelabel); @@ -421,7 +421,7 @@ function getBillingBandwidthGraphData($bill_id, $bill_hist_id, $from, $to, $imgt $average = 0; 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) { - 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($out_data, isset($data['traf_out']) ? $data['traf_out'] : 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); // 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++) { array_push($ticklabels, ''); array_push($in_data, 0); diff --git a/includes/html/collectd/functions.php b/includes/html/collectd/functions.php index f2859eee25..2402ae0db0 100644 --- a/includes/html/collectd/functions.php +++ b/includes/html/collectd/functions.php @@ -38,18 +38,7 @@ function read_var($name, &$array, $default = null) { if (isset($array[$name])) { if (is_array($array[$name])) { - if (get_magic_quotes_gpc()) { - $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]); + return $array[$name]; } else { return $array[$name]; } diff --git a/includes/html/graphs/bill/historicmonthly.inc.php b/includes/html/graphs/bill/historicmonthly.inc.php index 371df16e08..71891fea91 100644 --- a/includes/html/graphs/bill/historicmonthly.inc.php +++ b/includes/html/graphs/bill/historicmonthly.inc.php @@ -17,9 +17,9 @@ for ($i = 0; $i < count($graph_data['ticklabels']); $i++) { if (date('m', $start) == date('m', $end) && date('d', $start == 1)) { // 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 { - $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); } } } diff --git a/includes/html/graphs/bill/historictransfer.inc.php b/includes/html/graphs/bill/historictransfer.inc.php index f56a4cf01c..750cd89635 100644 --- a/includes/html/graphs/bill/historictransfer.inc.php +++ b/includes/html/graphs/bill/historictransfer.inc.php @@ -21,7 +21,7 @@ for ($i = 0; $i < count($graph_data['ticklabels']); $i++) { $date = strtotime($graph_data['ticklabels'][$i]); if ($vars['imgtype'] === 'day') { - $graph_data['ticklabels'][$i] = strftime("%e\n%b", $date); + $graph_data['ticklabels'][$i] = date("j\nM", $date); } } } diff --git a/includes/html/pages/bill/history.inc.php b/includes/html/pages/bill/history.inc.php index 2d0c7ef694..4283d92feb 100644 --- a/includes/html/pages/bill/history.inc.php +++ b/includes/html/pages/bill/history.inc.php @@ -104,7 +104,7 @@ foreach (dbFetchRows('SELECT * FROM `bill_history` WHERE `bill_id` = ? ORDER BY echo ' - ' . strftime('%Y-%m-%d', strtotime($datefrom)) . ' to ' . strftime('%Y-%m-%d', strtotime($dateto)) . " + ' . date('Y-m-d', strtotime($datefrom)) . ' to ' . date('Y-m-d', strtotime($dateto)) . " $type $allowed $in diff --git a/includes/html/table/bills.inc.php b/includes/html/table/bills.inc.php index e51e4147de..da0bcbd884 100644 --- a/includes/html/table/bills.inc.php +++ b/includes/html/table/bills.inc.php @@ -143,7 +143,7 @@ foreach (dbFetchRows($sql, $param) as $bill) { $overuse_formatted = (($overuse <= 0) ? '-' : "$overuse_formatted"); $bill_name = "${bill['bill_name']}
" . - 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']); $actions = ''; diff --git a/includes/notifications.php b/includes/notifications.php index bdd68fdd59..5035e3e34d 100644 --- a/includes/notifications.php +++ b/includes/notifications.php @@ -87,7 +87,7 @@ function parse_rss($feed) 'title'=>$item['title'], 'body'=>$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'], 'body'=>$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, 'source' => $source, '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) { diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 5e4a2bcce3..ad956d5869 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -415,11 +415,6 @@ parameters: count: 1 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\\.$#" count: 1 diff --git a/phpstan-deprecated.neon b/phpstan-deprecated.neon index de7f5dbb91..a8dc14e921 100644 --- a/phpstan-deprecated.neon +++ b/phpstan-deprecated.neon @@ -3,26 +3,25 @@ includes: - phpstan-baseline-deprecated.neon parameters: - phpVersion: 70300 customRulesetUsed: true reportUnmatchedIgnoredErrors: false resultCachePath: %tmpDir%/resultCache-deprecated.php paths: - - LibreNMS + - app - bootstrap - cache - - html - - storage - - app - config - database - doc + - html - includes + - LibreNMS - licenses - misc - resources - routes - sql-schema + - storage - tests diff --git a/phpstan.neon b/phpstan.neon index dfde96b3e2..38b6c23589 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -24,8 +24,19 @@ parameters: checkMissingIterableValueType: false treatPhpDocTypesAsCertain: false + checkFunctionNameCase: true + checkInternalClassCaseSensitivity: true + + checkModelProperties: true + + checkAlwaysTrueCheckTypeFunctionCall: true + checkAlwaysTrueInstanceof: true + checkAlwaysTrueStrictComparison: true + ignoreErrors: - '#Unsafe usage of new static#' parallel: processTimeout: 300.0 + + diff --git a/scripts/gen_smokeping.php b/scripts/gen_smokeping.php index 522521718b..8670670380 100755 --- a/scripts/gen_smokeping.php +++ b/scripts/gen_smokeping.php @@ -28,7 +28,7 @@ if (php_sapi_name() === 'cli') { require realpath(__DIR__ . '/..') . '/includes/init.php'; $return = \Artisan::call('smokeping:generate --targets --no-header --no-dns --single-process --compat'); - echo \Artisan::Output(); + echo \Artisan::output(); exit($return); } diff --git a/tests/MibTest.php b/tests/MibTest.php index 60f144d6cd..ce53adeee2 100644 --- a/tests/MibTest.php +++ b/tests/MibTest.php @@ -139,7 +139,7 @@ class MibTest extends TestCase if ($file->isDir()) { 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] = [ str_replace(Config::get('install_dir'), '.', $file->getPath()), $file->getFilename(), diff --git a/tests/SmokepingCliTest.php b/tests/SmokepingCliTest.php index 6a1fabca33..62c94dccfb 100644 --- a/tests/SmokepingCliTest.php +++ b/tests/SmokepingCliTest.php @@ -342,7 +342,7 @@ class SmokepingCliTest extends DBTestCase // Disable DNS lookups \Artisan::call('smokeping:generate --targets --no-header --no-dns --single-process --compat'); - $new = \Artisan::Output(); + $new = \Artisan::output(); $old = $this->legacyAlgo($data); $this->assertEquals($this->canonicalise($new), $this->canonicalise($old)); diff --git a/tests/phpstan/phpstan-php80.neon b/tests/phpstan/phpstan-php80.neon index ec6411bae9..68098e6216 100644 --- a/tests/phpstan/phpstan-php80.neon +++ b/tests/phpstan/phpstan-php80.neon @@ -4,3 +4,8 @@ parameters: - "#^Method LibreNMS\\\\Authentication\\\\LdapAuthorizer\\:\\:getLdapConnection\\(\\) has invalid return type LDAP\\\\Connection\\.$#" - "#^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