Address PHPStan warning in 'classes/pref/system.php'.

This commit is contained in:
wn_ 2021-11-14 20:26:21 +00:00
parent abab2a94e8
commit 5632d75a45
1 changed files with 9 additions and 10 deletions

View File

@ -2,7 +2,7 @@
class Pref_System extends Handler_Administrative { class Pref_System extends Handler_Administrative {
private $log_page_limit = 15; private const LOG_PAGE_LIMIT = 15;
function csrf_ignore(string $method): bool { function csrf_ignore(string $method): bool {
$csrf_ignored = array("index"); $csrf_ignored = array("index");
@ -10,11 +10,11 @@ class Pref_System extends Handler_Administrative {
return array_search($method, $csrf_ignored) !== false; return array_search($method, $csrf_ignored) !== false;
} }
function clearLog() { function clearLog(): void {
$this->pdo->query("DELETE FROM ttrss_error_log"); $this->pdo->query("DELETE FROM ttrss_error_log");
} }
function sendTestEmail() { function sendTestEmail(): void {
$mail_address = clean($_REQUEST["mail_address"]); $mail_address = clean($_REQUEST["mail_address"]);
$mailer = new Mailer(); $mailer = new Mailer();
@ -28,7 +28,7 @@ class Pref_System extends Handler_Administrative {
print json_encode(['rc' => $rc, 'error' => $mailer->error()]); print json_encode(['rc' => $rc, 'error' => $mailer->error()]);
} }
function getphpinfo() { function getphpinfo(): void {
ob_start(); ob_start();
phpinfo(); phpinfo();
$info = ob_get_contents(); $info = ob_get_contents();
@ -37,7 +37,7 @@ class Pref_System extends Handler_Administrative {
print preg_replace( '%^.*<body>(.*)</body>.*$%ms','$1', (string)$info); print preg_replace( '%^.*<body>(.*)</body>.*$%ms','$1', (string)$info);
} }
private function _log_viewer(int $page, int $severity) { private function _log_viewer(int $page, int $severity): void {
$errno_values = []; $errno_values = [];
switch ($severity) { switch ($severity) {
@ -56,8 +56,7 @@ class Pref_System extends Handler_Administrative {
$errno_filter_qpart = "true"; $errno_filter_qpart = "true";
} }
$limit = $this->log_page_limit; $offset = self::LOG_PAGE_LIMIT * $page;
$offset = $limit * $page;
$sth = $this->pdo->prepare("SELECT $sth = $this->pdo->prepare("SELECT
COUNT(id) AS total_pages COUNT(id) AS total_pages
@ -69,7 +68,7 @@ class Pref_System extends Handler_Administrative {
$sth->execute($errno_values); $sth->execute($errno_values);
if ($res = $sth->fetch()) { if ($res = $sth->fetch()) {
$total_pages = (int)($res["total_pages"] / $limit); $total_pages = (int)($res["total_pages"] / self::LOG_PAGE_LIMIT);
} else { } else {
$total_pages = 0; $total_pages = 0;
} }
@ -134,7 +133,7 @@ class Pref_System extends Handler_Administrative {
$errno_filter_qpart $errno_filter_qpart
ORDER BY ORDER BY
ttrss_error_log.id DESC ttrss_error_log.id DESC
LIMIT $limit OFFSET $offset"); LIMIT ". self::LOG_PAGE_LIMIT ." OFFSET $offset");
$sth->execute($errno_values); $sth->execute($errno_values);
@ -159,7 +158,7 @@ class Pref_System extends Handler_Administrative {
<?php <?php
} }
function index() { function index(): void {
$severity = (int) ($_REQUEST["severity"] ?? E_USER_WARNING); $severity = (int) ($_REQUEST["severity"] ?? E_USER_WARNING);
$page = (int) ($_REQUEST["page"] ?? 0); $page = (int) ($_REQUEST["page"] ?? 0);