From 5c4617d759a2a15773ea39a05e8d146bcd8872ea Mon Sep 17 00:00:00 2001 From: Alex Cabal Date: Tue, 8 Dec 2020 14:32:53 -0600 Subject: [PATCH] Code style tweaks to satisfy PHPStan --- lib/Ebook.php | 2 +- lib/HttpInput.php | 3 +++ lib/Library.php | 7 ++++++- lib/Manual.php | 7 +++++-- scripts/generate-opds.php | 2 ++ www/ebooks/index.php | 4 ++-- 6 files changed, 19 insertions(+), 6 deletions(-) diff --git a/lib/Ebook.php b/lib/Ebook.php index a4137232..3fb36043 100644 --- a/lib/Ebook.php +++ b/lib/Ebook.php @@ -209,7 +209,7 @@ class Ebook{ $this->TocEntries = []; $tocDom = new SimpleXMLElement(str_replace('xmlns=', 'ns=', file_get_contents($wwwFilesystemPath . '/toc.xhtml') ?: '')); $tocDom->registerXPathNamespace('epub', 'http://www.idpf.org/2007/ops'); - foreach($tocDom->xpath('/html/body//nav[@epub:type="toc"]//a[not(contains(@epub:type, "z3998:roman")) and not(text() = "Titlepage" or text() = "Imprint" or text() = "Colophon" or text() = "Endnotes" or text() = "Uncopyright") and not(contains(@href, "halftitle"))]') as $item){ + foreach($tocDom->xpath('/html/body//nav[@epub:type="toc"]//a[not(contains(@epub:type, "z3998:roman")) and not(text() = "Titlepage" or text() = "Imprint" or text() = "Colophon" or text() = "Endnotes" or text() = "Uncopyright") and not(contains(@href, "halftitle"))]') ?: [] as $item){ $this->TocEntries[] = (string)$item; } } diff --git a/lib/HttpInput.php b/lib/HttpInput.php index 2755426c..bd96d6e8 100644 --- a/lib/HttpInput.php +++ b/lib/HttpInput.php @@ -26,6 +26,9 @@ class HttpInput{ return self::GetHttpVar($variable, HTTP_VAR_DEC, GET, $default); } + /** + * @return array + */ public static function GetArray(string $variable, array $default = null): ?array{ return self::GetHttpVar($variable, HTTP_VAR_ARRAY, GET, $default); } diff --git a/lib/Library.php b/lib/Library.php index b64fe1f8..781fb8d8 100644 --- a/lib/Library.php +++ b/lib/Library.php @@ -1,6 +1,7 @@ */ - public static function FilterEbooks($query = null, $tags = [], $sort = null){ + public static function FilterEbooks(string $query = null, array $tags = [], string $sort = null){ $ebooks = Library::GetEbooks(); $matches = $ebooks; @@ -164,6 +165,10 @@ class Library{ return $ebooks; } + + /** + * @return array + */ public static function GetTags(): array{ return apcu_fetch('tags'); } diff --git a/lib/Manual.php b/lib/Manual.php index a7676f4a..439bed0b 100644 --- a/lib/Manual.php +++ b/lib/Manual.php @@ -1,13 +1,16 @@