From 5632d75a450f4573aaa903ef7655c44f7fc2d387 Mon Sep 17 00:00:00 2001 From: wn_ Date: Sun, 14 Nov 2021 20:26:21 +0000 Subject: [PATCH] Address PHPStan warning in 'classes/pref/system.php'. --- classes/pref/system.php | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/classes/pref/system.php b/classes/pref/system.php index 356adee0c..10f196b55 100644 --- a/classes/pref/system.php +++ b/classes/pref/system.php @@ -2,7 +2,7 @@ class Pref_System extends Handler_Administrative { - private $log_page_limit = 15; + private const LOG_PAGE_LIMIT = 15; function csrf_ignore(string $method): bool { $csrf_ignored = array("index"); @@ -10,11 +10,11 @@ class Pref_System extends Handler_Administrative { return array_search($method, $csrf_ignored) !== false; } - function clearLog() { + function clearLog(): void { $this->pdo->query("DELETE FROM ttrss_error_log"); } - function sendTestEmail() { + function sendTestEmail(): void { $mail_address = clean($_REQUEST["mail_address"]); $mailer = new Mailer(); @@ -28,7 +28,7 @@ class Pref_System extends Handler_Administrative { print json_encode(['rc' => $rc, 'error' => $mailer->error()]); } - function getphpinfo() { + function getphpinfo(): void { ob_start(); phpinfo(); $info = ob_get_contents(); @@ -37,7 +37,7 @@ class Pref_System extends Handler_Administrative { print preg_replace( '%^.*(.*).*$%ms','$1', (string)$info); } - private function _log_viewer(int $page, int $severity) { + private function _log_viewer(int $page, int $severity): void { $errno_values = []; switch ($severity) { @@ -56,8 +56,7 @@ class Pref_System extends Handler_Administrative { $errno_filter_qpart = "true"; } - $limit = $this->log_page_limit; - $offset = $limit * $page; + $offset = self::LOG_PAGE_LIMIT * $page; $sth = $this->pdo->prepare("SELECT COUNT(id) AS total_pages @@ -69,7 +68,7 @@ class Pref_System extends Handler_Administrative { $sth->execute($errno_values); if ($res = $sth->fetch()) { - $total_pages = (int)($res["total_pages"] / $limit); + $total_pages = (int)($res["total_pages"] / self::LOG_PAGE_LIMIT); } else { $total_pages = 0; } @@ -134,7 +133,7 @@ class Pref_System extends Handler_Administrative { $errno_filter_qpart ORDER BY ttrss_error_log.id DESC - LIMIT $limit OFFSET $offset"); + LIMIT ". self::LOG_PAGE_LIMIT ." OFFSET $offset"); $sth->execute($errno_values); @@ -159,7 +158,7 @@ class Pref_System extends Handler_Administrative {