about summary refs log tree commit diff stats
path: root/classes
diff options
context:
space:
mode:
authorAndrew Dolgov <fox@fakecake.org>2026-05-24 17:16:05 +0300
committerAndrew Dolgov <fox@fakecake.org>2026-05-24 17:16:05 +0300
commit6f660eedb640eaa31e75cfd2543692d7f494ddd6 (patch)
treebf5a6d43ae77daf7a63d5c1770ec5dac6af5bc06 /classes
parent8ca1fb36999b0e2eceed1388d1a1f7cc115a2f3c (diff)
downloadthe-epube-6f660eedb640eaa31e75cfd2543692d7f494ddd6.tar.gz
the-epube-6f660eedb640eaa31e75cfd2543692d7f494ddd6.tar.xz
fix phpstan issues
Diffstat (limited to 'classes')
-rw-r--r--classes/AuthMiddleware.php1
-rw-r--r--classes/Handler/DefineHandler.php2
-rw-r--r--classes/Request.php16
-rw-r--r--classes/Response.php1
-rw-r--r--classes/Router.php3
-rw-r--r--classes/Sanitizer.php5
6 files changed, 20 insertions, 8 deletions
diff --git a/classes/AuthMiddleware.php b/classes/AuthMiddleware.php
index 4f1f11d..68b2585 100644
--- a/classes/AuthMiddleware.php
+++ b/classes/AuthMiddleware.php
@@ -2,6 +2,7 @@
 
 class AuthMiddleware implements MiddlewareInterface
 {
+    /** @var array<string> */
     private array $csrfIgnore = [
         "cover", "download", "getpagination", "getlastread"
     ];
diff --git a/classes/Handler/DefineHandler.php b/classes/Handler/DefineHandler.php
index 2d683b8..30ae72e 100644
--- a/classes/Handler/DefineHandler.php
+++ b/classes/Handler/DefineHandler.php
@@ -38,7 +38,7 @@ class DefineHandler implements RequestHandlerInterface
         for ($i = 0; $i < 3; $i++) {
             $ch = curl_init();
             curl_setopt($ch, CURLOPT_URL, sprintf("dict://%s/define:%s", Config::get(Config::DICT_SERVER), $word));
-            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
             $dictReply = curl_exec($ch);
 
             if ($dictReply) {
diff --git a/classes/Request.php b/classes/Request.php
index 57fe862..b3d2b62 100644
--- a/classes/Request.php
+++ b/classes/Request.php
@@ -2,34 +2,42 @@
 
 class Request
 {
+    /** @var array<string, mixed> */
     private array $serverParams;
+    /** @var array<string, mixed> */
     private array $queryParams;
+    /** @var array<string, mixed> */
     private array $bodyParams;
+    /** @var array<string, mixed> */
     private array $cookies;
 
     public function __construct()
     {
-        $this->serverParams = $_SERVER ?? [];
-        $this->queryParams  = $_GET ?? [];
-        $this->bodyParams   = $_POST ?? [];
-        $this->cookies      = $_COOKIE ?? [];
+        $this->serverParams = $_SERVER;
+        $this->queryParams  = $_GET;
+        $this->bodyParams   = $_POST;
+        $this->cookies      = $_COOKIE;
     }
 
+    /** @return array<string, mixed> */
     public function getServerParams(): array
     {
         return $this->serverParams;
     }
 
+    /** @return array<string, mixed> */
     public function getQueryParams(): array
     {
         return $this->queryParams;
     }
 
+    /** @return array<string, mixed> */
     public function getParsedBody(): array
     {
         return array_merge($this->queryParams, $this->bodyParams);
     }
 
+    /** @return array<string, mixed> */
     public function getCookieParams(): array
     {
         return $this->cookies;
diff --git a/classes/Response.php b/classes/Response.php
index aa3302a..dcbbc5b 100644
--- a/classes/Response.php
+++ b/classes/Response.php
@@ -3,6 +3,7 @@
 class Response
 {
     private int $status = 200;
+    /** @var array<string, string> */
     private array $headers = [];
     private string $body = '';
 
diff --git a/classes/Router.php b/classes/Router.php
index f55173f..b4f4837 100644
--- a/classes/Router.php
+++ b/classes/Router.php
@@ -2,7 +2,7 @@
 
 class Router
 {
-    /** @var array<string, \Handler\RequestHandlerInterface> */
+    /** @var array<string, RequestHandlerInterface> */
     private array $routes = [];
 
     /** @var MiddlewareInterface[] */
@@ -30,7 +30,6 @@ class Router
             exit;
         }
 
-        /** @var callable $pipe */
         $pipe = $handler->handle(...);
 
         // wrap middleware in reverse order (last added = outermost)
diff --git a/classes/Sanitizer.php b/classes/Sanitizer.php
index d751245..9d2f5a3 100644
--- a/classes/Sanitizer.php
+++ b/classes/Sanitizer.php
@@ -19,7 +19,6 @@ class Sanitizer {
 			$rel_parts['host'] = $parts['host'];
 			$rel_parts['scheme'] = $parts['scheme'];
 
-			/** @phpstan-ignore-next-line */
 			if (isset($rel_parts['path'])) {
 				if (strpos($rel_parts['path'], '/') !== 0)
 					$rel_parts['path'] = '/' . $rel_parts['path'];
@@ -47,6 +46,7 @@ class Sanitizer {
 		$entries = $xpath->query('(//a[@href]|//img[@src]|//source[@srcset|@src])');
 
 		foreach ($entries as $entry) {
+		/** @var DOMElement $entry */
 
 			if ($entry->hasAttribute('href')) {
 				$entry->setAttribute('href',
@@ -109,10 +109,13 @@ class Sanitizer {
 		$entries = $xpath->query('//*');
 
 		foreach ($entries as $entry) {
+		/** @var DOMElement $entry */
 			if (!in_array($entry->nodeName, $allowed_elements)) {
 				$entry->parentNode->removeChild($entry);
+				continue;
 			}
 
+
 			if ($entry->hasAttributes()) {
 				$attrs_to_remove = array();