fix a bunch of lints
This commit is contained in:
parent
294f5845b1
commit
2396ae2ef9
34 changed files with 67 additions and 88 deletions
|
@ -25,6 +25,7 @@
|
|||
"require" : {
|
||||
"php" : ">=7.1",
|
||||
"ext-pdo": "*",
|
||||
"ext-json": "*",
|
||||
|
||||
"flexihash/flexihash" : "^2.0.0",
|
||||
"ifixit/php-akismet" : "1.*",
|
||||
|
|
|
@ -76,7 +76,7 @@ class BaseThemelet
|
|||
"</a>\n";
|
||||
}
|
||||
|
||||
public function display_paginator(Page $page, string $base, string $query=null, int $page_number, int $total_pages, bool $show_random = false)
|
||||
public function display_paginator(Page $page, string $base, ?string $query, int $page_number, int $total_pages, bool $show_random = false)
|
||||
{
|
||||
if ($total_pages == 0) {
|
||||
$total_pages = 1;
|
||||
|
@ -85,13 +85,13 @@ class BaseThemelet
|
|||
$page->add_block(new Block(null, $body, "main", 90, "paginator"));
|
||||
}
|
||||
|
||||
private function gen_page_link(string $base_url, string $query=null, string $page, string $name): string
|
||||
private function gen_page_link(string $base_url, ?string $query, string $page, string $name): string
|
||||
{
|
||||
$link = make_link($base_url.'/'.$page, $query);
|
||||
return '<a href="'.$link.'">'.$name.'</a>';
|
||||
}
|
||||
|
||||
private function gen_page_link_block(string $base_url, string $query=null, string $page, int $current_page, string $name): string
|
||||
private function gen_page_link_block(string $base_url, ?string $query, string $page, int $current_page, string $name): string
|
||||
{
|
||||
$paginator = "";
|
||||
if ($page == $current_page) {
|
||||
|
@ -104,7 +104,7 @@ class BaseThemelet
|
|||
return $paginator;
|
||||
}
|
||||
|
||||
private function build_paginator(int $current_page, int $total_pages, string $base_url, string $query=null, bool $show_random): string
|
||||
private function build_paginator(int $current_page, int $total_pages, string $base_url, ?string $query, bool $show_random): string
|
||||
{
|
||||
$next = $current_page + 1;
|
||||
$prev = $current_page - 1;
|
||||
|
|
|
@ -22,7 +22,7 @@ class NoCache implements CacheEngine
|
|||
|
||||
class MemcacheCache implements CacheEngine
|
||||
{
|
||||
/** @var \Memcache|null */
|
||||
/** @var ?Memcache */
|
||||
public $memcache=null;
|
||||
|
||||
public function __construct(string $args)
|
||||
|
@ -50,7 +50,7 @@ class MemcacheCache implements CacheEngine
|
|||
|
||||
class MemcachedCache implements CacheEngine
|
||||
{
|
||||
/** @var \Memcached|null */
|
||||
/** @var ?Memcached */
|
||||
public $memcache=null;
|
||||
|
||||
public function __construct(string $args)
|
||||
|
@ -169,6 +169,7 @@ class Cache
|
|||
public function __construct(?string $dsn)
|
||||
{
|
||||
$matches = [];
|
||||
$c = null;
|
||||
if ($dsn && preg_match("#(.*)://(.*)#", $dsn, $matches)) {
|
||||
if ($matches[1] == "memcache") {
|
||||
$c = new MemcacheCache($matches[2]);
|
||||
|
|
|
@ -350,7 +350,7 @@ class MockDatabase extends Database
|
|||
private $query_id = 0;
|
||||
/** @var array */
|
||||
private $responses = [];
|
||||
/** @var \NoCache|null */
|
||||
/** @var ?NoCache */
|
||||
public $cache = null;
|
||||
|
||||
public function __construct(array $responses = [])
|
||||
|
|
|
@ -37,7 +37,7 @@ class ImageAdditionException extends SCoreException
|
|||
*/
|
||||
class ImageDeletionEvent extends Event
|
||||
{
|
||||
/** @var \Image */
|
||||
/** @var Image */
|
||||
public $image;
|
||||
|
||||
/**
|
||||
|
@ -59,7 +59,7 @@ class ImageReplaceEvent extends Event
|
|||
{
|
||||
/** @var int */
|
||||
public $id;
|
||||
/** @var \Image */
|
||||
/** @var Image */
|
||||
public $image;
|
||||
|
||||
/**
|
||||
|
@ -123,7 +123,7 @@ class ParseLinkTemplateEvent extends Event
|
|||
public $link;
|
||||
/** @var string */
|
||||
public $original;
|
||||
/** @var \Image */
|
||||
/** @var Image */
|
||||
public $image;
|
||||
|
||||
public function __construct(string $link, Image $image)
|
||||
|
|
|
@ -45,7 +45,7 @@ class TagQuerylet
|
|||
|
||||
class ImgQuerylet
|
||||
{
|
||||
/** @var \Querylet */
|
||||
/** @var Querylet */
|
||||
public $qlet;
|
||||
/** @var bool */
|
||||
public $positive;
|
||||
|
|
|
@ -12,12 +12,12 @@ class UserClass
|
|||
{
|
||||
|
||||
/**
|
||||
* @var null|string
|
||||
* @var ?string
|
||||
*/
|
||||
public $name = null;
|
||||
|
||||
/**
|
||||
* @var \UserClass|null
|
||||
* @var ?UserClass
|
||||
*/
|
||||
public $parent = null;
|
||||
|
||||
|
|
|
@ -216,7 +216,7 @@ function transload(string $url, string $mfile): ?array
|
|||
$s_mfile = escapeshellarg($mfile);
|
||||
system("wget --no-check-certificate $s_url --output-document=$s_mfile");
|
||||
|
||||
return file_exists($mfile);
|
||||
return file_exists($mfile) ? ["ok"=>"true"] : null;
|
||||
}
|
||||
|
||||
if ($config->get_string("transload_engine") === "fopen") {
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
*/
|
||||
class AdminBuildingEvent extends Event
|
||||
{
|
||||
/** @var \Page */
|
||||
/** @var Page */
|
||||
public $page;
|
||||
|
||||
public function __construct(Page $page)
|
||||
|
|
|
@ -10,9 +10,9 @@
|
|||
*/
|
||||
class AuthorSetEvent extends Event
|
||||
{
|
||||
/** @var \Image */
|
||||
/** @var Image */
|
||||
public $image;
|
||||
/** @var \User */
|
||||
/** @var User */
|
||||
public $user;
|
||||
/** @var string */
|
||||
public $author;
|
||||
|
|
|
@ -15,7 +15,7 @@ class ArtistsTheme extends Themelet
|
|||
";
|
||||
}
|
||||
|
||||
public function sidebar_options(string $mode, ?int $artistID=null, $is_admin=false): bool
|
||||
public function sidebar_options(string $mode, ?int $artistID=null, $is_admin=false): void
|
||||
{
|
||||
global $page, $user;
|
||||
|
||||
|
|
|
@ -15,7 +15,7 @@ class CommentPostingEvent extends Event
|
|||
{
|
||||
/** @var int */
|
||||
public $image_id;
|
||||
/** @var \User */
|
||||
/** @var User */
|
||||
public $user;
|
||||
/** @var string */
|
||||
public $comment;
|
||||
|
|
|
@ -1,23 +1,9 @@
|
|||
<?php
|
||||
class CommentListTheme extends Themelet
|
||||
{
|
||||
private $comments_shown = 0;
|
||||
private $show_anon_id = false;
|
||||
private $anon_id = 1;
|
||||
private $anon_cid = 0;
|
||||
private $anon_map = [];
|
||||
private $ct = null;
|
||||
|
||||
private function get_anon_colour($ip)
|
||||
{
|
||||
if (is_null($this->ct)) {
|
||||
$this->ct = hsl_rainbow();
|
||||
}
|
||||
if (!array_key_exists($ip, $this->anon_map)) {
|
||||
$this->anon_map[$ip] = $this->ct[$this->anon_cid++ % count($this->ct)];
|
||||
}
|
||||
return $this->anon_map[$ip];
|
||||
}
|
||||
|
||||
/**
|
||||
* Display a page with a list of images, and for each image, the image's comments.
|
||||
|
|
|
@ -340,7 +340,7 @@ class CronUploader extends Extension
|
|||
$img->set_tags(Tag::explode($tags));
|
||||
}
|
||||
|
||||
private function generate_image_queue($base = "", $subdir = "")
|
||||
private function generate_image_queue(string $base = "", string $subdir = ""): void
|
||||
{
|
||||
if ($base == "") {
|
||||
$base = $this->root_dir . "/queue";
|
||||
|
@ -348,7 +348,7 @@ class CronUploader extends Extension
|
|||
|
||||
if (! is_dir($base)) {
|
||||
$this->add_upload_info("Image Queue Directory could not be found at \"$base\".");
|
||||
return [];
|
||||
return;
|
||||
}
|
||||
|
||||
foreach (glob("$base/$subdir/*") as $fullpath) {
|
||||
|
|
|
@ -17,7 +17,7 @@ class FavoriteSetEvent extends Event
|
|||
{
|
||||
/** @var int */
|
||||
public $image_id;
|
||||
/** @var \User */
|
||||
/** @var User */
|
||||
public $user;
|
||||
/** @var bool */
|
||||
public $do_set;
|
||||
|
|
|
@ -136,15 +136,6 @@ class PixelFileHandler extends DataHandlerExtension
|
|||
return true;
|
||||
}
|
||||
// }}}
|
||||
// epeg thumber {{{
|
||||
private function make_thumb_epeg(string $inname, string $outname): bool
|
||||
{
|
||||
global $config;
|
||||
$w = $config->get_int("thumb_width");
|
||||
exec("epeg $inname -c 'Created by EPEG' --max $w $outname");
|
||||
return true;
|
||||
}
|
||||
// }}}
|
||||
// GD thumber {{{
|
||||
private function make_thumb_gd(string $inname, string $outname): bool
|
||||
{
|
||||
|
|
|
@ -164,7 +164,7 @@ class SearchTermParseEvent extends Event
|
|||
public $term = null;
|
||||
/** @var string[] */
|
||||
public $context = [];
|
||||
/** @var \Querylet[] */
|
||||
/** @var Querylet[] */
|
||||
public $querylets = [];
|
||||
|
||||
public function __construct(string $term=null, array $context=[])
|
||||
|
|
|
@ -120,7 +120,7 @@ class PoolsTheme extends Themelet
|
|||
$page->add_block(new Block("Create Pool", $create_html, "main", 20));
|
||||
}
|
||||
|
||||
private function display_top(array $pools=null, string $heading, bool $check_all=false)
|
||||
private function display_top(?array $pools, string $heading, bool $check_all=false)
|
||||
{
|
||||
global $page, $user;
|
||||
|
||||
|
@ -361,6 +361,8 @@ class PoolsTheme extends Themelet
|
|||
$prefix = "+";
|
||||
} elseif ($history['action'] == 0) {
|
||||
$prefix = "-";
|
||||
} else {
|
||||
throw new Exception("history['action'] not in {0, 1}");
|
||||
}
|
||||
|
||||
$images = trim($history['images']);
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
class RatingSetEvent extends Event
|
||||
{
|
||||
/** @var \Image */
|
||||
/** @var Image */
|
||||
public $image;
|
||||
/** @var string */
|
||||
public $rating;
|
||||
|
|
|
@ -123,12 +123,10 @@ class Rule34 extends Extension
|
|||
}
|
||||
}
|
||||
|
||||
if ($aae->redirect) {
|
||||
$page->set_mode("redirect");
|
||||
$page->set_redirect(make_link("admin"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($event->page_matches("sys_ip_ban")) {
|
||||
global $page, $user;
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
class Rule34Theme extends Themelet
|
||||
{
|
||||
public function show_comic_changer(User $duser, bool $current_state): string
|
||||
public function show_comic_changer(User $duser, bool $current_state): void
|
||||
{
|
||||
global $page;
|
||||
$checked = $current_state ? 'checked="checked"' : '';
|
||||
|
@ -15,7 +15,7 @@ class Rule34Theme extends Themelet
|
|||
$page->add_block(new Block("Rule34 Comic Options", $html));
|
||||
}
|
||||
|
||||
public function display_bans(Page $page, $bans)
|
||||
public function display_bans(Page $page, array $bans)
|
||||
{
|
||||
global $database, $user;
|
||||
$h_bans = "";
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
*/
|
||||
class ConfigSaveEvent extends Event
|
||||
{
|
||||
/** @var \Config */
|
||||
/** @var Config */
|
||||
public $config;
|
||||
|
||||
public function __construct(Config $config)
|
||||
|
@ -28,7 +28,7 @@ class ConfigSaveEvent extends Event
|
|||
*/
|
||||
class SetupBuildingEvent extends Event
|
||||
{
|
||||
/** @var \SetupPanel */
|
||||
/** @var SetupPanel */
|
||||
public $panel;
|
||||
|
||||
public function __construct(SetupPanel $panel)
|
||||
|
@ -42,7 +42,7 @@ class SetupBuildingEvent extends Event
|
|||
*/
|
||||
class SetupPanel
|
||||
{
|
||||
/** @var \SetupBlock[] */
|
||||
/** @var SetupBlock[] */
|
||||
public $blocks = [];
|
||||
|
||||
public function add_block(SetupBlock $block)
|
||||
|
|
|
@ -2,9 +2,6 @@
|
|||
|
||||
class TagCategoriesTheme extends Themelet
|
||||
{
|
||||
private $heading = "";
|
||||
private $list = "";
|
||||
|
||||
public function show_tag_categories($page, $tc_dict)
|
||||
{
|
||||
$tc_block_index = 0;
|
||||
|
|
|
@ -48,9 +48,9 @@
|
|||
*/
|
||||
class OwnerSetEvent extends Event
|
||||
{
|
||||
/** @var \Image */
|
||||
/** @var Image */
|
||||
public $image;
|
||||
/** @var \User */
|
||||
/** @var User */
|
||||
public $owner;
|
||||
|
||||
public function __construct(Image $image, User $owner)
|
||||
|
@ -63,7 +63,7 @@ class OwnerSetEvent extends Event
|
|||
|
||||
class SourceSetEvent extends Event
|
||||
{
|
||||
/** @var \Image */
|
||||
/** @var Image */
|
||||
public $image;
|
||||
/** @var string */
|
||||
public $source;
|
||||
|
@ -78,7 +78,7 @@ class SourceSetEvent extends Event
|
|||
|
||||
class TagSetEvent extends Event
|
||||
{
|
||||
/** @var \Image */
|
||||
/** @var Image */
|
||||
public $image;
|
||||
public $tags;
|
||||
public $metatags;
|
||||
|
@ -116,7 +116,7 @@ class TagSetEvent extends Event
|
|||
|
||||
class LockSetEvent extends Event
|
||||
{
|
||||
/** @var \Image */
|
||||
/** @var Image */
|
||||
public $image;
|
||||
/** @var bool */
|
||||
public $locked;
|
||||
|
|
|
@ -140,7 +140,7 @@ class TaggerXML extends Extension
|
|||
return $result."</list>";
|
||||
}
|
||||
|
||||
private function tag_to_xml(string $tag): string
|
||||
private function tag_to_xml(PDORow $tag): string
|
||||
{
|
||||
return
|
||||
"<tag ".
|
||||
|
|
|
@ -21,7 +21,7 @@ class UserBlockBuildingEvent extends Event
|
|||
|
||||
class UserPageBuildingEvent extends Event
|
||||
{
|
||||
/** @var \User */
|
||||
/** @var User */
|
||||
public $display_user;
|
||||
/** @var array */
|
||||
public $stats = [];
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
*/
|
||||
class DisplayingImageEvent extends Event
|
||||
{
|
||||
/** @var \Image */
|
||||
/** @var Image */
|
||||
public $image;
|
||||
|
||||
public function __construct(Image $image)
|
||||
|
@ -34,9 +34,9 @@ class ImageInfoBoxBuildingEvent extends Event
|
|||
{
|
||||
/** @var array */
|
||||
public $parts = [];
|
||||
/** @var \Image */
|
||||
/** @var Image */
|
||||
public $image;
|
||||
/** @var \User */
|
||||
/** @var User */
|
||||
public $user;
|
||||
|
||||
public function __construct(Image $image, User $user)
|
||||
|
@ -56,7 +56,7 @@ class ImageInfoBoxBuildingEvent extends Event
|
|||
|
||||
class ImageInfoSetEvent extends Event
|
||||
{
|
||||
/** @var \Image */
|
||||
/** @var Image */
|
||||
public $image;
|
||||
|
||||
public function __construct(Image $image)
|
||||
|
@ -69,9 +69,9 @@ class ImageAdminBlockBuildingEvent extends Event
|
|||
{
|
||||
/** @var string[] */
|
||||
public $parts = [];
|
||||
/** @var \Image|null */
|
||||
/** @var ?Image */
|
||||
public $image = null;
|
||||
/** @var null|\User */
|
||||
/** @var ?User */
|
||||
public $user = null;
|
||||
|
||||
public function __construct(Image $image, User $user)
|
||||
|
|
|
@ -10,9 +10,9 @@
|
|||
|
||||
class WikiUpdateEvent extends Event
|
||||
{
|
||||
/** @var \User */
|
||||
/** @var User */
|
||||
public $user;
|
||||
/** @var \WikiPage */
|
||||
/** @var WikiPage */
|
||||
public $wikipage;
|
||||
|
||||
public function __construct(User $user, WikiPage $wikipage)
|
||||
|
@ -490,6 +490,9 @@ class Wiki extends Extension
|
|||
//return $nr1. " : $nr2 : - <font color='red' >".htmlentities( $value ) ."</font><br>";
|
||||
return "--- $value\n";
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new Exception("stat needs to be =, + or -");
|
||||
}
|
||||
}
|
||||
// }}}
|
||||
|
|
|
@ -53,7 +53,7 @@ class CustomIndexTheme extends IndexTheme
|
|||
return $h_search;
|
||||
}
|
||||
|
||||
protected function build_table(array $images, string $query): string
|
||||
protected function build_table(array $images, ?string $query): string
|
||||
{
|
||||
$h_query = html_escape($query);
|
||||
$table = "<div class='shm-image-list' data-query='$h_query'>";
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
class CustomCommentListTheme extends CommentListTheme
|
||||
{
|
||||
public function display_comment_list($images, $page_number, $total_pages, $can_post)
|
||||
public function display_comment_list(array $images, int $page_number, int $total_pages, bool $can_post)
|
||||
{
|
||||
global $config, $page, $user;
|
||||
|
||||
|
@ -82,13 +82,13 @@ class CustomCommentListTheme extends CommentListTheme
|
|||
}
|
||||
}
|
||||
|
||||
public function display_recent_comments($comments)
|
||||
public function display_recent_comments(array $comments)
|
||||
{
|
||||
// no recent comments in this theme
|
||||
}
|
||||
|
||||
|
||||
protected function comment_to_html(Comment $comment, $trim=false)
|
||||
protected function comment_to_html(Comment $comment, bool $trim=false): string
|
||||
{
|
||||
global $user;
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ class CustomIndexTheme extends IndexTheme
|
|||
/**
|
||||
* #param Image[] $images
|
||||
*/
|
||||
protected function build_table(array $images, string $query): string
|
||||
protected function build_table(array $images, ?string $query): string
|
||||
{
|
||||
$h_query = html_escape($query);
|
||||
$table = "<div class='shm-image-list' data-query='$h_query'>";
|
||||
|
|
|
@ -4,7 +4,7 @@ class CustomCommentListTheme extends CommentListTheme
|
|||
{
|
||||
public $inner_id = 0;
|
||||
|
||||
public function display_comment_list($images, $page_number, $total_pages, $can_post)
|
||||
public function display_comment_list(array $images, int $page_number, int $total_pages, bool $can_post)
|
||||
{
|
||||
global $config, $page;
|
||||
|
||||
|
@ -49,7 +49,7 @@ class CustomCommentListTheme extends CommentListTheme
|
|||
}
|
||||
}
|
||||
|
||||
public function display_recent_comments($comments)
|
||||
public function display_recent_comments(array $comments)
|
||||
{
|
||||
// sidebar fails in this theme
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ class CustomCommentListTheme extends CommentListTheme
|
|||
}
|
||||
|
||||
|
||||
protected function comment_to_html(Comment $comment, $trim=false)
|
||||
protected function comment_to_html(Comment $comment, bool $trim=false): string
|
||||
{
|
||||
$inner_id = $this->inner_id; // because custom themes can't add params, because PHP
|
||||
global $user;
|
||||
|
|
|
@ -5,7 +5,7 @@ class Themelet extends BaseThemelet
|
|||
/**
|
||||
* Add a generic paginator.
|
||||
*/
|
||||
public function display_paginator(Page $page, string $base, string $query, int $page_number, int $total_pages, bool $show_random = false)
|
||||
public function display_paginator(Page $page, string $base, ?string $query, int $page_number, int $total_pages, bool $show_random = false)
|
||||
{
|
||||
if ($total_pages == 0) {
|
||||
$total_pages = 1;
|
||||
|
|
|
@ -18,7 +18,7 @@ class Themelet extends BaseThemelet
|
|||
";
|
||||
}
|
||||
|
||||
public function display_paginator(Page $page, string $base, string $query, int $page_number, int $total_pages, bool $show_random = false)
|
||||
public function display_paginator(Page $page, string $base, ?string $query, int $page_number, int $total_pages, bool $show_random = false)
|
||||
{
|
||||
if ($total_pages == 0) {
|
||||
$total_pages = 1;
|
||||
|
@ -27,7 +27,7 @@ class Themelet extends BaseThemelet
|
|||
$page->add_block(new Block(null, $body, "main", 90));
|
||||
}
|
||||
|
||||
public function litetheme_gen_page_link(string $base_url, string $query, string $page, string $name, ?string $link_class=null): string
|
||||
public function litetheme_gen_page_link(string $base_url, ?string $query, string $page, string $name, ?string $link_class=null): string
|
||||
{
|
||||
$link = make_link("$base_url/$page", $query);
|
||||
return "<a class='$link_class' href='$link'>$name</a>";
|
||||
|
|
Reference in a new issue