mirror of
https://github.com/standardebooks/web.git
synced 2025-07-06 14:50:39 -04:00
Code style tweaks to satisfy PHPStan
This commit is contained in:
parent
658db66c2b
commit
5c4617d759
6 changed files with 19 additions and 6 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,6 +26,9 @@ class HttpInput{
|
|||
return self::GetHttpVar($variable, HTTP_VAR_DEC, GET, $default);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string>
|
||||
*/
|
||||
public static function GetArray(string $variable, array $default = null): ?array{
|
||||
return self::GetHttpVar($variable, HTTP_VAR_ARRAY, GET, $default);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
<?
|
||||
use function Safe\apcu_fetch;
|
||||
use function Safe\ksort;
|
||||
use function Safe\natsort;
|
||||
use function Safe\preg_replace;
|
||||
use function Safe\touch;
|
||||
use function Safe\unlink;
|
||||
|
@ -10,7 +11,7 @@ class Library{
|
|||
/**
|
||||
* @return array<Ebook>
|
||||
*/
|
||||
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<Tag>
|
||||
*/
|
||||
public static function GetTags(): array{
|
||||
return apcu_fetch('tags');
|
||||
}
|
||||
|
|
|
@ -1,13 +1,16 @@
|
|||
<?
|
||||
use function Safe\glob;
|
||||
use function Safe\preg_match_all;
|
||||
use function Safe\sort;
|
||||
|
||||
class Manual{
|
||||
public static function GetLatestVersion(){
|
||||
public static function GetLatestVersion(): string{
|
||||
$dirs = glob(MANUAL_PATH . '/*', GLOB_ONLYDIR);
|
||||
sort($dirs);
|
||||
return str_replace(MANUAL_PATH . '/', '', $dirs[sizeof($dirs) - 1]);
|
||||
}
|
||||
|
||||
public static function GetRequestedVersion(){
|
||||
public static function GetRequestedVersion(): ?string{
|
||||
try{
|
||||
if(preg_match_all('|/manual/([0-9]+\.[0-9]+\.[0-9]+)|ius', $_SERVER['REQUEST_URI'], $matches)){
|
||||
return($matches[1][0]);
|
||||
|
|
|
@ -22,6 +22,8 @@ foreach($contentFiles as $path){
|
|||
if($path == '')
|
||||
continue;
|
||||
|
||||
$ebookWwwFilesystemPath = '';
|
||||
|
||||
try{
|
||||
$ebookWwwFilesystemPath = preg_replace('|/content\.opf|ius', '', $path) ?? '';
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@ try{
|
|||
$query = HttpInput::GetString('query', false);
|
||||
$tags = HttpInput::GetArray('tags', []);
|
||||
$collection = HttpInput::GetString('collection', false);
|
||||
$view = Httpinput::GetString('view', false);
|
||||
$view = HttpInput::GetString('view', false);
|
||||
$sort = HttpInput::GetString('sort', false);
|
||||
$pages = 0;
|
||||
$totalEbooks = 0;
|
||||
|
@ -117,7 +117,7 @@ try{
|
|||
}
|
||||
|
||||
if($perPage !== EBOOKS_PER_PAGE){
|
||||
$queryString .= '&per-page=' . urlencode($perPage);
|
||||
$queryString .= '&per-page=' . urlencode((string)$perPage);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue