From 77f7121e26c18d500d8cdf1ff93aafcc4078c210 Mon Sep 17 00:00:00 2001 From: Shish Date: Sun, 14 Mar 2021 23:43:50 +0000 Subject: [PATCH] drop php7.3 support, make use of 7.4 features --- .github/workflows/test_and_publish.yml | 2 +- composer.json | 2 +- core/basepage.php | 72 +++--- core/block.php | 28 +-- core/cacheengine.php | 31 ++- core/command_builder.php | 6 +- core/config.php | 12 +- core/database.php | 17 +- core/dbengine.php | 36 ++- core/event.php | 59 ++--- core/exceptions.php | 22 +- core/extension.php | 67 +++--- core/imageboard/event.php | 48 ++-- core/imageboard/image.php | 91 +++----- core/imageboard/search.php | 18 +- core/install.php | 2 +- core/polyfills.php | 21 +- core/urls.php | 4 +- core/user.php | 22 +- core/userclass.php | 18 +- core/util.php | 22 +- ext/admin/info.php | 16 +- ext/admin/main.php | 14 +- ext/admin/theme.php | 1 - ext/alias_editor/info.php | 16 +- ext/alias_editor/main.php | 10 +- ext/approval/info.php | 10 +- ext/approval/main.php | 2 +- ext/approval/theme.php | 5 +- ext/artists/info.php | 14 +- ext/artists/main.php | 13 +- ext/artists/theme.php | 2 +- ext/auto_tagger/info.php | 10 +- ext/auto_tagger/main.php | 10 +- ext/autocomplete/info.php | 8 +- ext/autocomplete/main.php | 2 +- ext/autocomplete/script.js | 4 +- ext/ban_words/info.php | 14 +- ext/bbcode/info.php | 16 +- ext/bbcode/test.php | 4 +- ext/biography/info.php | 12 +- ext/biography/main.php | 6 +- ext/biography/test.php | 1 - ext/blocks/info.php | 12 +- ext/blocks/main.php | 2 +- ext/blotter/info.php | 12 +- ext/blotter/main.php | 2 +- ext/blotter/theme.php | 8 +- ext/browser_search/info.php | 16 +- ext/bulk_actions/info.php | 12 +- ext/bulk_actions/main.php | 17 +- ext/bulk_actions/script.js | 28 +-- ext/bulk_actions/theme.php | 6 +- ext/bulk_add/info.php | 14 +- ext/bulk_add/main.php | 6 +- ext/bulk_add/theme.php | 2 +- ext/bulk_add_csv/info.php | 14 +- ext/bulk_add_csv/main.php | 2 +- ext/bulk_add_csv/theme.php | 2 +- ext/bulk_download/info.php | 12 +- ext/bulk_import_export/events.php | 8 +- ext/bulk_import_export/info.php | 12 +- ext/bulk_import_export/main.php | 4 +- ext/comment/info.php | 16 +- ext/comment/main.php | 59 ++--- ext/comment/theme.php | 12 +- ext/cron_uploader/info.php | 12 +- ext/cron_uploader/main.php | 20 +- ext/cron_uploader/theme.php | 3 - ext/custom_html_headers/info.php | 14 +- ext/danbooru_api/info.php | 10 +- ext/danbooru_api/main.php | 15 +- ext/download/events.php | 10 +- ext/download/info.php | 14 +- ext/downtime/info.php | 14 +- ext/downtime/main.php | 4 +- ext/emoticons/info.php | 16 +- ext/emoticons_list/info.php | 14 +- ext/emoticons_list/main.php | 2 +- ext/eokm/info.php | 12 +- ext/eokm/main.php | 1 + ext/et/info.php | 16 +- ext/et/main.php | 4 +- ext/et/theme.php | 2 +- ext/et_server/info.php | 16 +- ext/ext_manager/info.php | 18 +- ext/ext_manager/main.php | 6 +- ext/favorites/info.php | 12 +- ext/favorites/main.php | 11 +- ext/favorites/theme.php | 7 +- ext/featured/info.php | 14 +- ext/featured/main.php | 2 +- ext/forum/info.php | 10 +- ext/forum/main.php | 30 +-- ext/forum/theme.php | 3 +- ext/four_oh_four/info.php | 16 +- ext/four_oh_four/main.php | 2 +- ext/google_analytics/info.php | 14 +- ext/google_analytics/main.php | 2 +- ext/handle_archive/info.php | 12 +- ext/handle_archive/main.php | 4 +- ext/handle_cbz/info.php | 10 +- ext/handle_cbz/main.php | 2 +- ext/handle_flash/info.php | 10 +- ext/handle_flash/main.php | 4 +- ext/handle_ico/info.php | 10 +- ext/handle_ico/main.php | 6 +- ext/handle_mp3/info.php | 10 +- ext/handle_mp3/main.php | 4 +- ext/handle_pixel/info.php | 12 +- ext/handle_pixel/main.php | 6 +- ext/handle_pixel/script.js | 16 +- ext/handle_svg/info.php | 10 +- ext/handle_svg/main.php | 29 +-- ext/handle_video/info.php | 12 +- ext/handle_video/main.php | 8 +- ext/hellban/info.php | 7 +- ext/help_pages/info.php | 14 +- ext/help_pages/main.php | 12 +- ext/holiday/info.php | 12 +- ext/holiday/main.php | 9 +- ext/holiday/theme.php | 18 +- ext/home/info.php | 14 +- ext/home/main.php | 4 +- ext/home/theme.php | 4 +- ext/image/info.php | 16 +- ext/image/main.php | 6 +- ext/image_hash_ban/info.php | 16 +- ext/image_hash_ban/main.php | 8 +- ext/image_hash_ban/test.php | 2 +- ext/image_hash_ban/theme.php | 4 +- ext/image_view_counter/info.php | 14 +- ext/image_view_counter/main.php | 4 +- ext/image_view_counter/theme.php | 2 +- ext/index/events.php | 20 +- ext/index/info.php | 16 +- ext/index/main.php | 2 +- ext/index/test.php | 2 +- ext/index/theme.php | 8 +- ext/ipban/info.php | 14 +- ext/ipban/main.php | 12 +- ext/link_image/info.php | 12 +- ext/link_image/main.php | 4 +- ext/link_image/theme.php | 6 +- ext/livefeed/info.php | 12 +- ext/log_db/info.php | 12 +- ext/log_db/main.php | 7 +- ext/log_logstash/info.php | 12 +- ext/log_net/info.php | 12 +- ext/log_net/main.php | 2 +- ext/media/events.php | 32 +-- ext/media/info.php | 16 +- ext/media/main.php | 5 +- ext/media/theme.php | 2 +- ext/mime/info.php | 14 +- ext/mime/main.php | 2 +- ext/mime/theme.php | 2 +- ext/not_a_tag/info.php | 12 +- ext/not_a_tag/main.php | 2 +- ext/notes/info.php | 10 +- ext/notes/main.php | 2 +- ext/notes/theme.php | 16 +- ext/numeric_score/info.php | 14 +- ext/numeric_score/main.php | 8 +- ext/numeric_score/theme.php | 2 +- ext/ouroboros_api/info.php | 12 +- ext/ouroboros_api/main.php | 208 ++++-------------- ext/pm/info.php | 14 +- ext/pm/main.php | 27 +-- ext/pm_triggers/info.php | 14 +- ext/pools/info.php | 12 +- ext/pools/main.php | 36 ++- ext/pools/test.php | 6 +- ext/pools/theme.php | 6 +- ext/post_peek/info.php | 11 +- .../events/post_title_set_event.php | 6 +- ext/post_titles/info.php | 10 +- ext/post_titles/main.php | 2 +- ext/private_image/info.php | 10 +- ext/private_image/main.php | 2 +- ext/private_image/theme.php | 5 +- ext/qr_code/info.php | 14 +- ext/qr_code/main.php | 2 +- ext/random_image/info.php | 14 +- ext/random_image/main.php | 6 +- ext/random_list/info.php | 14 +- ext/random_list/main.php | 2 +- ext/random_list/theme.php | 2 +- ext/rating/info.php | 14 +- ext/rating/main.php | 29 +-- ext/rating/theme.php | 4 +- ext/regen_thumb/info.php | 14 +- ext/regen_thumb/main.php | 4 +- ext/regen_thumb/theme.php | 4 +- ext/relationships/info.php | 10 +- ext/relationships/main.php | 6 +- ext/relationships/test.php | 12 +- ext/relationships/theme.php | 2 +- ext/report_image/info.php | 14 +- ext/report_image/main.php | 17 +- ext/res_limit/info.php | 12 +- ext/resize/info.php | 12 +- ext/resize/main.php | 2 +- ext/resize/theme.php | 8 +- ext/rotate/info.php | 10 +- ext/rotate/main.php | 2 +- ext/rss_comments/info.php | 12 +- ext/rss_images/info.php | 12 +- ext/rule34/info.php | 16 +- ext/rule34/main.php | 10 +- ext/setup/info.php | 14 +- ext/setup/main.php | 26 +-- ext/setup/theme.php | 4 +- ext/shimmie_api/info.php | 12 +- ext/shimmie_api/main.php | 26 ++- ext/site_description/info.php | 16 +- ext/sitemap/info.php | 12 +- ext/sitemap/main.php | 4 +- ext/source_history/info.php | 10 +- ext/source_history/main.php | 2 +- ext/source_history/theme.php | 4 +- ext/static_files/info.php | 16 +- ext/static_files/main.php | 2 +- ext/statsd/info.php | 16 +- ext/statsd/main.php | 2 +- ext/system/info.php | 14 +- ext/tag_categories/info.php | 10 +- ext/tag_categories/main.php | 8 +- ext/tag_categories/theme.php | 2 +- ext/tag_edit/info.php | 14 +- ext/tag_edit/main.php | 38 ++-- ext/tag_editcloud/info.php | 8 +- ext/tag_editcloud/main.php | 1 + ext/tag_editcloud/script.js | 4 +- ext/tag_history/info.php | 8 +- ext/tag_history/main.php | 2 +- ext/tag_history/theme.php | 4 +- ext/tag_list/info.php | 14 +- ext/tag_list/main.php | 4 +- ext/tag_list/test.php | 2 +- ext/tag_list/theme.php | 15 +- ext/tag_tools/info.php | 12 +- ext/tag_tools/main.php | 8 +- ext/tagger_xml/info.php | 10 +- ext/tagger_xml/main.php | 4 +- ext/tips/info.php | 14 +- ext/tips/main.php | 11 +- ext/transcode/info.php | 12 +- ext/transcode/main.php | 2 +- ext/transcode/script.js | 4 +- ext/transcode/theme.php | 6 +- ext/transcode_video/info.php | 12 +- ext/transcode_video/main.php | 8 +- ext/transcode_video/script.js | 6 +- ext/transcode_video/theme.php | 6 +- ext/trash/info.php | 10 +- ext/trash/main.php | 2 +- ext/trash/theme.php | 4 +- ext/update/info.php | 12 +- ext/update/main.php | 2 +- ext/upgrade/info.php | 14 +- ext/upload/info.php | 14 +- ext/upload/main.php | 30 +-- ext/upload/theme.php | 2 +- ext/user/events.php | 39 ++-- ext/user/info.php | 12 +- ext/user/main.php | 41 ++-- ext/user/theme.php | 5 +- ext/user_config/info.php | 14 +- ext/user_config/main.php | 17 +- ext/user_config/theme.php | 2 +- ext/varnish/info.php | 14 +- ext/view/events/displaying_image_event.php | 3 +- .../image_admin_block_building_event.php | 8 +- .../events/image_info_box_building_event.php | 9 +- ext/view/events/image_info_set_event.php | 3 +- ext/view/info.php | 14 +- ext/view/main.php | 2 +- ext/view/theme.php | 6 +- ext/wiki/info.php | 14 +- ext/wiki/main.php | 89 +++----- ext/wiki/theme.php | 4 +- ext/word_filter/info.php | 12 +- tests/bootstrap.php | 39 ++-- themes/danbooru/page.class.php | 3 +- themes/danbooru/view.theme.php | 2 +- themes/danbooru2/page.class.php | 2 +- themes/futaba/comment.theme.php | 8 +- themes/futaba/page.class.php | 2 +- themes/lite/page.class.php | 3 +- themes/lite/setup.theme.php | 6 +- themes/lite/user_config.theme.php | 6 +- themes/material/home.theme.php | 4 +- themes/material/page.class.php | 2 +- themes/material/view.theme.php | 4 +- themes/rule34v2/home.theme.php | 4 +- 296 files changed, 1571 insertions(+), 2039 deletions(-) diff --git a/.github/workflows/test_and_publish.yml b/.github/workflows/test_and_publish.yml index a87ef278..278cc7af 100644 --- a/.github/workflows/test_and_publish.yml +++ b/.github/workflows/test_and_publish.yml @@ -22,7 +22,7 @@ jobs: strategy: fail-fast: false matrix: - php: ['7.3', '7.4', '8.0'] + php: ['7.4', '8.0'] database: ['pgsql', 'mysql', 'sqlite'] runs-on: ubuntu-latest diff --git a/composer.json b/composer.json index ba0b0314..e3f09fd9 100644 --- a/composer.json +++ b/composer.json @@ -31,7 +31,7 @@ ], "require" : { - "php" : "^7.3 | ^8.0", + "php" : "^7.4 | ^8.0", "ext-pdo": "*", "ext-json": "*", "ext-fileinfo": "*", diff --git a/core/basepage.php b/core/basepage.php index b9f223c7..4376772a 100644 --- a/core/basepage.php +++ b/core/basepage.php @@ -20,10 +20,8 @@ abstract class PageMode */ class BasePage { - /** @var string */ - public $mode = PageMode::PAGE; - /** @var string */ - private $mime; + public string $mode = PageMode::PAGE; + private string $mime; /** * Set what this page should do; "page", "data", or "redirect". @@ -52,19 +50,11 @@ class BasePage // ============================================== - /** @var string; public only for unit test */ - public $data = ""; - - /** @var string */ - private $file = null; - - /** @var bool */ - private $file_delete = false; - - /** @var string */ - private $filename = null; - - private $disposition = null; + public string $data = ""; // public only for unit test + private ?string $file = null; + private bool $file_delete = false; + private ?string $filename = null; + private ?string $disposition = null; /** * Set the raw data to be sent. @@ -91,8 +81,7 @@ class BasePage // ============================================== - /** @var string */ - public $redirect = ""; + public string $redirect = ""; /** * Set the URL to redirect to (remember to use make_link() if linking @@ -105,32 +94,25 @@ class BasePage // ============================================== - /** @var int */ - public $code = 200; - - /** @var string */ - public $title = ""; - - /** @var string */ - public $heading = ""; - - /** @var string */ - public $subheading = ""; + public int $code = 200; + public string $title = ""; + public string $heading = ""; + public string $subheading = ""; /** @var string[] */ - public $html_headers = []; + public array $html_headers = []; /** @var string[] */ - public $http_headers = []; + public array $http_headers = []; /** @var string[][] */ - public $cookies = []; + public array $cookies = []; /** @var Block[] */ - public $blocks = []; + public array $blocks = []; /** @var string[] */ - public $flash = []; + public array $flash = []; /** * Set the HTTP status code @@ -428,7 +410,7 @@ class BasePage $this->add_html_header("", 44); } - protected function get_nav_links() + protected function get_nav_links(): array { $pnbe = send_event(new PageNavBuildingEvent()); @@ -574,7 +556,7 @@ EOD; class PageNavBuildingEvent extends Event { - public $links = []; + public array $links = []; public function add_nav_link(string $name, Link $link, string $desc, ?bool $active = null, int $order = 50) { @@ -584,9 +566,9 @@ class PageNavBuildingEvent extends Event class PageSubNavBuildingEvent extends Event { - public $parent; + public string $parent; - public $links = []; + public array $links = []; public function __construct(string $parent) { @@ -602,11 +584,11 @@ class PageSubNavBuildingEvent extends Event class NavLink { - public $name; - public $link; - public $description; - public $order; - public $active = false; + public string $name; + public Link $link; + public string $description; + public int $order; + public bool $active = false; public function __construct(String $name, Link $link, String $description, ?bool $active = null, int $order = 50) { @@ -663,7 +645,7 @@ class NavLink } } -function sort_nav_links(NavLink $a, NavLink $b) +function sort_nav_links(NavLink $a, NavLink $b): int { return $a->order - $b->order; } diff --git a/core/block.php b/core/block.php index 2fdaa091..771eedc5 100644 --- a/core/block.php +++ b/core/block.php @@ -9,49 +9,37 @@ class Block { /** * The block's title. - * - * @var string */ - public $header; + public ?string $header; /** * The content of the block. - * - * @var string */ - public $body; + public ?string $body; /** * Where the block should be placed. The default theme supports * "main" and "left", other themes can add their own areas. - * - * @var string */ - public $section; + public string $section; /** * How far down the section the block should appear, higher * numbers appear lower. The scale is 0-100 by convention, * though any number will work. - * - * @var int */ - public $position; + public int $position; /** * A unique ID for the block. - * - * @var string */ - public $id; + public string $id; /** * Should this block count as content for the sake of * the 404 handler - * - * @var boolean */ - public $is_content = true; + public bool $is_content = true; public function __construct(string $header=null, string $body=null, string $section="main", int $position=50, string $id=null) { @@ -63,7 +51,9 @@ class Block if (is_null($id)) { $id = (empty($header) ? md5($body ?? '') : $header) . $section; } - $this->id = preg_replace('/[^\w-]/', '', str_replace(' ', '_', $id)); + $str_id = preg_replace('/[^\w-]/', '', str_replace(' ', '_', $id)); + assert(is_string($str_id)); + $this->id = $str_id; } /** diff --git a/core/cacheengine.php b/core/cacheengine.php index 75b7891e..b29039a0 100644 --- a/core/cacheengine.php +++ b/core/cacheengine.php @@ -2,8 +2,8 @@ interface CacheEngine { public function get(string $key); - public function set(string $key, $val, int $time=0); - public function delete(string $key); + public function set(string $key, $val, int $time=0): void; + public function delete(string $key): void; } class NoCache implements CacheEngine @@ -12,18 +12,17 @@ class NoCache implements CacheEngine { return false; } - public function set(string $key, $val, int $time=0) + public function set(string $key, $val, int $time=0): void { } - public function delete(string $key) + public function delete(string $key): void { } } class MemcachedCache implements CacheEngine { - /** @var ?Memcached */ - public $memcache=null; + public ?Memcached $memcache=null; public function __construct(string $args) { @@ -52,7 +51,7 @@ class MemcachedCache implements CacheEngine } } - public function set(string $key, $val, int $time=0) + public function set(string $key, $val, int $time=0): void { $key = urlencode($key); @@ -63,7 +62,7 @@ class MemcachedCache implements CacheEngine } } - public function delete(string $key) + public function delete(string $key): void { $key = urlencode($key); @@ -87,12 +86,12 @@ class APCCache implements CacheEngine return apc_fetch($key); } - public function set(string $key, $val, int $time=0) + public function set(string $key, $val, int $time=0): void { apc_store($key, $val, $time); } - public function delete(string $key) + public function delete(string $key): void { apc_delete($key); } @@ -100,7 +99,7 @@ class APCCache implements CacheEngine class RedisCache implements CacheEngine { - private $redis=null; + private Redis $redis; public function __construct(string $args) { @@ -116,7 +115,7 @@ class RedisCache implements CacheEngine return $this->redis->get($key); } - public function set(string $key, $val, int $time=0) + public function set(string $key, $val, int $time=0): void { if ($time > 0) { $this->redis->setEx($key, $time, $val); @@ -125,7 +124,7 @@ class RedisCache implements CacheEngine } } - public function delete(string $key) + public function delete(string $key): void { $this->redis->del($key); } @@ -134,9 +133,9 @@ class RedisCache implements CacheEngine class Cache { public $engine; - public $hits=0; - public $misses=0; - public $time=0; + public int $hits=0; + public int $misses=0; + public int $time=0; public function __construct(?string $dsn) { diff --git a/core/command_builder.php b/core/command_builder.php index afc1e796..e7500a5b 100644 --- a/core/command_builder.php +++ b/core/command_builder.php @@ -5,9 +5,9 @@ // quotes are only needed if the path to convert contains a space; some other times, quotes break things, see github bug #27 class CommandBuilder { - private $executable; - private $args = []; - public $output; + private string $executable; + private array $args = []; + public array $output; public function __construct(String $executable) { diff --git a/core/config.php b/core/config.php index 1be1e8d0..ae302ac6 100644 --- a/core/config.php +++ b/core/config.php @@ -130,7 +130,7 @@ interface Config */ abstract class BaseConfig implements Config { - public $values = []; + public array $values = []; public function set_int(string $name, ?int $value): void { @@ -256,12 +256,10 @@ abstract class BaseConfig implements Config */ class DatabaseConfig extends BaseConfig { - /** @var Database */ - private $database = null; - - private $table_name; - private $sub_column; - private $sub_value; + private Database $database; + private string $table_name; + private ?string $sub_column; + private ?string $sub_value; public function __construct( Database $database, diff --git a/core/database.php b/core/database.php index 63d05040..e8c6fca0 100644 --- a/core/database.php +++ b/core/database.php @@ -13,30 +13,23 @@ abstract class DatabaseDriver */ class Database { - /** @var string */ - private $dsn; + private string $dsn; /** * The PDO database connection object, for anyone who wants direct access. - * @var null|PDO */ - private $db = null; - - /** - * @var float - */ - public $dbtime = 0.0; + private ?PDO $db = null; + public float $dbtime = 0.0; /** * Meta info about the database engine. - * @var DBEngine|null */ - private $engine = null; + private ?DBEngine $engine = null; /** * How many queries this DB object has run */ - public $query_count = 0; + public int $query_count = 0; public function __construct(string $dsn) { diff --git a/core/dbengine.php b/core/dbengine.php index 0e1a7254..355cd099 100644 --- a/core/dbengine.php +++ b/core/dbengine.php @@ -7,16 +7,15 @@ abstract class SCORE abstract class DBEngine { - /** @var null|string */ - public $name = null; + public ?string $name = null; public function init(PDO $db) { } - public function scoreql_to_sql(string $scoreql): string + public function scoreql_to_sql(string $data): string { - return $scoreql; + return $data; } public function create_table_sql(string $name, string $data): string @@ -33,8 +32,7 @@ abstract class DBEngine class MySQL extends DBEngine { - /** @var string */ - public $name = DatabaseDriver::MYSQL; + public ?string $name = DatabaseDriver::MYSQL; public function init(PDO $db) { @@ -73,8 +71,7 @@ class MySQL extends DBEngine class PostgreSQL extends DBEngine { - /** @var string */ - public $name = DatabaseDriver::PGSQL; + public ?string $name = DatabaseDriver::PGSQL; public function init(PDO $db) { @@ -122,19 +119,19 @@ class PostgreSQL extends DBEngine } // shimmie functions for export to sqlite -function _unix_timestamp($date) +function _unix_timestamp($date): int { return strtotime($date); } -function _now() +function _now(): string { return date("Y-m-d H:i:s"); } -function _floor($a) +function _floor($a): float { return floor($a); } -function _log($a, $b=null) +function _log($a, $b=null): float { if (is_null($b)) { return log($a); @@ -142,35 +139,34 @@ function _log($a, $b=null) return log($a, $b); } } -function _isnull($a) +function _isnull($a): bool { return is_null($a); } -function _md5($a) +function _md5($a): string { return md5($a); } -function _concat($a, $b) +function _concat($a, $b): string { return $a . $b; } -function _lower($a) +function _lower($a): string { return strtolower($a); } -function _rand() +function _rand(): int { return rand(); } -function _ln($n) +function _ln($n): float { return log($n); } class SQLite extends DBEngine { - /** @var string */ - public $name = DatabaseDriver::SQLITE; + public ?string $name = DatabaseDriver::SQLITE; public function init(PDO $db) { diff --git a/core/event.php b/core/event.php index 84804e99..7a563fff 100644 --- a/core/event.php +++ b/core/event.php @@ -6,13 +6,13 @@ */ abstract class Event { - public $stop_processing = false; + public bool $stop_processing = false; public function __construct() { } - public function __toString() + public function __toString(): string { return var_export($this, true); } @@ -42,19 +42,11 @@ class InitExtEvent extends Event class PageRequestEvent extends Event { /** - * @var array + * @var string[] */ public $args; - - /** - * @var int - */ - public $arg_count; - - /** - * @var int - */ - public $part_count; + public int $arg_count; + public int $part_count; public function __construct(string $path) { @@ -179,15 +171,12 @@ class PageRequestEvent extends Event */ class CommandEvent extends Event { - /** - * @var string - */ - public $cmd = "help"; + public string $cmd = "help"; /** - * @var array + * @var string[] */ - public $args = []; + public array $args = []; /** * #param string[] $args @@ -256,24 +245,18 @@ class TextFormattingEvent extends Event { /** * For reference - * - * @var string */ - public $original; + public string $original; /** * with formatting applied - * - * @var string */ - public $formatted; + public string $formatted; /** * with formatting removed - * - * @var string */ - public $stripped; + public string $stripped; public function __construct(string $text) { @@ -296,38 +279,30 @@ class LogEvent extends Event { /** * a category, normally the extension name - * - * @var string */ - public $section; + public string $section; /** * See python... - * - * @var int */ - public $priority = 0; + public int $priority = 0; /** * Free text to be logged - * - * @var string */ - public $message; + public string $message; /** * The time that the event was created - * - * @var int */ - public $time; + public int $time; /** * Extra data to be held separate * - * @var array + * @var string[] */ - public $args; + public array $args; public function __construct(string $section, int $priority, string $message) { diff --git a/core/exceptions.php b/core/exceptions.php index af83415f..fa2e0d07 100644 --- a/core/exceptions.php +++ b/core/exceptions.php @@ -7,11 +7,8 @@ */ class SCoreException extends RuntimeException { - /** @var string|null */ - public $query; - - /** @var string */ - public $error; + public ?string $query; + public string $error; public function __construct(string $msg, ?string $query=null) { @@ -23,21 +20,16 @@ class SCoreException extends RuntimeException class InstallerException extends RuntimeException { - /** @var string */ - public $title; + public string $title; + public string $body; + public int $exit_code; - /** @var string */ - public $body; - - /** @var int */ - public $code; - - public function __construct(string $title, string $body, int $code) + public function __construct(string $title, string $body, int $exit_code) { parent::__construct($body); $this->title = $title; $this->body = $body; - $this->code = $code; + $this->exit_code = $exit_code; } } diff --git a/core/extension.php b/core/extension.php index 55cf3de2..b5a5ed3e 100644 --- a/core/extension.php +++ b/core/extension.php @@ -13,16 +13,11 @@ */ abstract class Extension { - /** @var string */ - public $key; + public string $key; + protected ?Themelet $theme; + public ?ExtensionInfo $info; - /** @var Themelet */ - protected $theme; - - /** @var ExtensionInfo */ - public $info; - - private static $enabled_extensions = []; + private static array $enabled_extensions = []; public function __construct($class = null) { @@ -122,35 +117,31 @@ abstract class ExtensionInfo public const LICENSE_MIT = "MIT"; public const LICENSE_WTFPL = "WTFPL"; + public const VISIBLE_DEFAULT = "default"; public const VISIBLE_ADMIN = "admin"; public const VISIBLE_HIDDEN = "hidden"; - private const VALID_VISIBILITY = [self::VISIBLE_ADMIN, self::VISIBLE_HIDDEN]; + private const VALID_VISIBILITY = [self::VISIBLE_DEFAULT, self::VISIBLE_ADMIN, self::VISIBLE_HIDDEN]; - public $key; + public string $key; - public $core = false; + public bool $core = false; + public bool $beta = false; - public $beta = false; + public string $name; + public string $license; + public string $description; + public array $authors = []; + public array $dependencies = []; + public array $conflicts = []; + public string $visibility = self::VISIBLE_DEFAULT; + public ?string $link = null; + public ?string $version = null; + public ?string $documentation = null; - public $name; - public $authors = []; - public $link; - public $license; - public $version; - public $dependencies = []; - public $conflicts = []; - public $visibility; - public $description; - public $documentation; - - /** @var array which DBs this ext supports (blank for 'all') */ - public $db_support = []; - - /** @var bool */ - private $supported = null; - - /** @var string */ - private $support_info = null; + /** @var string[] which DBs this ext supports (blank for 'all') */ + public array $db_support = []; + private ?bool $supported = null; + private ?string $support_info = null; public function is_supported(): bool { @@ -168,9 +159,9 @@ abstract class ExtensionInfo return $this->support_info; } - private static $all_info_by_key = []; - private static $all_info_by_class = []; - private static $core_extensions = []; + private static array $all_info_by_key = []; + private static array $all_info_by_class = []; + private static array $core_extensions = []; protected function __construct() { @@ -283,7 +274,7 @@ abstract class FormatterExtension extends Extension */ abstract class DataHandlerExtension extends Extension { - protected $SUPPORTED_MIME = []; + protected array $SUPPORTED_MIME = []; protected function move_upload_to_archive(DataUploadEvent $event) { @@ -335,7 +326,9 @@ abstract class DataHandlerExtension extends Extension } send_event(new ImageReplaceEvent($event->replace_id, $image)); - $event->image_id = $event->replace_id; + $_id = $event->replace_id; + assert(!is_null($_id)); + $event->image_id = $_id; } else { $image = $this->create_image_from_data(warehouse_path(Image::IMAGE_DIR, $event->hash), $event->metadata); if (is_null($image)) { diff --git a/core/imageboard/event.php b/core/imageboard/event.php index a6fa55b0..346db5e6 100644 --- a/core/imageboard/event.php +++ b/core/imageboard/event.php @@ -5,13 +5,9 @@ */ class ImageAdditionEvent extends Event { - /** @var User */ - public $user; - - /** @var Image */ - public $image; - - public $merged = false; + public User $user; + public Image $image; + public bool $merged = false; /** * Inserts a new image into the database with its associated @@ -34,11 +30,8 @@ class ImageAdditionException extends SCoreException */ class ImageDeletionEvent extends Event { - /** @var Image */ - public $image; - - /** @var bool */ - public $force = false; + public Image $image; + public bool $force = false; /** * Deletes an image. @@ -59,10 +52,8 @@ class ImageDeletionEvent extends Event */ class ImageReplaceEvent extends Event { - /** @var int */ - public $id; - /** @var Image */ - public $image; + public int $id; + public Image $image; /** * Replaces an image. @@ -88,15 +79,10 @@ class ImageReplaceException extends SCoreException */ class ThumbnailGenerationEvent extends Event { - /** @var string */ - public $hash; - /** @var string */ - public $mime; - /** @var bool */ - public $force; - - /** @var bool */ - public $generated; + public string $hash; + public string $mime; + public bool $force; + public bool $generated; /** * Request a thumbnail be made for an image object @@ -121,14 +107,10 @@ class ThumbnailGenerationEvent extends Event */ class ParseLinkTemplateEvent extends Event { - /** @var string */ - public $link; - /** @var string */ - public $text; - /** @var string */ - public $original; - /** @var Image */ - public $image; + public string $link; + public string $text; + public string $original; + public Image $image; public function __construct(string $link, Image $image) { diff --git a/core/imageboard/image.php b/core/imageboard/image.php index a57d19d2..2a7b7692 100644 --- a/core/imageboard/image.php +++ b/core/imageboard/image.php @@ -13,68 +13,31 @@ class Image public const IMAGE_DIR = "images"; public const THUMBNAIL_DIR = "thumbs"; - /** @var null|int */ - public $id = null; - - /** @var int */ - public $height; - - /** @var int */ - public $width; - - /** @var string */ - public $hash; - - /** @var int */ - public $filesize; - - /** @var string */ - public $filename; - - /** @var string */ - private $ext; - - /** @var string */ - private $mime; + public ?int $id = null; + public int $height; + public int $width; + public string $hash; + public int $filesize; + public string $filename; + private string $ext; + private string $mime; /** @var string[]|null */ - public $tag_array; + public ?array $tag_array; + public int $owner_id; + public string $owner_ip; + public string $posted; + public ?string $source; + public bool $locked = false; + public ?bool $lossless = null; + public ?bool $video = null; + public ?string $video_codec = null; + public ?bool $image = null; + public ?bool $audio = null; + public ?int $length = null; - /** @var int */ - public $owner_id; - - /** @var string */ - public $owner_ip; - - /** @var string */ - public $posted; - - /** @var string */ - public $source; - - /** @var boolean */ - public $locked = false; - - /** @var boolean */ - public $lossless = null; - - /** @var boolean */ - public $video = null; - - /** @var string */ - public $video_codec = null; - - /** @var boolean */ - public $image = null; - - /** @var boolean */ - public $audio = null; - - /** @var int */ - public $length = null; - - public static $bool_props = ["locked", "lossless", "video", "audio"]; - public static $int_props = ["id", "owner_id", "height", "width", "filesize", "length"]; + public static array $bool_props = ["locked", "lossless", "video", "audio", "image"]; + public static array $int_props = ["id", "owner_id", "height", "width", "filesize", "length"]; /** * One will very rarely construct an image directly, more common @@ -145,7 +108,7 @@ class Image private static function find_images_internal(int $start = 0, ?int $limit = null, array $tags=[]): iterable { - global $database, $user, $config; + global $database, $user; if ($start < 0) { $start = 0; @@ -161,9 +124,7 @@ class Image } $querylet = Image::build_search_querylet($tags, $limit, $start); - $result = $database->get_all_iterable($querylet->sql, $querylet->variables); - - return $result; + return $database->get_all_iterable($querylet->sql, $querylet->variables); } /** @@ -625,7 +586,9 @@ class Image public function set_mime($mime): void { $this->mime = $mime; - $this->ext = FileExtension::get_for_mime($this->get_mime()); + $ext = FileExtension::get_for_mime($this->get_mime()); + assert($ext != null); + $this->ext = $ext; } diff --git a/core/imageboard/search.php b/core/imageboard/search.php index 30456459..981cdd23 100644 --- a/core/imageboard/search.php +++ b/core/imageboard/search.php @@ -1,10 +1,8 @@ title, $e->body, $e->code); + die_nicely($e->title, $e->body, $e->exit_code); } } diff --git a/core/polyfills.php b/core/polyfills.php index 33be6cec..a2785f0f 100644 --- a/core/polyfills.php +++ b/core/polyfills.php @@ -246,21 +246,22 @@ function find_header(array $headers, string $name): ?string if (!function_exists('mb_strlen')) { // TODO: we should warn the admin that they are missing multibyte support - function mb_strlen($str, $encoding) + /** @noinspection PhpUnusedParameterInspection */ + function mb_strlen($str, $encoding): int { return strlen($str); } - function mb_internal_encoding($encoding) + function mb_internal_encoding($encoding): void { } - function mb_strtolower($str) + function mb_strtolower($str): string { return strtolower($str); } } /** @noinspection PhpUnhandledExceptionInspection */ -function get_subclasses_of(string $parent) +function get_subclasses_of(string $parent): array { $result = []; foreach (get_declared_classes() as $class) { @@ -327,7 +328,7 @@ function get_base_href(): string /** * The opposite of the standard library's parse_url */ -function unparse_url($parsed_url) +function unparse_url(array $parsed_url): string { $scheme = isset($parsed_url['scheme']) ? $parsed_url['scheme'] . '://' : ''; $host = isset($parsed_url['host']) ? $parsed_url['host'] : ''; @@ -345,14 +346,14 @@ function unparse_url($parsed_url) if (!function_exists('str_starts_with')) { function str_starts_with(string $haystack, string $needle): bool { - return \strncmp($haystack, $needle, \strlen($needle)) === 0; + return strncmp($haystack, $needle, strlen($needle)) === 0; } } if (!function_exists('str_ends_with')) { function str_ends_with(string $haystack, string $needle): bool { - return $needle === '' || $needle === \substr($haystack, - \strlen($needle)); + return $needle === '' || $needle === substr($haystack, - strlen($needle)); } } @@ -520,13 +521,9 @@ function parse_shorthand_int(string $limit): int /** @noinspection PhpMissingBreakStatementInspection */ case 't': $value *= 1024; // fall through /** @noinspection PhpMissingBreakStatementInspection */ - // no break case 'g': $value *= 1024; // fall through /** @noinspection PhpMissingBreakStatementInspection */ - // no break case 'm': $value *= 1024; // fall through - /** @noinspection PhpMissingBreakStatementInspection */ - // no break case 'k': $value *= 1024; break; default: $value = -1; } @@ -800,7 +797,7 @@ function iterator_map_to_array(callable $callback, iterator $iter): array return iterator_to_array(iterator_map($callback, $iter)); } -function stringer($s) +function stringer($s): string { if (is_array($s)) { if (isset($s[0])) { diff --git a/core/urls.php b/core/urls.php index 1ca3192d..97a0e957 100644 --- a/core/urls.php +++ b/core/urls.php @@ -2,8 +2,8 @@ class Link { - public $page; - public $query; + public ?string $page; + public ?string $query; public function __construct(?string $page=null, ?string $query=null) { diff --git a/core/user.php b/core/user.php index 220e9d57..f9319970 100644 --- a/core/user.php +++ b/core/user.php @@ -15,22 +15,12 @@ function _new_user(array $row): User */ class User { - /** @var int */ - public $id; - - /** @var string */ - public $name; - - /** @var string */ - public $email; - - public $join_date; - - /** @var string */ - public $passhash; - - /** @var UserClass */ - public $class; + public int $id; + public string $name; + public ?string $email; + public string $join_date; + public ?string $passhash; + public UserClass $class; /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Initialisation * diff --git a/core/userclass.php b/core/userclass.php index ba77884c..7fd6b7dc 100644 --- a/core/userclass.php +++ b/core/userclass.php @@ -10,21 +10,9 @@ $_shm_user_classes = []; */ class UserClass { - - /** - * @var ?string - */ - public $name = null; - - /** - * @var ?UserClass - */ - public $parent = null; - - /** - * @var array - */ - public $abilities = []; + public ?string $name = null; + public ?UserClass $parent = null; + public array $abilities = []; public function __construct(string $name, string $parent = null, array $abilities = []) { diff --git a/core/util.php b/core/util.php index a6c350f4..03f0b63e 100644 --- a/core/util.php +++ b/core/util.php @@ -12,6 +12,7 @@ use function MicroHTML\TFOOT; use function MicroHTML\TR; use function MicroHTML\TH; use function MicroHTML\TD; +use MicroHTML\HTMLElement; /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\ * Misc * @@ -359,7 +360,7 @@ function path_to_tags(string $path): string } -function join_url(string $base, string ...$paths) +function join_url(string $base, string ...$paths): string { $output = $base; foreach ($paths as $path) { @@ -410,7 +411,7 @@ function remove_empty_dirs(string $dir): bool } } if ($result===true) { - $result = $result && rmdir($dir); + $result = rmdir($dir); } return $result; } @@ -584,7 +585,6 @@ function _get_themelet_files(string $_theme): array /** * Used to display fatal errors to the web user. - * @noinspection PhpPossiblePolymorphicInvocationInspection */ function _fatal_error(Exception $e): void { @@ -703,7 +703,7 @@ function make_form(string $target, string $method="POST", bool $multipart=false, return '
'.$extra_inputs; } -function SHM_FORM(string $target, string $method="POST", bool $multipart=false, string $form_id="", string $onsubmit="") +function SHM_FORM(string $target, string $method="POST", bool $multipart=false, string $form_id="", string $onsubmit=""): HTMLElement { global $user; @@ -728,19 +728,19 @@ function SHM_FORM(string $target, string $method="POST", bool $multipart=false, ); } -function SHM_SIMPLE_FORM($target, ...$children) +function SHM_SIMPLE_FORM($target, ...$children): HTMLElement { $form = SHM_FORM($target); $form->appendChild(emptyHTML(...$children)); return $form; } -function SHM_SUBMIT(string $text) +function SHM_SUBMIT(string $text): HTMLElement { return INPUT(["type"=>"submit", "value"=>$text]); } -function SHM_COMMAND_EXAMPLE(string $ex, string $desc) +function SHM_COMMAND_EXAMPLE(string $ex, string $desc): HTMLElement { return DIV( ["class"=>"command_example"], @@ -749,7 +749,7 @@ function SHM_COMMAND_EXAMPLE(string $ex, string $desc) ); } -function SHM_USER_FORM(User $duser, string $target, string $title, $body, $foot) +function SHM_USER_FORM(User $duser, string $target, string $title, $body, $foot): HTMLElement { if (is_string($foot)) { $foot = TFOOT(TR(TD(["colspan"=>"2"], INPUT(["type"=>"submit", "value"=>$foot])))); @@ -769,16 +769,16 @@ function SHM_USER_FORM(User $duser, string $target, string $title, $body, $foot) } const BYTE_DENOMINATIONS = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']; -function human_filesize(int $bytes, $decimals = 2) +function human_filesize(int $bytes, $decimals = 2): string { $factor = floor((strlen(strval($bytes)) - 1) / 3); return sprintf("%.{$decimals}f", $bytes / pow(1024, $factor)) . @BYTE_DENOMINATIONS[$factor]; } -/* +/** * Generates a unique key for the website to prevent unauthorized access. */ -function generate_key(int $length = 20) +function generate_key(int $length = 20): string { $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; $randomString = ''; diff --git a/ext/admin/info.php b/ext/admin/info.php index 333c452b..fb3ea72b 100644 --- a/ext/admin/info.php +++ b/ext/admin/info.php @@ -4,12 +4,12 @@ class AdminPageInfo extends ExtensionInfo { public const KEY = "admin"; - public $key = self::KEY; - public $name = "Admin Controls"; - public $url = self::SHIMMIE_URL; - public $authors = self::SHISH_AUTHOR; - public $license = self::LICENSE_GPLV2; - public $description = "Provides a base for various small admin functions"; - public $core = true; - public $visibility = self::VISIBLE_HIDDEN; + public string $key = self::KEY; + public string $name = "Admin Controls"; + public string $url = self::SHIMMIE_URL; + public array $authors = self::SHISH_AUTHOR; + public string $license = self::LICENSE_GPLV2; + public string $description = "Provides a base for various small admin functions"; + public bool $core = true; + public string $visibility = self::VISIBLE_HIDDEN; } diff --git a/ext/admin/main.php b/ext/admin/main.php index 005b55c0..31b25eb2 100644 --- a/ext/admin/main.php +++ b/ext/admin/main.php @@ -1,13 +1,11 @@ -/alias/list; only site admins can edit it, other people can view and download it'; - public $core = true; + public string $key = self::KEY; + public string $name = "Alias Editor"; + public string $url = self::SHIMMIE_URL; + public array $authors = self::SHISH_AUTHOR; + public string $license = self::LICENSE_GPLV2; + public string $description = "Edit the alias list"; + public ?string $documentation = 'The list is visible at /alias/list; only site admins can edit it, other people can view and download it'; + public bool $core = true; } diff --git a/ext/alias_editor/main.php b/ext/alias_editor/main.php index 73eb94f0..6a0d0dfc 100644 --- a/ext/alias_editor/main.php +++ b/ext/alias_editor/main.php @@ -26,10 +26,8 @@ class AliasTable extends Table class AddAliasEvent extends Event { - /** @var string */ - public $oldtag; - /** @var string */ - public $newtag; + public string $oldtag; + public string $newtag; public function __construct(string $oldtag, string $newtag) { @@ -41,7 +39,7 @@ class AddAliasEvent extends Event class DeleteAliasEvent extends Event { - public $oldtag; + public string $oldtag; public function __construct(string $oldtag) { @@ -57,7 +55,7 @@ class AddAliasException extends SCoreException class AliasEditor extends Extension { /** @var AliasEditorTheme */ - protected $theme; + protected ?Themelet $theme; public function onPageRequest(PageRequestEvent $event) { diff --git a/ext/approval/info.php b/ext/approval/info.php index 03ad7631..7c469789 100644 --- a/ext/approval/info.php +++ b/ext/approval/info.php @@ -4,9 +4,9 @@ class ApprovalInfo extends ExtensionInfo { public const KEY = "approval"; - public $key = self::KEY; - public $name = "Approval"; - public $authors = ["Matthew Barbour"=>"matthew@darkholme.net"]; - public $license = self::LICENSE_WTFPL; - public $description = "Adds an approval step to the upload/import process."; + public string $key = self::KEY; + public string $name = "Approval"; + public array $authors = ["Matthew Barbour"=>"matthew@darkholme.net"]; + public string $license = self::LICENSE_WTFPL; + public string $description = "Adds an approval step to the upload/import process."; } diff --git a/ext/approval/main.php b/ext/approval/main.php index 1f6216c0..1ac6c764 100644 --- a/ext/approval/main.php +++ b/ext/approval/main.php @@ -10,7 +10,7 @@ abstract class ApprovalConfig class Approval extends Extension { /** @var ApprovalTheme */ - protected $theme; + protected ?Themelet $theme; public function onInitExt(InitExtEvent $event) { diff --git a/ext/approval/theme.php b/ext/approval/theme.php index e6033d72..fa6b8747 100644 --- a/ext/approval/theme.php +++ b/ext/approval/theme.php @@ -5,7 +5,7 @@ use function MicroHTML\INPUT; class ApprovalTheme extends Themelet { - public function get_image_admin_html(Image $image) + public function get_image_admin_html(Image $image): string { if ($image->approved===true) { $html = SHM_SIMPLE_FORM( @@ -24,8 +24,7 @@ class ApprovalTheme extends Themelet return (string)$html; } - - public function get_help_html() + public function get_help_html(): string { return '

Search for posts that are approved/not approved.

diff --git a/ext/artists/info.php b/ext/artists/info.php index 7b10ee95..702a71e2 100644 --- a/ext/artists/info.php +++ b/ext/artists/info.php @@ -4,11 +4,11 @@ class ArtistsInfo extends ExtensionInfo { public const KEY = "artists"; - public $key = self::KEY; - public $name = "Artists System"; - public $url = self::SHIMMIE_URL; - public $authors = ["Sein Kraft"=>"mail@seinkraft.info","Alpha"=>"alpha@furries.com.ar"]; - public $license = self::LICENSE_GPLV2; - public $description = "Simple artists extension"; - public $beta = true; + public string $key = self::KEY; + public string $name = "Artists System"; + public string $url = self::SHIMMIE_URL; + public array $authors = ["Sein Kraft"=>"mail@seinkraft.info","Alpha"=>"alpha@furries.com.ar"]; + public string $license = self::LICENSE_GPLV2; + public string $description = "Simple artists extension"; + public bool $beta = true; } diff --git a/ext/artists/main.php b/ext/artists/main.php index 77f2de0d..57718d29 100644 --- a/ext/artists/main.php +++ b/ext/artists/main.php @@ -2,12 +2,9 @@ class AuthorSetEvent extends Event { - /** @var Image */ - public $image; - /** @var User */ - public $user; - /** @var string */ - public $author; + public Image $image; + public User $user; + public string $author; public function __construct(Image $image, User $user, string $author) { @@ -21,7 +18,7 @@ class AuthorSetEvent extends Event class Artists extends Extension { /** @var ArtistsTheme */ - protected $theme; + protected ?Themelet $theme; public function onImageInfoSet(ImageInfoSetEvent $event) { @@ -683,7 +680,7 @@ class Artists extends Extension ); } - private function add_artist() + private function add_artist(): int { global $user; $inputs = validate_input([ diff --git a/ext/artists/theme.php b/ext/artists/theme.php index f3a52d24..4c47666c 100644 --- a/ext/artists/theme.php +++ b/ext/artists/theme.php @@ -546,7 +546,7 @@ class ArtistsTheme extends Themelet return $html; } - public function get_help_html() + public function get_help_html(): string { return '

Search for posts with a particular artist.

diff --git a/ext/auto_tagger/info.php b/ext/auto_tagger/info.php index 2ae694b7..8d3b7c56 100644 --- a/ext/auto_tagger/info.php +++ b/ext/auto_tagger/info.php @@ -4,9 +4,9 @@ class AutoTaggerInfo extends ExtensionInfo { public const KEY = "auto_tagger"; - public $key = self::KEY; - public $name = "Auto-Tagger"; - public $authors = ["Matthew Barbour"=>"matthew@darkholme.net"]; - public $license = self::LICENSE_WTFPL; - public $description = "Provides several automatic tagging functions"; + public string $key = self::KEY; + public string $name = "Auto-Tagger"; + public array $authors = ["Matthew Barbour"=>"matthew@darkholme.net"]; + public string $license = self::LICENSE_WTFPL; + public string $description = "Provides several automatic tagging functions"; } diff --git a/ext/auto_tagger/main.php b/ext/auto_tagger/main.php index 11782cb9..378e18b1 100644 --- a/ext/auto_tagger/main.php +++ b/ext/auto_tagger/main.php @@ -28,10 +28,8 @@ class AutoTaggerTable extends Table class AddAutoTagEvent extends Event { - /** @var string */ - public $tag; - /** @var string */ - public $additional_tags; + public string $tag; + public string $additional_tags; public function __construct(string $tag, string $additional_tags) { @@ -43,7 +41,7 @@ class AddAutoTagEvent extends Event class DeleteAutoTagEvent extends Event { - public $tag; + public string $tag; public function __construct(string $tag) { @@ -63,7 +61,7 @@ class AddAutoTagException extends SCoreException class AutoTagger extends Extension { /** @var AutoTaggerTheme */ - protected $theme; + protected ?Themelet $theme; public function onPageRequest(PageRequestEvent $event) { diff --git a/ext/autocomplete/info.php b/ext/autocomplete/info.php index 0c6c912b..f0d7186a 100644 --- a/ext/autocomplete/info.php +++ b/ext/autocomplete/info.php @@ -4,8 +4,8 @@ class AutoCompleteInfo extends ExtensionInfo { public const KEY = "autocomplete"; - public $key = self::KEY; - public $name = "Autocomplete"; - public $authors = ["Daku"=>"admin@codeanimu.net"]; - public $description = "Adds autocomplete to search & tagging."; + public string $key = self::KEY; + public string $name = "Autocomplete"; + public array $authors = ["Daku"=>"admin@codeanimu.net"]; + public string $description = "Adds autocomplete to search & tagging."; } diff --git a/ext/autocomplete/main.php b/ext/autocomplete/main.php index be60a704..2fce4876 100644 --- a/ext/autocomplete/main.php +++ b/ext/autocomplete/main.php @@ -3,7 +3,7 @@ class AutoComplete extends Extension { /** @var AutoCompleteTheme */ - protected $theme; + protected ?Themelet $theme; public function get_priority(): int { diff --git a/ext/autocomplete/script.js b/ext/autocomplete/script.js index 98c7296e..3180d673 100644 --- a/ext/autocomplete/script.js +++ b/ext/autocomplete/script.js @@ -63,12 +63,12 @@ document.addEventListener('DOMContentLoaded', () => { var keyCode = e.keyCode || e.which; //Stop tags containing space. - if(keyCode == 32) { + if(keyCode === 32) { e.preventDefault(); $('.autocomplete_tags').tagit('createTag', $(this).val()); $(this).autocomplete('close'); - } else if (keyCode == 9) { + } else if (keyCode === 9) { e.preventDefault(); var tag = $('.tagit-autocomplete[style*=\"display: block\"] > li:focus, .tagit-autocomplete[style*=\"display: block\"] > li:first').first(); diff --git a/ext/ban_words/info.php b/ext/ban_words/info.php index 664ba0e4..e5862a54 100644 --- a/ext/ban_words/info.php +++ b/ext/ban_words/info.php @@ -4,13 +4,13 @@ class BanWordsInfo extends ExtensionInfo { public const KEY = "ban_words"; - public $key = self::KEY; - public $name = "Comment Word Ban"; - public $url = self::SHIMMIE_URL; - public $authors = self::SHISH_AUTHOR; - public $license = self::LICENSE_GPLV2; - public $description = "For stopping spam and other comment abuse"; - public $documentation = + public string $key = self::KEY; + public string $name = "Comment Word Ban"; + public string $url = self::SHIMMIE_URL; + public array $authors = self::SHISH_AUTHOR; + public string $license = self::LICENSE_GPLV2; + public string $description = "For stopping spam and other comment abuse"; + public ?string $documentation = "Allows an administrator to ban certain words from comments. This can be a very simple but effective way of stopping spam; just add \"viagra\", \"porn\", etc to the diff --git a/ext/bbcode/info.php b/ext/bbcode/info.php index ae10d345..7759be1d 100644 --- a/ext/bbcode/info.php +++ b/ext/bbcode/info.php @@ -4,14 +4,14 @@ class BBCodeInfo extends ExtensionInfo { public const KEY = "bbcode"; - public $key = self::KEY; - public $name = "BBCode"; - public $url = self::SHIMMIE_URL; - public $authors = self::SHISH_AUTHOR; - public $license = self::LICENSE_GPLV2; - public $core = true; - public $description = "Turns BBCode into HTML"; - public $documentation = + public string $key = self::KEY; + public string $name = "BBCode"; + public string $url = self::SHIMMIE_URL; + public array $authors = self::SHISH_AUTHOR; + public string $license = self::LICENSE_GPLV2; + public bool $core = true; + public string $description = "Turns BBCode into HTML"; + public ?string $documentation = " Basic formatting tags:
  • [b]bold[/b] diff --git a/ext/bbcode/test.php b/ext/bbcode/test.php index 8284ae92..e3357e28 100644 --- a/ext/bbcode/test.php +++ b/ext/bbcode/test.php @@ -96,13 +96,13 @@ class BBCodeTest extends ShimmiePHPUnitTestCase ); } - private function filter($in) + private function filter($in): string { $bb = new BBCode(); return $bb->format($in); } - private function strip($in) + private function strip($in): string { $bb = new BBCode(); return $bb->strip($in); diff --git a/ext/biography/info.php b/ext/biography/info.php index 12147c22..4c3b63e1 100644 --- a/ext/biography/info.php +++ b/ext/biography/info.php @@ -4,10 +4,10 @@ class BiographyInfo extends ExtensionInfo { public const KEY = "biography"; - public $key = self::KEY; - public $name = "User Bios"; - public $url = self::SHIMMIE_URL; - public $authors = self::SHISH_AUTHOR; - public $license = self::LICENSE_GPLV2; - public $description = "Allow users to write a bit about themselves"; + public string $key = self::KEY; + public string $name = "User Bios"; + public string $url = self::SHIMMIE_URL; + public array $authors = self::SHISH_AUTHOR; + public string $license = self::LICENSE_GPLV2; + public string $description = "Allow users to write a bit about themselves"; } diff --git a/ext/biography/main.php b/ext/biography/main.php index 913bf9df..6c5371ed 100644 --- a/ext/biography/main.php +++ b/ext/biography/main.php @@ -3,11 +3,11 @@ class Biography extends Extension { /** @var BiographyTheme */ - protected $theme; + protected ?Themelet $theme; public function onUserPageBuilding(UserPageBuildingEvent $event) { - global $database, $page, $user; + global $page, $user; $duser = $event->display_user; $duser_config = UserConfig::get_for_user($event->display_user->id); $bio = $duser_config->get_string("biography", ""); @@ -21,7 +21,7 @@ class Biography extends Extension public function onPageRequest(PageRequestEvent $event) { - global $cache, $database, $page, $user, $user_config; + global $page, $user, $user_config; if ($event->page_matches("biography")) { if ($user->check_auth_token()) { $user_config->set_string("biography", $_POST['biography']); diff --git a/ext/biography/test.php b/ext/biography/test.php index e07a4851..aef7eedf 100644 --- a/ext/biography/test.php +++ b/ext/biography/test.php @@ -3,7 +3,6 @@ class BiographyTest extends ShimmiePHPUnitTestCase { public function testBio() { - global $database; $this->log_in_as_user(); $this->post_page("biography", ["biography"=>"My bio goes here"]); $this->get_page("user/" . self::$user_name); diff --git a/ext/blocks/info.php b/ext/blocks/info.php index d5c34b9c..24af7eaf 100644 --- a/ext/blocks/info.php +++ b/ext/blocks/info.php @@ -4,10 +4,10 @@ class BlocksInfo extends ExtensionInfo { public const KEY = "blocks"; - public $key = self::KEY; - public $name = "Generic Blocks"; - public $url = self::SHIMMIE_URL; - public $authors = self::SHISH_AUTHOR; - public $license = self::LICENSE_GPLV2; - public $description = "Add HTML to some space (News, Ads, etc)"; + public string $key = self::KEY; + public string $name = "Generic Blocks"; + public string $url = self::SHIMMIE_URL; + public array $authors = self::SHISH_AUTHOR; + public string $license = self::LICENSE_GPLV2; + public string $description = "Add HTML to some space (News, Ads, etc)"; } diff --git a/ext/blocks/main.php b/ext/blocks/main.php index c07ea893..9922a635 100644 --- a/ext/blocks/main.php +++ b/ext/blocks/main.php @@ -3,7 +3,7 @@ class Blocks extends Extension { /** @var BlocksTheme */ - protected $theme; + protected ?Themelet $theme; public function onDatabaseUpgrade(DatabaseUpgradeEvent $event) { diff --git a/ext/blotter/info.php b/ext/blotter/info.php index 6adfd345..36c4f28d 100644 --- a/ext/blotter/info.php +++ b/ext/blotter/info.php @@ -4,12 +4,12 @@ class BlotterInfo extends ExtensionInfo { public const KEY = "blotter"; - public $key = self::KEY; - public $name = "Blotter"; - public $url = "http://seemslegit.com/"; - public $authors = ["Zach Hall"=>"zach@sosguy.net"]; - public $license = self::LICENSE_GPLV2; - public $description = "Displays brief updates about whatever you want on every page. + public string $key = self::KEY; + public string $name = "Blotter"; + public string $url = "http://seemslegit.com/"; + public array $authors = ["Zach Hall"=>"zach@sosguy.net"]; + public string $license = self::LICENSE_GPLV2; + public string $description = "Displays brief updates about whatever you want on every page. Colors and positioning can be configured to match your site's design. Development TODO at https://github.com/zshall/shimmie2/issues"; diff --git a/ext/blotter/main.php b/ext/blotter/main.php index 32c322ac..e03cfe1c 100644 --- a/ext/blotter/main.php +++ b/ext/blotter/main.php @@ -3,7 +3,7 @@ class Blotter extends Extension { /** @var BlotterTheme */ - protected $theme; + protected ?Themelet $theme; public function onInitExt(InitExtEvent $event) { diff --git a/ext/blotter/theme.php b/ext/blotter/theme.php index c1d38d37..88d7c375 100644 --- a/ext/blotter/theme.php +++ b/ext/blotter/theme.php @@ -20,7 +20,7 @@ class BlotterTheme extends Themelet $page->add_block(new Block("Blotter Entries", $html, "main", 10)); } - public function display_blotter($entries) + public function display_blotter(array $entries): void { global $page, $config; $html = $this->get_html_for_blotter($entries); @@ -28,7 +28,7 @@ class BlotterTheme extends Themelet $page->add_block(new Block(null, $html, $position, 20)); } - private function get_html_for_blotter_editor($entries) + private function get_html_for_blotter_editor(array $entries): string { global $user; @@ -99,7 +99,7 @@ class BlotterTheme extends Themelet return $html; } - private function get_html_for_blotter_page($entries) + private function get_html_for_blotter_page(array $entries): string { /** * This one displays a list of all blotter entries. @@ -130,7 +130,7 @@ class BlotterTheme extends Themelet return $html; } - private function get_html_for_blotter($entries) + private function get_html_for_blotter(array $entries): string { global $config; $i_color = $config->get_string("blotter_color", "#FF0000"); diff --git a/ext/browser_search/info.php b/ext/browser_search/info.php index 35154b48..f3c8780e 100644 --- a/ext/browser_search/info.php +++ b/ext/browser_search/info.php @@ -4,14 +4,14 @@ class BrowserSearchInfo extends ExtensionInfo { public const KEY = "browser_search"; - public $key = self::KEY; - public $name = "Browser Search"; - public $url = "http://atravelinggeek.com/"; - public $authors = ["ATravelingGeek"=>"atg@atravelinggeek.com"]; - public $license = self::LICENSE_GPLV2; - public $version = "0.1c, October 26, 2007"; - public $description = "Allows the user to add a browser 'plugin' to search the site with real-time suggestions"; - public $documentation = + public string $key = self::KEY; + public string $name = "Browser Search"; + public string $url = "http://atravelinggeek.com/"; + public array $authors = ["ATravelingGeek"=>"atg@atravelinggeek.com"]; + public string $license = self::LICENSE_GPLV2; + public ?string $version = "0.1c, October 26, 2007"; + public string $description = "Allows the user to add a browser 'plugin' to search the site with real-time suggestions"; + public ?string $documentation = "Once installed, users with an opensearch compatible browser should see their search box light up with whatever \"click here to add a search engine\" notification they have Some code (and lots of help) by Artanis (Erik Youngren ) from the 'tagger' extension - Used with permission"; diff --git a/ext/bulk_actions/info.php b/ext/bulk_actions/info.php index bb49ea82..011b83c6 100644 --- a/ext/bulk_actions/info.php +++ b/ext/bulk_actions/info.php @@ -4,10 +4,10 @@ class BulkActionsInfo extends ExtensionInfo { public const KEY = "bulk_actions"; - public $key = self::KEY; - public $name = "Bulk Actions"; - public $authors = ["Matthew Barbour"=>"matthew@darkholme.net"]; - public $license = self::LICENSE_WTFPL; - public $description = "Provides query and selection-based bulk action support"; - public $documentation = "Provides bulk action section in list view. Allows performing actions against a set of posts based on query or manual selection. Based on Mass Tagger by Christian Walde , contributions by Shish and Agasa."; + public string $key = self::KEY; + public string $name = "Bulk Actions"; + public array $authors = ["Matthew Barbour"=>"matthew@darkholme.net"]; + public string $license = self::LICENSE_WTFPL; + public string $description = "Provides query and selection-based bulk action support"; + public ?string $documentation = "Provides bulk action section in list view. Allows performing actions against a set of posts based on query or manual selection. Based on Mass Tagger by Christian Walde , contributions by Shish and Agasa."; } diff --git a/ext/bulk_actions/main.php b/ext/bulk_actions/main.php index 343536ba..eac4dfab 100644 --- a/ext/bulk_actions/main.php +++ b/ext/bulk_actions/main.php @@ -5,10 +5,8 @@ class BulkActionException extends SCoreException } class BulkActionBlockBuildingEvent extends Event { - /** @var array */ - public $actions = []; - - public $search_terms = []; + public array $actions = []; + public array $search_terms = []; public function add_action(String $action, string $button_text, string $access_key = null, String $confirmation_message = "", String $block = "", int $position = 40) { @@ -38,12 +36,9 @@ class BulkActionBlockBuildingEvent extends Event class BulkActionEvent extends Event { - /** @var string */ - public $action; - /** @var array */ - public $items; - /** @var bool */ - public $redirect = true; + public string $action; + public Generator $items; + public bool $redirect = true; public function __construct(String $action, Generator $items) { @@ -56,7 +51,7 @@ class BulkActionEvent extends Event class BulkActions extends Extension { /** @var BulkActionsTheme */ - protected $theme; + protected ?Themelet $theme; public function onPostListBuilding(PostListBuildingEvent $event) { diff --git a/ext/bulk_actions/script.js b/ext/bulk_actions/script.js index b8a816da..4fccb5f8 100644 --- a/ext/bulk_actions/script.js +++ b/ext/bulk_actions/script.js @@ -8,13 +8,13 @@ function validate_selections(form, confirmationMessage) { var queryOnly = false; if(bulk_selector_active) { var data = get_selected_items(); - if(data.length==0) { + if(data.length===0) { return false; } } else { var query = $(form).find('input[name="bulk_query"]').val(); - if (query == null || query == "") { + if (query == null || query === "") { return false; } else { queryOnly = true; @@ -22,7 +22,7 @@ function validate_selections(form, confirmationMessage) { } - if(confirmationMessage!=null&&confirmationMessage!="") { + if(confirmationMessage!=null&&confirmationMessage!=="") { return confirm(confirmationMessage); } else if(queryOnly) { var action = $(form).find('input[name="submit_button"]').val(); @@ -59,7 +59,7 @@ function deactivate_bulk_selector() { function get_selected_items() { var data = $('#bulk_selected_ids').val(); - if(data==""||data==null) { + if(data===""||data==null) { data = []; } else { data = JSON.parse(data); @@ -97,11 +97,11 @@ function toggle_selection( id ) { var data = get_selected_items(); if(data.includes(id)) { data.splice(data.indexOf(id),1); - set_selected_items(data); + set_selected_items(data); return false; } else { data.push(id); - set_selected_items(data); + set_selected_items(data); return true; } } @@ -116,7 +116,7 @@ function select_all() { items.push(id); } ); - set_selected_items(items); + set_selected_items(items); } function select_invert() { @@ -131,11 +131,11 @@ function select_invert() { } } ); - set_selected_items(items); + set_selected_items(items); } function select_none() { - set_selected_items([]); + set_selected_items([]); } function select_range(start, end) { @@ -145,7 +145,7 @@ function select_range(start, end) { function ( index, block ) { block = $(block); var id = block.data("post-id"); - if(id==start) + if(id===start) selecting = true; if(selecting) { @@ -153,7 +153,7 @@ function select_range(start, end) { data.push(id); } - if(id==end) { + if(id===end) { selecting = false; } } @@ -163,14 +163,14 @@ function select_range(start, end) { var last_clicked_item; -function add_selector_button($block) { +function add_selector_button($block) { var c = function(e) { if(!bulk_selector_active) return true; e.preventDefault(); e.stopPropagation(); - + var id = $block.data("post-id"); if(e.shiftKey) { if(last_clicked_itemadd_block($block); } - public function render_ban_reason_input() + public function render_ban_reason_input(): string { if (class_exists("ImageBan")) { return ""; @@ -54,13 +54,13 @@ class BulkActionsTheme extends Themelet } } - public function render_tag_input() + public function render_tag_input(): string { return "" . ""; } - public function render_source_input() + public function render_source_input(): string { return ""; } diff --git a/ext/bulk_add/info.php b/ext/bulk_add/info.php index 568b333b..3cf83aaa 100644 --- a/ext/bulk_add/info.php +++ b/ext/bulk_add/info.php @@ -4,13 +4,13 @@ class BulkAddInfo extends ExtensionInfo { public const KEY = "bulk_add"; - public $key = self::KEY; - public $name = "Bulk Add"; - public $url = self::SHIMMIE_URL; - public $authors = self::SHISH_AUTHOR; - public $license = self::LICENSE_GPLV2; - public $description = "Bulk add server-side images"; - public $documentation = + public string $key = self::KEY; + public string $name = "Bulk Add"; + public string $url = self::SHIMMIE_URL; + public array $authors = self::SHISH_AUTHOR; + public string $license = self::LICENSE_GPLV2; + public string $description = "Bulk add server-side images"; + public ?string $documentation = "Upload the images into a new directory via ftp or similar, go to shimmie's admin page and put that directory in the bulk add box. If there are subdirectories, they get used as tags (eg if you diff --git a/ext/bulk_add/main.php b/ext/bulk_add/main.php index 022589b6..aaad0b84 100644 --- a/ext/bulk_add/main.php +++ b/ext/bulk_add/main.php @@ -2,8 +2,8 @@ class BulkAddEvent extends Event { - public $dir; - public $results; + public string $dir; + public array $results; public function __construct(string $dir) { @@ -16,7 +16,7 @@ class BulkAddEvent extends Event class BulkAdd extends Extension { /** @var BulkAddTheme */ - protected $theme; + protected ?Themelet $theme; public function onPageRequest(PageRequestEvent $event) { diff --git a/ext/bulk_add/theme.php b/ext/bulk_add/theme.php index bfdcf5c4..532c9cbc 100644 --- a/ext/bulk_add/theme.php +++ b/ext/bulk_add/theme.php @@ -2,7 +2,7 @@ class BulkAddTheme extends Themelet { - private $messages = []; + private array $messages = []; /* * Show a standard page for results to be put into diff --git a/ext/bulk_add_csv/info.php b/ext/bulk_add_csv/info.php index 71230903..680af301 100644 --- a/ext/bulk_add_csv/info.php +++ b/ext/bulk_add_csv/info.php @@ -4,13 +4,13 @@ class BulkAddCSVInfo extends ExtensionInfo { public const KEY = "bulk_add_csv"; - public $key = self::KEY; - public $name = "Bulk Add CSV"; - public $url = self::SHIMMIE_URL; - public $authors = ["velocity37"=>"velocity37@gmail.com"]; - public $license = self::LICENSE_GPLV2; - public $description = "Bulk add server-side posts with metadata from CSV file"; - public $documentation = + public string $key = self::KEY; + public string $name = "Bulk Add CSV"; + public string $url = self::SHIMMIE_URL; + public array $authors = ["velocity37"=>"velocity37@gmail.com"]; + public string $license = self::LICENSE_GPLV2; + public string $description = "Bulk add server-side posts with metadata from CSV file"; + public ?string $documentation = "Modification of \"Bulk Add\" by Shish.

    Adds posts from a CSV with the five following values:
    \"/path/to/image.jpg\",\"spaced tags\",\"source\",\"rating s/q/e\",\"/path/thumbnail.jpg\"
    diff --git a/ext/bulk_add_csv/main.php b/ext/bulk_add_csv/main.php index 5816dded..e6b570a8 100644 --- a/ext/bulk_add_csv/main.php +++ b/ext/bulk_add_csv/main.php @@ -3,7 +3,7 @@ class BulkAddCSV extends Extension { /** @var BulkAddCSVTheme */ - protected $theme; + protected ?Themelet $theme; public function onPageRequest(PageRequestEvent $event) { diff --git a/ext/bulk_add_csv/theme.php b/ext/bulk_add_csv/theme.php index f001bfea..00804f5a 100644 --- a/ext/bulk_add_csv/theme.php +++ b/ext/bulk_add_csv/theme.php @@ -2,7 +2,7 @@ class BulkAddCSVTheme extends Themelet { - private $messages = []; + private array $messages = []; /* * Show a standard page for results to be put into diff --git a/ext/bulk_download/info.php b/ext/bulk_download/info.php index bb031282..7c210ae1 100644 --- a/ext/bulk_download/info.php +++ b/ext/bulk_download/info.php @@ -5,10 +5,10 @@ class BulkDownloadInfo extends ExtensionInfo { public const KEY = "bulk_download"; - public $key = self::KEY; - public $name = "Bulk Download"; - public $authors = ["Matthew Barbour"=>"matthew@darkholme.net"]; - public $license = self::LICENSE_WTFPL; - public $description = "Allows bulk downloading images."; - public $dependencies = [BulkActionsInfo::KEY]; + public string $key = self::KEY; + public string $name = "Bulk Download"; + public array $authors = ["Matthew Barbour"=>"matthew@darkholme.net"]; + public string $license = self::LICENSE_WTFPL; + public string $description = "Allows bulk downloading images."; + public array $dependencies = [BulkActionsInfo::KEY]; } diff --git a/ext/bulk_import_export/events.php b/ext/bulk_import_export/events.php index e75f8e64..3e453a86 100644 --- a/ext/bulk_import_export/events.php +++ b/ext/bulk_import_export/events.php @@ -2,8 +2,8 @@ class BulkExportEvent extends Event { - public $image; - public $fields = []; + public Image $image; + public array $fields = []; public function __construct(Image $image) { @@ -15,8 +15,8 @@ class BulkExportEvent extends Event class BulkImportEvent extends Event { - public $image; - public $fields = []; + public Image $image; + public array $fields = []; public function __construct(Image $image, $fields) { diff --git a/ext/bulk_import_export/info.php b/ext/bulk_import_export/info.php index 8e77e7c0..ead144cb 100644 --- a/ext/bulk_import_export/info.php +++ b/ext/bulk_import_export/info.php @@ -6,10 +6,10 @@ class BulkImportExportInfo extends ExtensionInfo { public const KEY = "bulk_import_export"; - public $key = self::KEY; - public $name = "Bulk Import/Export"; - public $authors = ["Matthew Barbour"=>"matthew@darkholme.net"]; - public $license = self::LICENSE_WTFPL; - public $description = "Allows bulk exporting/importing of images and associated data."; - public $dependencies = [BulkActionsInfo::KEY]; + public string $key = self::KEY; + public string $name = "Bulk Import/Export"; + public array $authors = ["Matthew Barbour"=>"matthew@darkholme.net"]; + public string $license = self::LICENSE_WTFPL; + public string $description = "Allows bulk exporting/importing of images and associated data."; + public array $dependencies = [BulkActionsInfo::KEY]; } diff --git a/ext/bulk_import_export/main.php b/ext/bulk_import_export/main.php index 6a4ac039..5f06e47f 100644 --- a/ext/bulk_import_export/main.php +++ b/ext/bulk_import_export/main.php @@ -5,7 +5,7 @@ class BulkImportExport extends DataHandlerExtension { const EXPORT_ACTION_NAME = "bulk_export"; const EXPORT_INFO_FILE_NAME = "export.json"; - protected $SUPPORTED_MIME = [MimeType::ZIP]; + protected array $SUPPORTED_MIME = [MimeType::ZIP]; public function onDataUpload(DataUploadEvent $event) @@ -159,7 +159,7 @@ class BulkImportExport extends DataHandlerExtension return false; } - protected function create_thumb(string $hash, string $type): bool + protected function create_thumb(string $hash, string $mime): bool { return false; } diff --git a/ext/comment/info.php b/ext/comment/info.php index 1a8ced0f..4727b52a 100644 --- a/ext/comment/info.php +++ b/ext/comment/info.php @@ -4,12 +4,12 @@ class CommentListInfo extends ExtensionInfo { public const KEY = "comment"; - public $key = self::KEY; - public $name = "Post Comments"; - public $url = self::SHIMMIE_URL; - public $authors = self::SHISH_AUTHOR; - public $license = self::LICENSE_GPLV2; - public $description = "Allow users to make comments on images"; - public $documentation = "Formatting is done with the standard formatting API (normally BBCode)"; - public $core = true; + public string $key = self::KEY; + public string $name = "Post Comments"; + public string $url = self::SHIMMIE_URL; + public array $authors = self::SHISH_AUTHOR; + public string $license = self::LICENSE_GPLV2; + public string $description = "Allow users to make comments on images"; + public ?string $documentation = "Formatting is done with the standard formatting API (normally BBCode)"; + public bool $core = true; } diff --git a/ext/comment/main.php b/ext/comment/main.php index ca471aa0..da1c65f1 100644 --- a/ext/comment/main.php +++ b/ext/comment/main.php @@ -4,12 +4,9 @@ require_once "vendor/ifixit/php-akismet/akismet.class.php"; class CommentPostingEvent extends Event { - /** @var int */ - public $image_id; - /** @var User */ - public $user; - /** @var string */ - public $comment; + public int $image_id; + public User $user; + public string $comment; public function __construct(int $image_id, User $user, string $comment) { @@ -27,8 +24,7 @@ class CommentPostingEvent extends Event */ class CommentDeletionEvent extends Event { - /** @var int */ - public $comment_id; + public int $comment_id; public function __construct(int $comment_id) { @@ -43,46 +39,27 @@ class CommentPostingException extends SCoreException class Comment { - /** @var User */ - public $owner; - - /** @var int */ - public $owner_id; - - /** @var string */ - public $owner_name; - - /** @var string */ - public $owner_email; - - /** @var string */ - public $owner_class; - - /** @var string */ - public $comment; - - /** @var int */ - public $comment_id; - - /** @var int */ - public $image_id; - - /** @var string */ - public $poster_ip; - - /** @var string */ - public $posted; + public ?User $owner; + public int $owner_id; + public string $owner_name; + public ?string $owner_email; + public string $owner_class; + public string $comment; + public int $comment_id; + public int $image_id; + public string $poster_ip; + public string $posted; public function __construct($row) { $this->owner = null; - $this->owner_id = $row['user_id']; + $this->owner_id = (int)$row['user_id']; $this->owner_name = $row['user_name']; $this->owner_email = $row['user_email']; // deprecated $this->owner_class = $row['user_class']; $this->comment = $row['comment']; - $this->comment_id = $row['comment_id']; - $this->image_id = $row['image_id']; + $this->comment_id = (int)$row['comment_id']; + $this->image_id = (int)$row['image_id']; $this->poster_ip = $row['poster_ip']; $this->posted = $row['posted']; } @@ -109,7 +86,7 @@ class Comment class CommentList extends Extension { /** @var CommentListTheme $theme */ - public $theme; + public ?Themelet $theme; public function onInitExt(InitExtEvent $event) { diff --git a/ext/comment/theme.php b/ext/comment/theme.php index f9ef115d..0516b09a 100644 --- a/ext/comment/theme.php +++ b/ext/comment/theme.php @@ -1,9 +1,9 @@ add_block(new Block("Mass Comment Delete", $html)); } - /** * Add some comments to the page, probably in a sidebar. * @@ -122,7 +120,6 @@ class CommentListTheme extends Themelet $page->add_block(new Block("Comments", $html, "left", 50, "comment-list-recent")); } - /** * Show comments for an image. * @@ -142,7 +139,6 @@ class CommentListTheme extends Themelet $page->add_block(new Block("Comments", $html, "main", 30, "comment-list-image")); } - /** * Show comments made by a user. * @@ -287,7 +283,7 @@ class CommentListTheme extends Themelet '; } - public function get_help_html() + public function get_help_html(): string { return '

    Search for posts containing a certain number of comments, or comments by a particular individual.

    diff --git a/ext/cron_uploader/info.php b/ext/cron_uploader/info.php index 7b920aa3..db899d96 100644 --- a/ext/cron_uploader/info.php +++ b/ext/cron_uploader/info.php @@ -13,12 +13,12 @@ class CronUploaderInfo extends ExtensionInfo { public const KEY = "cron_uploader"; - public $key = self::KEY; - public $name = "Cron Uploader"; - public $url = self::SHIMMIE_URL; - public $authors = ["YaoiFox"=>"admin@yaoifox.com", "Matthew Barbour"=>"matthew@darkholme.net"]; - public $license = self::LICENSE_GPLV2; - public $description = "Uploads images automatically using Cron Jobs"; + public string $key = self::KEY; + public string $name = "Cron Uploader"; + public string $url = self::SHIMMIE_URL; + public array $authors = ["YaoiFox"=>"admin@yaoifox.com", "Matthew Barbour"=>"matthew@darkholme.net"]; + public string $license = self::LICENSE_GPLV2; + public string $description = "Uploads images automatically using Cron Jobs"; public function __construct() { diff --git a/ext/cron_uploader/main.php b/ext/cron_uploader/main.php index cfbaad90..43c70548 100644 --- a/ext/cron_uploader/main.php +++ b/ext/cron_uploader/main.php @@ -5,7 +5,7 @@ require_once "config.php"; class CronUploader extends Extension { /** @var CronUploaderTheme */ - protected $theme; + protected ?Themelet $theme; public const NAME = "cron_uploader"; @@ -15,7 +15,7 @@ class CronUploader extends Extension const UPLOADED_DIR = "uploaded"; const FAILED_DIR = "failed_to_upload"; - private static $IMPORT_RUNNING = false; + private static bool $IMPORT_RUNNING = false; public function onInitUserConfig(InitUserConfigEvent $event) { @@ -201,7 +201,7 @@ class CronUploader extends Extension } - private function get_cron_url() + private function get_cron_url(): string { global $user_config; @@ -210,12 +210,12 @@ class CronUploader extends Extension return make_http(make_link("/cron_upload/run", "api_key=".urlencode($user_api_key))); } - private function get_cron_cmd() + private function get_cron_cmd(): string { return "curl --silent " . $this->get_cron_url(); } - private function display_documentation() + private function display_documentation(): void { global $database; @@ -261,7 +261,7 @@ class CronUploader extends Extension ); } - public function get_queue_dir() + public function get_queue_dir(): string { global $user_config; @@ -269,7 +269,7 @@ class CronUploader extends Extension return join_path($dir, self::QUEUE_DIR); } - public function get_uploaded_dir() + public function get_uploaded_dir(): string { global $user_config; @@ -277,7 +277,7 @@ class CronUploader extends Extension return join_path($dir, self::UPLOADED_DIR); } - public function get_failed_dir() + public function get_failed_dir(): string { global $user_config; @@ -499,7 +499,7 @@ class CronUploader extends Extension private const SKIPPABLE_FILES = ['.ds_store','thumbs.db']; private const SKIPPABLE_DIRECTORIES = ['__macosx']; - private function is_skippable_dir(string $path) + private function is_skippable_dir(string $path): bool { $info = pathinfo($path); @@ -510,7 +510,7 @@ class CronUploader extends Extension return false; } - private function is_skippable_file(string $path) + private function is_skippable_file(string $path): bool { $info = pathinfo($path); diff --git a/ext/cron_uploader/theme.php b/ext/cron_uploader/theme.php index 07d3edde..4e0e43b3 100644 --- a/ext/cron_uploader/theme.php +++ b/ext/cron_uploader/theme.php @@ -10,8 +10,6 @@ use function MicroHTML\TD; use function MicroHTML\INPUT; use function MicroHTML\rawHTML; use function MicroHTML\emptyHTML; -use function MicroHTML\SELECT; -use function MicroHTML\OPTION; class CronUploaderTheme extends Themelet { @@ -33,7 +31,6 @@ class CronUploaderTheme extends Themelet if (!$config->get_bool(UserConfig::ENABLE_API_KEYS)) { $info_html .= "THIS EXTENSION REQUIRES USER API KEYS TO BE ENABLED IN BOARD ADMIN"; - } else { } $info_html .= "Information diff --git a/ext/custom_html_headers/info.php b/ext/custom_html_headers/info.php index 08f14a36..075ad1ba 100644 --- a/ext/custom_html_headers/info.php +++ b/ext/custom_html_headers/info.php @@ -4,13 +4,13 @@ class CustomHtmlHeadersInfo extends ExtensionInfo { public const KEY = "custom_html_headers"; - public $key = self::KEY; - public $name = "Custom HTML Headers"; - public $url = "http://www.drudexsoftware.com"; - public $authors = ["Drudex Software"=>"support@drudexsoftware.com"]; - public $license = self::LICENSE_GPLV2; - public $description = "Allows admins to modify & set custom <head> content"; - public $documentation = + public string $key = self::KEY; + public string $name = "Custom HTML Headers"; + public string $url = "http://www.drudexsoftware.com"; + public array $authors = ["Drudex Software"=>"support@drudexsoftware.com"]; + public string $license = self::LICENSE_GPLV2; + public string $description = "Allows admins to modify & set custom <head> content"; + public ?string $documentation = "When you go to board config you can find a block named Custom HTML Headers. In that block you can simply place any thing you can place within <head></head> diff --git a/ext/danbooru_api/info.php b/ext/danbooru_api/info.php index 0e958d72..5d03f5f7 100644 --- a/ext/danbooru_api/info.php +++ b/ext/danbooru_api/info.php @@ -4,11 +4,11 @@ class DanbooruApiInfo extends ExtensionInfo { public const KEY = "danbooru_api"; - public $key = self::KEY; - public $name = "Danbooru Client API"; - public $authors = ["JJS"=>"jsutinen@gmail.com"]; - public $description = "Allow Danbooru apps like Danbooru Uploader for Firefox to communicate with Shimmie"; - public $documentation = + public string $key = self::KEY; + public string $name = "Danbooru Client API"; + public array $authors = ["JJS"=>"jsutinen@gmail.com"]; + public string $description = "Allow Danbooru apps like Danbooru Uploader for Firefox to communicate with Shimmie"; + public ?string $documentation = "

    Notes:
    danbooru API based on documentation from danbooru 1.0 - http://attachr.com/7569 diff --git a/ext/danbooru_api/main.php b/ext/danbooru_api/main.php index 3243aa16..9ec6e8d8 100644 --- a/ext/danbooru_api/main.php +++ b/ext/danbooru_api/main.php @@ -2,19 +2,19 @@ use \MicroHTML\HTMLElement; -function TAGS(...$args) +function TAGS(...$args): HTMLElement { return new HTMLElement("tags", $args); } -function TAG(...$args) +function TAG(...$args): HTMLElement { return new HTMLElement("tag", $args); } -function POSTS(...$args) +function POSTS(...$args): HTMLElement { return new HTMLElement("posts", $args); } -function POST(...$args) +function POST(...$args): HTMLElement { return new HTMLElement("post", $args); } @@ -114,11 +114,14 @@ class DanbooruApi extends Extension } } // Currently disabled to maintain identical functionality to danbooru 1.0's own "broken" find_tags - elseif (false && isset($_GET['tags'])) { + /* + elseif (isset($_GET['tags'])) { $start = isset($_GET['after_id']) ? int_escape($_GET['offset']) : 0; $tags = Tag::explode($_GET['tags']); assert(!is_null($start) && !is_null($tags)); - } else { + } + */ + else { $start = isset($_GET['after_id']) ? int_escape($_GET['offset']) : 0; $sqlresult = $database->get_all( "SELECT id,tag,count FROM tags WHERE count > 0 AND id >= :id ORDER BY id DESC", diff --git a/ext/download/events.php b/ext/download/events.php index 5a27bfc8..477bb50a 100644 --- a/ext/download/events.php +++ b/ext/download/events.php @@ -2,12 +2,12 @@ class ImageDownloadingEvent extends Event { - public $image; - public $mime; - public $path; - public $file_modified = false; + public Image $image; + public string $mime; + public string $path; + public bool $file_modified = false; - public function __construct(Image $image, String $path, string $mime) + public function __construct(Image $image, string $path, string $mime) { parent::__construct(); $this->image = $image; diff --git a/ext/download/info.php b/ext/download/info.php index e1f5228a..a789f511 100644 --- a/ext/download/info.php +++ b/ext/download/info.php @@ -4,11 +4,11 @@ class DownloadInfo extends ExtensionInfo { public const KEY = "download"; - public $key = self::KEY; - public $name = "Download"; - public $authors = ["Matthew Barbour"=>"matthew@darkholme.net"]; - public $license = self::LICENSE_WTFPL; - public $description = "System-wide download functions"; - public $core = true; - public $visibility = self::VISIBLE_HIDDEN; + public string $key = self::KEY; + public string $name = "Download"; + public array $authors = ["Matthew Barbour"=>"matthew@darkholme.net"]; + public string $license = self::LICENSE_WTFPL; + public string $description = "System-wide download functions"; + public bool $core = true; + public string $visibility = self::VISIBLE_HIDDEN; } diff --git a/ext/downtime/info.php b/ext/downtime/info.php index a47dc7f0..726ef963 100644 --- a/ext/downtime/info.php +++ b/ext/downtime/info.php @@ -4,13 +4,13 @@ class DowntimeInfo extends ExtensionInfo { public const KEY = "downtime"; - public $key = self::KEY; - public $name = "Downtime"; - public $url = self::SHIMMIE_URL; - public $authors = self::SHISH_AUTHOR; - public $license = self::LICENSE_GPLV2; - public $description = "Show a \"down for maintenance\" page"; - public $documentation = + public string $key = self::KEY; + public string $name = "Downtime"; + public string $url = self::SHIMMIE_URL; + public array $authors = self::SHISH_AUTHOR; + public string $license = self::LICENSE_GPLV2; + public string $description = "Show a \"down for maintenance\" page"; + public ?string $documentation = "Once installed there will be some more options on the config page -- Ticking \"disable non-admin access\" will mean that regular and anonymous users will be blocked from accessing the site, only able to view the diff --git a/ext/downtime/main.php b/ext/downtime/main.php index 6bc823aa..531fe1f5 100644 --- a/ext/downtime/main.php +++ b/ext/downtime/main.php @@ -3,7 +3,7 @@ class Downtime extends Extension { /** @var DowntimeTheme */ - protected $theme; + protected ?Themelet $theme; public function get_priority(): int { @@ -35,7 +35,7 @@ class Downtime extends Extension } } - private function is_safe_page(PageRequestEvent $event) + private function is_safe_page(PageRequestEvent $event): bool { if ($event->page_matches("user_admin/login")) { return true; diff --git a/ext/emoticons/info.php b/ext/emoticons/info.php index eadcbf67..f841e1a0 100644 --- a/ext/emoticons/info.php +++ b/ext/emoticons/info.php @@ -4,14 +4,14 @@ class EmoticonsInfo extends ExtensionInfo { public const KEY = "emoticons"; - public $key = self::KEY; - public $name = "Emoticon Filter"; - public $url = self::SHIMMIE_URL; - public $authors = self::SHISH_AUTHOR; - public $license = self::LICENSE_GPLV2; - public $dependencies = [EmoticonListInfo::KEY]; - public $description = "Lets users use graphical smilies"; - public $documentation = + public string $key = self::KEY; + public string $name = "Emoticon Filter"; + public string $url = self::SHIMMIE_URL; + public array $authors = self::SHISH_AUTHOR; + public string $license = self::LICENSE_GPLV2; + public array $dependencies = [EmoticonListInfo::KEY]; + public string $description = "Lets users use graphical smilies"; + public ?string $documentation = "This extension will turn colon-something-colon into a link to an image with that something as the name, eg :smile: becomes a link to smile.gif diff --git a/ext/emoticons_list/info.php b/ext/emoticons_list/info.php index 2bf25bc3..954300a5 100644 --- a/ext/emoticons_list/info.php +++ b/ext/emoticons_list/info.php @@ -4,12 +4,12 @@ class EmoticonListInfo extends ExtensionInfo { public const KEY = "emoticons_list"; - public $key = self::KEY; - public $name = "Emoticon List"; - public $url = self::SHIMMIE_URL; - public $authors = self::SHISH_AUTHOR; - public $license = self::LICENSE_GPLV2; - public $description = "Lists available graphical smilies"; + public string $key = self::KEY; + public string $name = "Emoticon List"; + public string $url = self::SHIMMIE_URL; + public array $authors = self::SHISH_AUTHOR; + public string $license = self::LICENSE_GPLV2; + public string $description = "Lists available graphical smilies"; - public $visibility = self::VISIBLE_HIDDEN; + public string $visibility = self::VISIBLE_HIDDEN; } diff --git a/ext/emoticons_list/main.php b/ext/emoticons_list/main.php index 14120548..e5c15b23 100644 --- a/ext/emoticons_list/main.php +++ b/ext/emoticons_list/main.php @@ -6,7 +6,7 @@ class EmoticonList extends Extension { /** @var EmoticonListTheme */ - protected $theme; + protected ?Themelet $theme; public function onPageRequest(PageRequestEvent $event) { diff --git a/ext/eokm/info.php b/ext/eokm/info.php index 23a5fb4c..3f29726d 100644 --- a/ext/eokm/info.php +++ b/ext/eokm/info.php @@ -4,10 +4,10 @@ class EokmInfo extends ExtensionInfo { public const KEY = "eokm"; - public $key = self::KEY; - public $name = "EOKM Filter"; - public $url = self::SHIMMIE_URL; - public $authors = self::SHISH_AUTHOR; - public $license = self::LICENSE_GPLV2; - public $description = "Check uploads against the EOKM blocklist"; + public string $key = self::KEY; + public string $name = "EOKM Filter"; + public string $url = self::SHIMMIE_URL; + public array $authors = self::SHISH_AUTHOR; + public string $license = self::LICENSE_GPLV2; + public string $description = "Check uploads against the EOKM blocklist"; } diff --git a/ext/eokm/main.php b/ext/eokm/main.php index 45b0f32f..ba302b0c 100644 --- a/ext/eokm/main.php +++ b/ext/eokm/main.php @@ -25,6 +25,7 @@ class Eokm extends Extension $return = curl_exec($ch); curl_close($ch); + /** @noinspection PhpStatementHasEmptyBodyInspection */ if ($return == "false") { // all ok } elseif ($return == "true") { diff --git a/ext/et/info.php b/ext/et/info.php index c51bec46..a3bd372d 100644 --- a/ext/et/info.php +++ b/ext/et/info.php @@ -4,14 +4,14 @@ class ETInfo extends ExtensionInfo { public const KEY = "et"; - public $key = self::KEY; - public $name = "System Info"; - public $url = self::SHIMMIE_URL; - public $authors = self::SHISH_AUTHOR; - public $license = self::LICENSE_GPLV2; - public $core = true; - public $description = "Show various bits of system information"; - public $documentation = + public string $key = self::KEY; + public string $name = "System Info"; + public string $url = self::SHIMMIE_URL; + public array $authors = self::SHISH_AUTHOR; + public string $license = self::LICENSE_GPLV2; + public bool $core = true; + public string $description = "Show various bits of system information"; + public ?string $documentation = "Knowing the information that this extension shows can be very useful for debugging. There's also an option to send your stats to my database, so I can get some idea of how shimmie is used, which servers I need to support, which versions of PHP I should test with, etc."; diff --git a/ext/et/main.php b/ext/et/main.php index a23a1360..b63b190f 100644 --- a/ext/et/main.php +++ b/ext/et/main.php @@ -3,7 +3,7 @@ class ET extends Extension { /** @var ETTheme */ - protected $theme; + protected ?Themelet $theme; public function onPageRequest(PageRequestEvent $event) { @@ -116,7 +116,7 @@ class ET extends Extension return $info; } - private function to_yaml($info) + private function to_yaml(array $info): string { $data = ""; foreach ($info as $title => $section) { diff --git a/ext/et/theme.php b/ext/et/theme.php index 4b41c579..39eaa174 100644 --- a/ext/et/theme.php +++ b/ext/et/theme.php @@ -22,7 +22,7 @@ class ETTheme extends Themelet $page->add_block(new Block("Information:", $this->build_data_form($yaml))); } - protected function build_data_form($yaml) + protected function build_data_form($yaml): string { return (string)FORM( ["action"=>"https://shimmie.shishnet.org/register.php", "method"=>"POST"], diff --git a/ext/et_server/info.php b/ext/et_server/info.php index c87f6514..2d578959 100644 --- a/ext/et_server/info.php +++ b/ext/et_server/info.php @@ -4,12 +4,12 @@ class ETServerInfo extends ExtensionInfo { public const KEY = "et_server"; - public $key = self::KEY; - public $name = "System Info Registry"; - public $url = self::SHIMMIE_URL; - public $authors = self::SHISH_AUTHOR; - public $license = self::LICENSE_GPLV2; - public $description = "Keep track of shimmie registrations"; - public $documentation = "For internal use"; - public $visibility = self::VISIBLE_HIDDEN; + public string $key = self::KEY; + public string $name = "System Info Registry"; + public string $url = self::SHIMMIE_URL; + public array $authors = self::SHISH_AUTHOR; + public string $license = self::LICENSE_GPLV2; + public string $description = "Keep track of shimmie registrations"; + public ?string $documentation = "For internal use"; + public string $visibility = self::VISIBLE_HIDDEN; } diff --git a/ext/ext_manager/info.php b/ext/ext_manager/info.php index 71b54b95..a2f00482 100644 --- a/ext/ext_manager/info.php +++ b/ext/ext_manager/info.php @@ -4,13 +4,13 @@ class ExtManagerInfo extends ExtensionInfo { public const KEY = "ext_manager"; - public $key = self::KEY; - public $name = "Extension Manager"; - public $url = self::SHIMMIE_URL; - public $authors = self::SHISH_AUTHOR; - public $license = self::LICENSE_GPLV2; - public $visibility = self::VISIBLE_ADMIN; - public $description = "A thing for point & click extension management"; - public $documentation = "Allows the admin to view a list of all extensions and enable or disable them; also allows users to view the list of activated extensions and read their documentation"; - public $core = true; + public string $key = self::KEY; + public string $name = "Extension Manager"; + public string $url = self::SHIMMIE_URL; + public array $authors = self::SHISH_AUTHOR; + public string $license = self::LICENSE_GPLV2; + public string $visibility = self::VISIBLE_ADMIN; + public string $description = "A thing for point & click extension management"; + public ?string $documentation = "Allows the admin to view a list of all extensions and enable or disable them; also allows users to view the list of activated extensions and read their documentation"; + public bool $core = true; } diff --git a/ext/ext_manager/main.php b/ext/ext_manager/main.php index 091e9621..b6be0cf2 100644 --- a/ext/ext_manager/main.php +++ b/ext/ext_manager/main.php @@ -21,8 +21,8 @@ function __extman_extactive(ExtensionInfo $a): bool class ExtensionAuthor { - public $name; - public $email; + public string $name; + public ?string $email; public function __construct(string $name, ?string $email) { @@ -34,7 +34,7 @@ class ExtensionAuthor class ExtManager extends Extension { /** @var ExtManagerTheme */ - protected $theme; + protected ?Themelet $theme; public function onPageRequest(PageRequestEvent $event) { diff --git a/ext/favorites/info.php b/ext/favorites/info.php index 5a6e2591..b743c62c 100644 --- a/ext/favorites/info.php +++ b/ext/favorites/info.php @@ -4,12 +4,12 @@ class FavoritesInfo extends ExtensionInfo { public const KEY = "favorites"; - public $key = self::KEY; - public $name = "Favorites"; - public $authors = ["Daniel Marschall"=>"info@daniel-marschall.de"]; - public $license = self::LICENSE_GPLV2; - public $description = "Allow users to favorite images"; - public $documentation = + public string $key = self::KEY; + public string $name = "Favorites"; + public array $authors = ["Daniel Marschall"=>"info@daniel-marschall.de"]; + public string $license = self::LICENSE_GPLV2; + public string $description = "Allow users to favorite images"; + public ?string $documentation = "Gives users a \"favorite this image\" button that they can press

    Favorites for a user can then be retrieved by searching for \"favorited_by=UserName\"

    Popular images can be searched for by eg. \"favorites>5\" diff --git a/ext/favorites/main.php b/ext/favorites/main.php index e1c66a1f..b35a88e3 100644 --- a/ext/favorites/main.php +++ b/ext/favorites/main.php @@ -2,12 +2,9 @@ class FavoriteSetEvent extends Event { - /** @var int */ - public $image_id; - /** @var User */ - public $user; - /** @var bool */ - public $do_set; + public int $image_id; + public User $user; + public bool $do_set; public function __construct(int $image_id, User $user, bool $do_set) { @@ -24,7 +21,7 @@ class FavoriteSetEvent extends Event class Favorites extends Extension { /** @var FavoritesTheme */ - protected $theme; + protected ?Themelet $theme; public function onImageAdminBlockBuilding(ImageAdminBlockBuildingEvent $event) { diff --git a/ext/favorites/theme.php b/ext/favorites/theme.php index b6e06e5a..2efc1bd7 100644 --- a/ext/favorites/theme.php +++ b/ext/favorites/theme.php @@ -1,9 +1,10 @@ add_block(new Block("Favorited By", $html, "left", 25)); } - public function get_help_html() + public function get_help_html(): string { return '

    Search for posts that have been favorited a certain number of times, or favorited by a particular individual.

    diff --git a/ext/featured/info.php b/ext/featured/info.php index cbe3dd94..384b9025 100644 --- a/ext/featured/info.php +++ b/ext/featured/info.php @@ -4,13 +4,13 @@ class FeaturedInfo extends ExtensionInfo { public const KEY = "featured"; - public $key = self::KEY; - public $name = "Featured Post"; - public $url = self::SHIMMIE_URL; - public $authors = self::SHISH_AUTHOR; - public $license = self::LICENSE_GPLV2; - public $description = "Bring a specific image to the users' attentions"; - public $documentation = + public string $key = self::KEY; + public string $name = "Featured Post"; + public string $url = self::SHIMMIE_URL; + public array $authors = self::SHISH_AUTHOR; + public string $license = self::LICENSE_GPLV2; + public string $description = "Bring a specific image to the users' attentions"; + public ?string $documentation = "Once enabled, a new \"feature this\" button will appear next to the other post control buttons (delete, rotate, etc). Clicking it will set the image as the site's current feature, diff --git a/ext/featured/main.php b/ext/featured/main.php index f0227766..88aecf86 100644 --- a/ext/featured/main.php +++ b/ext/featured/main.php @@ -3,7 +3,7 @@ class Featured extends Extension { /** @var FeaturedTheme */ - protected $theme; + protected ?Themelet $theme; public function onInitExt(InitExtEvent $event) { diff --git a/ext/forum/info.php b/ext/forum/info.php index 15caede4..1be749b6 100644 --- a/ext/forum/info.php +++ b/ext/forum/info.php @@ -4,9 +4,9 @@ class ForumInfo extends ExtensionInfo { public const KEY = "forum"; - public $key = self::KEY; - public $name = "Forum"; - public $authors = ["Sein Kraft"=>"mail@seinkraft.info","Alpha"=>"alpha@furries.com.ar"]; - public $license = self::LICENSE_GPLV2; - public $description = "Rough forum extension"; + public string $key = self::KEY; + public string $name = "Forum"; + public array $authors = ["Sein Kraft"=>"mail@seinkraft.info","Alpha"=>"alpha@furries.com.ar"]; + public string $license = self::LICENSE_GPLV2; + public string $description = "Rough forum extension"; } diff --git a/ext/forum/main.php b/ext/forum/main.php index f4d941a2..add705d4 100644 --- a/ext/forum/main.php +++ b/ext/forum/main.php @@ -10,7 +10,7 @@ Todo: class Forum extends Extension { /** @var ForumTheme */ - protected $theme; + protected ?Themelet $theme; public function onDatabaseUpgrade(DatabaseUpgradeEvent $event) { @@ -189,15 +189,15 @@ class Forum extends Extension } } - private function get_total_pages_for_thread(int $threadID) + private function get_total_pages_for_thread(int $threadID): int { global $database, $config; $result = $database->get_row("SELECT COUNT(1) AS count FROM forum_posts WHERE thread_id = :thread_id", ['thread_id'=>$threadID]); - return ceil($result["count"] / $config->get_int("forumPostsPerPage")); + return (int)ceil($result["count"] / $config->get_int("forumPostsPerPage")); } - private function sanity_check_new_thread() + private function sanity_check_new_thread(): array { $errors = null; if (!array_key_exists("title", $_POST)) { @@ -217,7 +217,7 @@ class Forum extends Extension return [$errors]; } - private function sanity_check_new_post() + private function sanity_check_new_post(): array { $errors = null; if (!array_key_exists("threadID", $_POST)) { @@ -235,7 +235,7 @@ class Forum extends Extension return [$errors]; } - private function sanity_check_viewed_thread(int $threadID) + private function sanity_check_viewed_thread(int $threadID): array { $errors = null; if (!$this->threadExists($threadID)) { @@ -244,14 +244,14 @@ class Forum extends Extension return [$errors]; } - private function get_thread_title(int $threadID) + private function get_thread_title(int $threadID): string { global $database; $result = $database->get_row("SELECT t.title FROM forum_threads AS t WHERE t.id = :id ", ['id'=>$threadID]); return $result["title"]; } - private function show_last_threads(Page $page, PageRequestEvent $event, $showAdminOptions = false) + private function show_last_threads(Page $page, PageRequestEvent $event, bool $showAdminOptions = false): void { global $config, $database; $threadsPerPage = $config->get_int('forumThreadsPerPage', 15); @@ -278,7 +278,7 @@ class Forum extends Extension $this->theme->display_thread_list($page, $threads, $showAdminOptions, $pageNumber + 1, $totalPages); } - private function show_posts(PageRequestEvent $event, $showAdminOptions = false) + private function show_posts(PageRequestEvent $event, bool $showAdminOptions = false): void { global $config, $database; $threadID = int_escape($event->get_arg(1)); @@ -305,7 +305,7 @@ class Forum extends Extension $this->theme->display_thread($posts, $showAdminOptions, $threadTitle, $threadID, $pageNumber + 1, $totalPages); } - private function save_new_thread(User $user) + private function save_new_thread(User $user): int { $title = html_escape($_POST["title"]); $sticky = !empty($_POST["sticky"]); @@ -327,7 +327,7 @@ class Forum extends Extension return $threadID; } - private function save_new_post(int $threadID, User $user) + private function save_new_post(int $threadID, User $user): void { global $config; $userID = $user->id; @@ -349,7 +349,7 @@ class Forum extends Extension $database->execute("UPDATE forum_threads SET uptodate=now() WHERE id=:id", ['id'=>$threadID]); } - private function retrieve_posts(int $threadID, int $pageNumber) + private function retrieve_posts(int $threadID, int $pageNumber): array { global $database, $config; $postsPerPage = $config->get_int('forumPostsPerPage', 15); @@ -366,20 +366,20 @@ class Forum extends Extension ); } - private function delete_thread(int $threadID) + private function delete_thread(int $threadID): void { global $database; $database->execute("DELETE FROM forum_threads WHERE id = :id", ['id'=>$threadID]); $database->execute("DELETE FROM forum_posts WHERE thread_id = :thread_id", ['thread_id'=>$threadID]); } - private function delete_post(int $postID) + private function delete_post(int $postID): void { global $database; $database->execute("DELETE FROM forum_posts WHERE id = :id", ['id'=>$postID]); } - private function threadExists(int $threadID) + private function threadExists(int $threadID): bool { global $database; $result=$database->get_one("SELECT EXISTS (SELECT * FROM forum_threads WHERE id=:id)", ['id'=>$threadID]); diff --git a/ext/forum/theme.php b/ext/forum/theme.php index 8508691f..c92b8aac 100644 --- a/ext/forum/theme.php +++ b/ext/forum/theme.php @@ -173,7 +173,7 @@ class ForumTheme extends Themelet - private function make_thread_list($threads, $showAdminOptions) + private function make_thread_list($threads, $showAdminOptions): string { $html = "". "". @@ -188,7 +188,6 @@ class ForumTheme extends Themelet $html .= ""; - $current_post = 0; foreach ($threads as $thread) { $oe = ($current_post++ % 2 == 0) ? "even" : "odd"; diff --git a/ext/four_oh_four/info.php b/ext/four_oh_four/info.php index fa95e8b9..46918483 100644 --- a/ext/four_oh_four/info.php +++ b/ext/four_oh_four/info.php @@ -4,12 +4,12 @@ class FourOhFourInfo extends ExtensionInfo { public const KEY = "four_oh_four"; - public $key = self::KEY; - public $name = "404 Detector"; - public $url = self::SHIMMIE_URL; - public $authors = self::SHISH_AUTHOR; - public $license = self::LICENSE_GPLV2; - public $visibility = self::VISIBLE_HIDDEN; - public $description = "If no other extension puts anything onto the page, show 404"; - public $core = true; + public string $key = self::KEY; + public string $name = "404 Detector"; + public string $url = self::SHIMMIE_URL; + public array $authors = self::SHISH_AUTHOR; + public string $license = self::LICENSE_GPLV2; + public string $visibility = self::VISIBLE_HIDDEN; + public string $description = "If no other extension puts anything onto the page, show 404"; + public bool $core = true; } diff --git a/ext/four_oh_four/main.php b/ext/four_oh_four/main.php index 08ae677d..f1a19214 100644 --- a/ext/four_oh_four/main.php +++ b/ext/four_oh_four/main.php @@ -17,7 +17,7 @@ class FourOhFour extends Extension } } - private function count_main($blocks) + private function count_main($blocks): int { $n = 0; foreach ($blocks as $block) { diff --git a/ext/google_analytics/info.php b/ext/google_analytics/info.php index fc7c47be..ca0405ed 100644 --- a/ext/google_analytics/info.php +++ b/ext/google_analytics/info.php @@ -4,12 +4,12 @@ class GoogleAnalyticsInfo extends ExtensionInfo { public const KEY = "google_analytics"; - public $key = self::KEY; - public $name = "Google Analytics"; - public $url = "http://drudexsoftware.com"; - public $authors = ["Drudex Software"=>"support@drudexsoftware.com"]; - public $license = self::LICENSE_GPLV2; - public $description = "Integrates Google Analytics tracking"; - public $documentation = + public string $key = self::KEY; + public string $name = "Google Analytics"; + public string $url = "http://drudexsoftware.com"; + public array $authors = ["Drudex Software"=>"support@drudexsoftware.com"]; + public string $license = self::LICENSE_GPLV2; + public string $description = "Integrates Google Analytics tracking"; + public ?string $documentation = "User has to enter their Google Analytics ID in the Board Config to use this extension."; } diff --git a/ext/google_analytics/main.php b/ext/google_analytics/main.php index 72c0f4e9..c4d78071 100644 --- a/ext/google_analytics/main.php +++ b/ext/google_analytics/main.php @@ -23,7 +23,7 @@ class GoogleAnalytics extends Extension _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; - ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; + ga.src = ('https:' === document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })();"); } diff --git a/ext/handle_archive/info.php b/ext/handle_archive/info.php index 066cf1b0..a6295a1c 100644 --- a/ext/handle_archive/info.php +++ b/ext/handle_archive/info.php @@ -4,12 +4,12 @@ class ArchiveFileHandlerInfo extends ExtensionInfo { public const KEY = "handle_archive"; - public $key = self::KEY; - public $name = "Handle Archives"; - public $url = self::SHIMMIE_URL; - public $authors = self::SHISH_AUTHOR; - public $description = "Allow users to upload archives (zip, etc)"; - public $documentation = + public string $key = self::KEY; + public string $name = "Handle Archives"; + public string $url = self::SHIMMIE_URL; + public array $authors = self::SHISH_AUTHOR; + public string $description = "Allow users to upload archives (zip, etc)"; + public ?string $documentation = "Note: requires exec() access and an external unzip command

    Any command line unzipper should work, some examples:

    unzip: unzip -d \"%d\" \"%f\" diff --git a/ext/handle_archive/main.php b/ext/handle_archive/main.php index 55c7b686..1d39fecc 100644 --- a/ext/handle_archive/main.php +++ b/ext/handle_archive/main.php @@ -2,7 +2,7 @@ class ArchiveFileHandler extends DataHandlerExtension { - protected $SUPPORTED_MIME = [MimeType::ZIP]; + protected array $SUPPORTED_MIME = [MimeType::ZIP]; public function onInitExt(InitExtEvent $event) { @@ -56,7 +56,7 @@ class ArchiveFileHandler extends DataHandlerExtension return false; } - protected function create_thumb(string $hash, string $type): bool + protected function create_thumb(string $hash, string $mime): bool { return false; } diff --git a/ext/handle_cbz/info.php b/ext/handle_cbz/info.php index 25b72125..692ef244 100644 --- a/ext/handle_cbz/info.php +++ b/ext/handle_cbz/info.php @@ -4,9 +4,9 @@ class CBZFileHandlerInfo extends ExtensionInfo { public const KEY = "handle_cbz"; - public $key = self::KEY; - public $name = "Handle CBZ"; - public $url = self::SHIMMIE_URL; - public $authors = self::SHISH_AUTHOR; - public $description = "Handle CBZ Comic Archives."; + public string $key = self::KEY; + public string $name = "Handle CBZ"; + public string $url = self::SHIMMIE_URL; + public array $authors = self::SHISH_AUTHOR; + public string $description = "Handle CBZ Comic Archives."; } diff --git a/ext/handle_cbz/main.php b/ext/handle_cbz/main.php index 40e6e4c5..0a98f244 100644 --- a/ext/handle_cbz/main.php +++ b/ext/handle_cbz/main.php @@ -2,7 +2,7 @@ class CBZFileHandler extends DataHandlerExtension { - protected $SUPPORTED_MIME = [MimeType::COMIC_ZIP]; + protected array $SUPPORTED_MIME = [MimeType::COMIC_ZIP]; protected function media_check_properties(MediaCheckPropertiesEvent $event): void { diff --git a/ext/handle_flash/info.php b/ext/handle_flash/info.php index 448996bc..2c44530e 100644 --- a/ext/handle_flash/info.php +++ b/ext/handle_flash/info.php @@ -4,9 +4,9 @@ class FlashFileHandlerInfo extends ExtensionInfo { public const KEY = "handle_flash"; - public $key = self::KEY; - public $name = "Handle Flash"; - public $url = self::SHIMMIE_URL; - public $authors = self::SHISH_AUTHOR; - public $description = "Handle Flash files."; + public string $key = self::KEY; + public string $name = "Handle Flash"; + public string $url = self::SHIMMIE_URL; + public array $authors = self::SHISH_AUTHOR; + public string $description = "Handle Flash files."; } diff --git a/ext/handle_flash/main.php b/ext/handle_flash/main.php index b4b0969c..d7bfdc02 100644 --- a/ext/handle_flash/main.php +++ b/ext/handle_flash/main.php @@ -2,7 +2,7 @@ class FlashFileHandler extends DataHandlerExtension { - protected $SUPPORTED_MIME = [MimeType::FLASH]; + protected array $SUPPORTED_MIME = [MimeType::FLASH]; protected function media_check_properties(MediaCheckPropertiesEvent $event): void { @@ -17,7 +17,7 @@ class FlashFileHandler extends DataHandlerExtension } } - protected function create_thumb(string $hash, string $type): bool + protected function create_thumb(string $hash, string $mime): bool { if (!Media::create_thumbnail_ffmpeg($hash)) { copy("ext/handle_flash/thumb.jpg", warehouse_path(Image::THUMBNAIL_DIR, $hash)); diff --git a/ext/handle_ico/info.php b/ext/handle_ico/info.php index 6c932f0c..485827d2 100644 --- a/ext/handle_ico/info.php +++ b/ext/handle_ico/info.php @@ -4,9 +4,9 @@ class IcoFileHandlerInfo extends ExtensionInfo { public const KEY = "handle_ico"; - public $key = self::KEY; - public $name = "Handle ICO"; - public $url = self::SHIMMIE_URL; - public $authors = self::SHISH_AUTHOR; - public $description = "Handle windows icons"; + public string $key = self::KEY; + public string $name = "Handle ICO"; + public string $url = self::SHIMMIE_URL; + public array $authors = self::SHISH_AUTHOR; + public string $description = "Handle windows icons"; } diff --git a/ext/handle_ico/main.php b/ext/handle_ico/main.php index 69363c3a..41421196 100644 --- a/ext/handle_ico/main.php +++ b/ext/handle_ico/main.php @@ -2,7 +2,7 @@ class IcoFileHandler extends DataHandlerExtension { - protected $SUPPORTED_MIME = [MimeType::ICO, MimeType::ANI, MimeType::WIN_BITMAP, MimeType::ICO_OSX]; + protected array $SUPPORTED_MIME = [MimeType::ICO, MimeType::ANI, MimeType::WIN_BITMAP, MimeType::ICO_OSX]; protected function media_check_properties(MediaCheckPropertiesEvent $event): void { @@ -36,9 +36,9 @@ class IcoFileHandler extends DataHandlerExtension } } - protected function check_contents(string $file): bool + protected function check_contents(string $tmpname): bool { - $fp = fopen($file, "r"); + $fp = fopen($tmpname, "r"); $header = unpack("Snull/Stype/Scount", fread($fp, 6)); fclose($fp); return ($header['null'] == 0 && ($header['type'] == 0 || $header['type'] == 1)); diff --git a/ext/handle_mp3/info.php b/ext/handle_mp3/info.php index ba5ede9b..9a2b2420 100644 --- a/ext/handle_mp3/info.php +++ b/ext/handle_mp3/info.php @@ -4,9 +4,9 @@ class MP3FileHandlerInfo extends ExtensionInfo { public const KEY = "handle_mp3"; - public $key = self::KEY; - public $name = "Handle MP3"; - public $url = self::SHIMMIE_URL; - public $authors = self::SHISH_AUTHOR; - public $description = "Handle MP3 files"; + public string $key = self::KEY; + public string $name = "Handle MP3"; + public string $url = self::SHIMMIE_URL; + public array $authors = self::SHISH_AUTHOR; + public string $description = "Handle MP3 files"; } diff --git a/ext/handle_mp3/main.php b/ext/handle_mp3/main.php index 48663bc9..d052853f 100644 --- a/ext/handle_mp3/main.php +++ b/ext/handle_mp3/main.php @@ -5,7 +5,7 @@ class MP3FileHandler extends DataHandlerExtension { - protected $SUPPORTED_MIME = [MimeType::MP3]; + protected array $SUPPORTED_MIME = [MimeType::MP3]; protected function media_check_properties(MediaCheckPropertiesEvent $event): void { @@ -18,7 +18,7 @@ class MP3FileHandler extends DataHandlerExtension // TODO: ->length = ??? } - protected function create_thumb(string $hash, string $type): bool + protected function create_thumb(string $hash, string $mime): bool { copy("ext/handle_mp3/thumb.jpg", warehouse_path(Image::THUMBNAIL_DIR, $hash)); return true; diff --git a/ext/handle_pixel/info.php b/ext/handle_pixel/info.php index fb94045f..c33e08f7 100644 --- a/ext/handle_pixel/info.php +++ b/ext/handle_pixel/info.php @@ -4,10 +4,10 @@ class PixelFileHandlerInfo extends ExtensionInfo { public const KEY = "handle_pixel"; - public $key = self::KEY; - public $name = "Handle Pixel"; - public $url = self::SHIMMIE_URL; - public $authors = self::SHISH_AUTHOR; - public $description = "Handle JPEG, PNG, GIF, WEBP, etc files"; - public $core = true; + public string $key = self::KEY; + public string $name = "Handle Pixel"; + public string $url = self::SHIMMIE_URL; + public array $authors = self::SHISH_AUTHOR; + public string $description = "Handle JPEG, PNG, GIF, WEBP, etc files"; + public bool $core = true; } diff --git a/ext/handle_pixel/main.php b/ext/handle_pixel/main.php index 7e77561f..8fdb4424 100644 --- a/ext/handle_pixel/main.php +++ b/ext/handle_pixel/main.php @@ -2,7 +2,7 @@ class PixelFileHandler extends DataHandlerExtension { - protected $SUPPORTED_MIME = [MimeType::JPEG, MimeType::GIF, MimeType::PNG, MimeType::WEBP]; + protected array $SUPPORTED_MIME = [MimeType::JPEG, MimeType::GIF, MimeType::PNG, MimeType::WEBP]; protected function media_check_properties(MediaCheckPropertiesEvent $event): void { @@ -35,10 +35,10 @@ class PixelFileHandler extends DataHandlerExtension return $info && in_array($info[2], $valid); } - protected function create_thumb(string $hash, string $type): bool + protected function create_thumb(string $hash, string $mime): bool { try { - create_image_thumb($hash, $type); + create_image_thumb($hash, $mime); return true; } catch (InsufficientMemoryException $e) { $tsize = get_thumbnail_max_size_scaled(); diff --git a/ext/handle_pixel/script.js b/ext/handle_pixel/script.js index 6cb05f2c..6cd83fbf 100644 --- a/ext/handle_pixel/script.js +++ b/ext/handle_pixel/script.js @@ -1,28 +1,28 @@ document.addEventListener('DOMContentLoaded', () => { function zoom(zoom_type, save_cookie) { save_cookie = save_cookie === undefined ? true : save_cookie; - + var img = $('.shm-main-image'); - - if(zoom_type == "full") { + + if(zoom_type === "full") { img.css('max-width', img.data('width') + 'px'); img.css('max-height', img.data('height') + 'px'); } - if(zoom_type == "width") { + if(zoom_type === "width") { img.css('max-width', '95%'); img.css('max-height', img.data('height') + 'px'); } - if(zoom_type == "height") { + if(zoom_type === "height") { img.css('max-width', img.data('width') + 'px'); img.css('max-height', (window.innerHeight * 0.95) + 'px'); } - if(zoom_type == "both") { + if(zoom_type === "both") { img.css('max-width', '95%'); img.css('max-height', (window.innerHeight * 0.95) + 'px'); } - + $(".shm-zoomer").val(zoom_type); - + if (save_cookie) { Cookies.set("ui-image-zoom", zoom_type, {expires: 365}); } diff --git a/ext/handle_svg/info.php b/ext/handle_svg/info.php index e9818a65..b23918ce 100644 --- a/ext/handle_svg/info.php +++ b/ext/handle_svg/info.php @@ -4,9 +4,9 @@ class SVGFileHandlerInfo extends ExtensionInfo { public const KEY = "handle_svg"; - public $key = self::KEY; - public $name = "Handle SVG"; - public $url = self::SHIMMIE_URL; - public $authors = self::SHISH_AUTHOR; - public $description = "Handle static SVG files."; + public string $key = self::KEY; + public string $name = "Handle SVG"; + public string $url = self::SHIMMIE_URL; + public array $authors = self::SHISH_AUTHOR; + public string $description = "Handle static SVG files."; } diff --git a/ext/handle_svg/main.php b/ext/handle_svg/main.php index 1c8cafb3..1f3ec92a 100644 --- a/ext/handle_svg/main.php +++ b/ext/handle_svg/main.php @@ -3,10 +3,10 @@ use enshrined\svgSanitize\Sanitizer; class SVGFileHandler extends DataHandlerExtension { - protected $SUPPORTED_MIME = [MimeType::SVG]; + protected array $SUPPORTED_MIME = [MimeType::SVG]; /** @var SVGFileHandlerTheme */ - protected $theme; + protected ?Themelet $theme; public function onPageRequest(PageRequestEvent $event) { @@ -48,14 +48,14 @@ class SVGFileHandler extends DataHandlerExtension file_put_contents(warehouse_path(Image::IMAGE_DIR, $event->hash), $cleanSVG); } - protected function create_thumb(string $hash, string $type): bool + protected function create_thumb(string $hash, string $mime): bool { try { // Normally we require imagemagick, but for unit tests we can use a no-op engine if (defined('UNITTEST')) { - create_image_thumb($hash, $type); + create_image_thumb($hash, $mime); } else { - create_image_thumb($hash, $type, MediaEngine::IMAGICK); + create_image_thumb($hash, $mime, MediaEngine::IMAGICK); } return true; } catch (MediaException $e) { @@ -65,28 +65,23 @@ class SVGFileHandler extends DataHandlerExtension } } - protected function check_contents(string $file): bool + protected function check_contents(string $tmpname): bool { - if (MimeType::get_for_file($file)!==MimeType::SVG) { + if (MimeType::get_for_file($tmpname)!==MimeType::SVG) { return false; } - $msp = new MiniSVGParser($file); + $msp = new MiniSVGParser($tmpname); return bool_escape($msp->valid); } } class MiniSVGParser { - /** @var bool */ - public $valid=false; - /** @var int */ - public $width=0; - /** @var int */ - public $height=0; - - /** @var int */ - private $xml_depth=0; + public bool $valid = false; + public int $width=0; + public int $height=0; + private int $xml_depth=0; public function __construct(string $file) { diff --git a/ext/handle_video/info.php b/ext/handle_video/info.php index 66965294..f242d7b5 100644 --- a/ext/handle_video/info.php +++ b/ext/handle_video/info.php @@ -4,12 +4,12 @@ class VideoFileHandlerInfo extends ExtensionInfo { public const KEY = "handle_video"; - public $key = self::KEY; - public $name = "Handle Video"; - public $authors = ["velocity37"=>"velocity37@gmail.com",self::SHISH_NAME=>self::SHISH_EMAIL, "jgen"=>"jeffgenovy@gmail.com", "im-mi"=>"im.mi.mail.mi@gmail.com"]; - public $license = self::LICENSE_GPLV2; - public $description = "Handle FLV, MP4, OGV and WEBM video files."; - public $documentation = + public string $key = self::KEY; + public string $name = "Handle Video"; + public array $authors = ["velocity37"=>"velocity37@gmail.com",self::SHISH_NAME=>self::SHISH_EMAIL, "jgen"=>"jeffgenovy@gmail.com", "im-mi"=>"im.mi.mail.mi@gmail.com"]; + public string $license = self::LICENSE_GPLV2; + public string $description = "Handle FLV, MP4, OGV and WEBM video files."; + public ?string $documentation = "Based heavily on \"Handle MP3\" by Shish.

    FLV: Flash player
    MP4: HTML5 with Flash fallback
    diff --git a/ext/handle_video/main.php b/ext/handle_video/main.php index 11d3a356..9de0cd5e 100644 --- a/ext/handle_video/main.php +++ b/ext/handle_video/main.php @@ -20,7 +20,7 @@ class VideoFileHandler extends DataHandlerExtension MimeType::QUICKTIME, MimeType::WEBM, ]; - protected $SUPPORTED_MIME = self::SUPPORTED_MIME; + protected array $SUPPORTED_MIME = self::SUPPORTED_MIME; public function onInitExt(InitExtEvent $event) { @@ -65,7 +65,7 @@ class VideoFileHandler extends DataHandlerExtension if (is_array($data)) { if (array_key_exists("streams", $data)) { $video = false; - $audio = true; + $audio = false; $video_codec = null; $streams = $data["streams"]; if (is_array($streams)) { @@ -107,7 +107,7 @@ class VideoFileHandler extends DataHandlerExtension if (array_key_exists("format", $data)&& is_array($data["format"])) { $format = $data["format"]; if (array_key_exists("duration", $format) && is_numeric($format["duration"])) { - $event->image->length = floor(floatval($format["duration"]) * 1000); + $event->image->length = (int)floor(floatval($format["duration"]) * 1000); } } } @@ -125,7 +125,7 @@ class VideoFileHandler extends DataHandlerExtension return MimeType::matches_array($mime, $enabled_formats, true); } - protected function create_thumb(string $hash, string $type): bool + protected function create_thumb(string $hash, string $mime): bool { return Media::create_thumbnail_ffmpeg($hash); } diff --git a/ext/hellban/info.php b/ext/hellban/info.php index a3e9cdb3..ecd6a5f9 100644 --- a/ext/hellban/info.php +++ b/ext/hellban/info.php @@ -8,7 +8,8 @@ class HellBanInfo extends ExtensionInfo { public const KEY = "hellban"; - public $key = self::KEY; - public $name = "Hellban"; - public $beta = true; + public string $key = self::KEY; + public string $name = "Hellban"; + public bool $beta = true; + public string $description = "Make some users only visible to themselves"; } diff --git a/ext/help_pages/info.php b/ext/help_pages/info.php index ecca4cda..719459ff 100644 --- a/ext/help_pages/info.php +++ b/ext/help_pages/info.php @@ -4,11 +4,11 @@ class HelpPagesInfo extends ExtensionInfo { public const KEY = "help_pages"; - public $key = self::KEY; - public $name = "Help Pages"; - public $authors = ["Matthew Barbour"=>"matthew@darkholme.net"]; - public $license = self::LICENSE_WTFPL; - public $description = "Provides documentation screens"; - public $visibility = self::VISIBLE_HIDDEN; - public $core = true; + public string $key = self::KEY; + public string $name = "Help Pages"; + public array $authors = ["Matthew Barbour"=>"matthew@darkholme.net"]; + public string $license = self::LICENSE_WTFPL; + public string $description = "Provides documentation screens"; + public string $visibility = self::VISIBLE_HIDDEN; + public bool $core = true; } diff --git a/ext/help_pages/main.php b/ext/help_pages/main.php index a3fe8290..ef3991fd 100644 --- a/ext/help_pages/main.php +++ b/ext/help_pages/main.php @@ -2,7 +2,7 @@ class HelpPageListBuildingEvent extends Event { - public $pages = []; + public array $pages = []; public function add_page(string $key, string $name) { @@ -12,8 +12,8 @@ class HelpPageListBuildingEvent extends Event class HelpPageBuildingEvent extends Event { - public $key; - public $blocks = []; + public string $key; + public array $blocks = []; public function __construct(string $key) { @@ -33,11 +33,9 @@ class HelpPageBuildingEvent extends Event class HelpPages extends Extension { /** @var HelpPagesTheme */ - protected $theme; - + protected ?Themelet $theme; public const SEARCH = "search"; - - private $pages; + private ?array $pages = null; private function get_pages(): array { diff --git a/ext/holiday/info.php b/ext/holiday/info.php index 22832290..21d02f42 100644 --- a/ext/holiday/info.php +++ b/ext/holiday/info.php @@ -4,10 +4,10 @@ class HolidayInfo extends ExtensionInfo { public const KEY = "holiday"; - public $key = self::KEY; - public $name = "Holiday Theme"; - public $url = "http://www.codeanimu.net"; - public $authors = ["DakuTree"=>"thedakutree@codeanimu.net"]; - public $license = self::LICENSE_GPLV2; - public $description = "Use an additional stylesheet on certain holidays"; + public string $key = self::KEY; + public string $name = "Holiday Theme"; + public string $url = "http://www.codeanimu.net"; + public array $authors = ["DakuTree"=>"thedakutree@codeanimu.net"]; + public string $license = self::LICENSE_GPLV2; + public string $description = "Use an additional stylesheet on certain holidays"; } diff --git a/ext/holiday/main.php b/ext/holiday/main.php index 7d911c36..8a3ec55f 100644 --- a/ext/holiday/main.php +++ b/ext/holiday/main.php @@ -3,7 +3,7 @@ class Holiday extends Extension { /** @var HolidayTheme */ - protected $theme; + protected ?Themelet $theme; public function onInitExt(InitExtEvent $event) { @@ -20,11 +20,8 @@ class Holiday extends Extension public function onPageRequest(PageRequestEvent $event) { global $config; - $date = /*date('d/m') == '01/01' ||date('d/m') == '14/02' || */date('d/m') == '01/04'/* || date('d/m') == '24/12' || date('d/m') == '25/12' || date('d/m') == '31/12'*/; - if ($date) { - if ($config->get_bool("holiday_aprilfools")) { - $this->theme->display_holiday($date); - } + if (date('d/m') == '01/04' && $config->get_bool("holiday_aprilfools")) { + $this->theme->display_holiday("aprilfools"); } } } diff --git a/ext/holiday/theme.php b/ext/holiday/theme.php index d0afcbe4..2aa993af 100644 --- a/ext/holiday/theme.php +++ b/ext/holiday/theme.php @@ -1,21 +1,13 @@ "; - $page->add_html_header("$csssheet"); + if ($holiday) { + $page->add_html_header( + "" + ); } } } diff --git a/ext/home/info.php b/ext/home/info.php index 8740b38a..e99b2d1a 100644 --- a/ext/home/info.php +++ b/ext/home/info.php @@ -4,13 +4,13 @@ class HomeInfo extends ExtensionInfo { public const KEY = "home"; - public $key = self::KEY; - public $name = "Home Page"; - public $authors =["Bzchan"=>"bzchan@animemahou.com"]; - public $license = self::LICENSE_GPLV2; - public $visibility = self::VISIBLE_ADMIN; - public $description = "Displays a front page with logo, search box and post count"; - public $documentation = + public string $key = self::KEY; + public string $name = "Home Page"; + public array $authors =["Bzchan"=>"bzchan@animemahou.com"]; + public string $license = self::LICENSE_GPLV2; + public string $visibility = self::VISIBLE_ADMIN; + public string $description = "Displays a front page with logo, search box and post count"; + public ?string $documentation = "Once enabled, the page will show up at the URL \"home\", so if you want this to be the front page of your site, you should go to \"Board Config\" and set \"Front Page\" to \"home\". diff --git a/ext/home/main.php b/ext/home/main.php index 6dbcfbf4..3118feaf 100644 --- a/ext/home/main.php +++ b/ext/home/main.php @@ -3,7 +3,7 @@ class Home extends Extension { /** @var HomeTheme */ - protected $theme; + protected ?Themelet $theme; public function onPageRequest(PageRequestEvent $event) { @@ -34,7 +34,7 @@ class Home extends Extension } - private function get_body() + private function get_body(): string { // returns just the contents of the body global $config; diff --git a/ext/home/theme.php b/ext/home/theme.php index afd898be..0a0ca876 100644 --- a/ext/home/theme.php +++ b/ext/home/theme.php @@ -2,7 +2,7 @@ class HomeTheme extends Themelet { - public function display_page(Page $page, $sitename, $base_href, $theme_name, $body) + public function display_page(Page $page, string $sitename, string $base_href, string $theme_name, string $body): void { $page->set_mode(PageMode::DATA); $page->add_auto_html_headers(); @@ -25,7 +25,7 @@ EOD ); } - public function build_body(string $sitename, string $main_links, string $main_text, string $contact_link, $num_comma, string $counter_text) + public function build_body(string $sitename, string $main_links, string $main_text, string $contact_link, $num_comma, string $counter_text): string { $main_links_html = empty($main_links) ? "" : "

    "; $message_html = empty($main_text) ? "" : "
    $main_text
    "; diff --git a/ext/image/info.php b/ext/image/info.php index abf55984..2c4b78d6 100644 --- a/ext/image/info.php +++ b/ext/image/info.php @@ -4,12 +4,12 @@ class ImageIOInfo extends ExtensionInfo { public const KEY = "image"; - public $key = self::KEY; - public $name = "Post Manager"; - public $url = self::SHIMMIE_URL; - public $authors = [self::SHISH_NAME=> self::SHISH_EMAIL, "jgen"=>"jgen.tech@gmail.com"]; - public $license = self::LICENSE_GPLV2; - public $description = "Handle the image database"; - public $visibility = self::VISIBLE_HIDDEN; - public $core = true; + public string $key = self::KEY; + public string $name = "Post Manager"; + public string $url = self::SHIMMIE_URL; + public array $authors = [self::SHISH_NAME=> self::SHISH_EMAIL, "jgen"=>"jgen.tech@gmail.com"]; + public string $license = self::LICENSE_GPLV2; + public string $description = "Handle the image database"; + public string $visibility = self::VISIBLE_HIDDEN; + public bool $core = true; } diff --git a/ext/image/main.php b/ext/image/main.php index 80a03391..0d2b0579 100644 --- a/ext/image/main.php +++ b/ext/image/main.php @@ -8,7 +8,7 @@ require_once "config.php"; class ImageIO extends Extension { /** @var ImageIOTheme */ - protected $theme; + protected ?Themelet $theme; const COLLISION_OPTIONS = [ 'Error'=>ImageConfig::COLLISION_ERROR, @@ -155,7 +155,9 @@ class ImageIO extends Extension send_event(new SourceSetEvent($existing, $_GET['source'])); } $event->merged = true; - $event->image = Image::by_id($existing->id); + $im = Image::by_id($existing->id); + assert(!is_null($image)); + $event->image = $im; return; } else { $error = "Post {$existing->id} ". diff --git a/ext/image_hash_ban/info.php b/ext/image_hash_ban/info.php index 77c30580..61ef21e9 100644 --- a/ext/image_hash_ban/info.php +++ b/ext/image_hash_ban/info.php @@ -4,13 +4,13 @@ class ImageBanInfo extends ExtensionInfo { public const KEY = "image_hash_ban"; - public $key = self::KEY; - public $name = "Post Hash Ban"; - public $url = "http://atravelinggeek.com/"; - public $authors = ["ATravelingGeek"=>"atg@atravelinggeek.com"]; - public $license = self::LICENSE_GPLV2; - public $description = "Ban images based on their hash"; - public $version = "0.1, October 21, 2007"; - public $documentation = + public string $key = self::KEY; + public string $name = "Post Hash Ban"; + public string $url = "http://atravelinggeek.com/"; + public array $authors = ["ATravelingGeek"=>"atg@atravelinggeek.com"]; + public string $license = self::LICENSE_GPLV2; + public string $description = "Ban images based on their hash"; + public ?string $version = "0.1, October 21, 2007"; + public ?string $documentation = "Based on the ResolutionLimit and IPban extensions by Shish"; } diff --git a/ext/image_hash_ban/main.php b/ext/image_hash_ban/main.php index 629d8d2c..d9715b65 100644 --- a/ext/image_hash_ban/main.php +++ b/ext/image_hash_ban/main.php @@ -31,7 +31,7 @@ class HashBanTable extends Table class RemoveImageHashBanEvent extends Event { - public $hash; + public string $hash; public function __construct(string $hash) { @@ -42,8 +42,8 @@ class RemoveImageHashBanEvent extends Event class AddImageHashBanEvent extends Event { - public $hash; - public $reason; + public string $hash; + public string $reason; public function __construct(string $hash, string $reason) { @@ -56,7 +56,7 @@ class AddImageHashBanEvent extends Event class ImageBan extends Extension { /** @var ImageBanTheme */ - protected $theme; + protected ?Themelet $theme; public function onDatabaseUpgrade(DatabaseUpgradeEvent $event) { diff --git a/ext/image_hash_ban/test.php b/ext/image_hash_ban/test.php index 720c7d3f..1cb27827 100644 --- a/ext/image_hash_ban/test.php +++ b/ext/image_hash_ban/test.php @@ -1,7 +1,7 @@ set_title("Post Bans"); $page->set_heading("Post Bans"); @@ -17,7 +17,7 @@ class ImageBanTheme extends Themelet /* * Display a link to delete an image */ - public function get_buttons_html(Image $image) + public function get_buttons_html(Image $image): string { return (string)SHM_SIMPLE_FORM( "image_hash_ban/add", diff --git a/ext/image_view_counter/info.php b/ext/image_view_counter/info.php index ad043076..0d71ab6c 100644 --- a/ext/image_view_counter/info.php +++ b/ext/image_view_counter/info.php @@ -4,13 +4,13 @@ class ImageViewCounterInfo extends ExtensionInfo { public const KEY = "image_view_counter"; - public $key = self::KEY; - public $name = "Post View Counter"; - public $url = "http://www.drudexsoftware.com/"; - public $authors = ["Drudex Software"=>"support@drudexsoftware.com"]; - public $license = self::LICENSE_GPLV2; - public $description = "Tracks & displays how many times a post is viewed"; - public $documentation = + public string $key = self::KEY; + public string $name = "Post View Counter"; + public string $url = "http://www.drudexsoftware.com/"; + public array $authors = ["Drudex Software"=>"support@drudexsoftware.com"]; + public string $license = self::LICENSE_GPLV2; + public string $description = "Tracks & displays how many times a post is viewed"; + public ?string $documentation = "Whenever anyone views a post, a view will be added to that image. This extension will also track any username & the IP address. This is done to prevent duplicate views. diff --git a/ext/image_view_counter/main.php b/ext/image_view_counter/main.php index d4b4b682..3c025fa8 100644 --- a/ext/image_view_counter/main.php +++ b/ext/image_view_counter/main.php @@ -2,8 +2,8 @@ class ImageViewCounter extends Extension { - protected $theme; - private $view_interval = 3600; # allows views to be added each hour + protected ?Themelet $theme; + private int $view_interval = 3600; # allows views to be added each hour # Add Setup Block with options for view counter public function onSetupBuilding(SetupBuildingEvent $event) diff --git a/ext/image_view_counter/theme.php b/ext/image_view_counter/theme.php index 98bc2d6e..a7f9292c 100644 --- a/ext/image_view_counter/theme.php +++ b/ext/image_view_counter/theme.php @@ -17,7 +17,7 @@ class ImageViewCounterTheme extends Themelet $page->add_block(new Block(null, $pop_images, "main", 30)); } - public function get_help_html() + public function get_help_html(): string { return '

    Search for posts that have received views by users.

    '; } diff --git a/ext/index/events.php b/ext/index/events.php index a4a8585f..10911fb8 100644 --- a/ext/index/events.php +++ b/ext/index/events.php @@ -6,16 +6,13 @@ */ class SearchTermParseEvent extends Event { - /** @var int */ - public $id = 0; - /** @var null|string */ - public $term = null; + public int $id = 0; + public ?string $term = null; /** @var string[] */ - public $context = []; + public array $context = []; /** @var Querylet[] */ - public $querylets = []; - /** @var null|string */ - public $order = null; + public array $querylets = []; + public ?string $order = null; public function __construct(int $id, string $term=null, array $context=[]) { @@ -37,11 +34,8 @@ class SearchTermParseException extends SCoreException class PostListBuildingEvent extends Event { - /** @var array */ - public $search_terms = []; - - /** @var array */ - public $parts = []; + public array $search_terms = []; + public array $parts = []; /** * #param string[] $search diff --git a/ext/index/info.php b/ext/index/info.php index 9c7377fe..4f6901e1 100644 --- a/ext/index/info.php +++ b/ext/index/info.php @@ -4,14 +4,14 @@ class IndexInfo extends ExtensionInfo { public const KEY = "index"; - public $key = self::KEY; - public $name = "Post List"; - public $url = self::SHIMMIE_URL; - public $authors = self::SHISH_AUTHOR; - public $license = self::LICENSE_GPLV2; - public $description = "Show a list of uploaded posts"; - public $core = true; - public $documentation = "Here is a list of the search methods available out of the box; + public string $key = self::KEY; + public string $name = "Post List"; + public string $url = self::SHIMMIE_URL; + public array $authors = self::SHISH_AUTHOR; + public string $license = self::LICENSE_GPLV2; + public string $description = "Show a list of uploaded posts"; + public bool $core = true; + public ?string $documentation = "Here is a list of the search methods available out of the box; Shimmie extensions may provide other filters:
    • by tag, eg diff --git a/ext/index/main.php b/ext/index/main.php index 20e7793e..5f8e400f 100644 --- a/ext/index/main.php +++ b/ext/index/main.php @@ -6,7 +6,7 @@ require_once "events.php"; class Index extends Extension { /** @var IndexTheme */ - protected $theme; + protected ?Themelet $theme; public function onInitExt(InitExtEvent $event) { diff --git a/ext/index/test.php b/ext/index/test.php index e1399cd1..41899214 100644 --- a/ext/index/test.php +++ b/ext/index/test.php @@ -57,7 +57,7 @@ class IndexTest extends ShimmiePHPUnitTestCase } // base case - public function testUpload() + public function testUpload(): array { $this->log_in_as_user(); $image_id_1 = $this->post_image("tests/pbx_screenshot.jpg", "thing computer screenshot pbx phone"); diff --git a/ext/index/theme.php b/ext/index/theme.php index e9f949e0..f68a3eaa 100644 --- a/ext/index/theme.php +++ b/ext/index/theme.php @@ -2,9 +2,9 @@ class IndexTheme extends Themelet { - protected $page_number; - protected $total_pages; - protected $search_terms; + protected int $page_number; + protected int $total_pages; + protected array $search_terms; public function set_page(int $page_number, int $total_pages, array $search_terms) { @@ -179,7 +179,7 @@ and of course start organising your images :-) } } - public function get_help_html() + public function get_help_html(): string { return '

      Searching is largely based on tags, with a number of special keywords available that allow searching based on properties of the posts.

      diff --git a/ext/ipban/info.php b/ext/ipban/info.php index 38876db7..82915f3e 100644 --- a/ext/ipban/info.php +++ b/ext/ipban/info.php @@ -4,13 +4,13 @@ class IPBanInfo extends ExtensionInfo { public const KEY = "ipban"; - public $key = self::KEY; - public $name = "IP Ban"; - public $url = self::SHIMMIE_URL; - public $authors = self::SHISH_AUTHOR; - public $license = self::LICENSE_GPLV2; - public $description = "Ban IP addresses"; - public $documentation = + public string $key = self::KEY; + public string $name = "IP Ban"; + public string $url = self::SHIMMIE_URL; + public array $authors = self::SHISH_AUTHOR; + public string $license = self::LICENSE_GPLV2; + public string $description = "Ban IP addresses"; + public ?string $documentation = "Adding a Ban
      IP: Can be a single IP (eg. 123.234.210.21), or a CIDR block (eg. 152.23.43.0/24)
      Reason: Any text, for the admin to remember why the ban was put in place diff --git a/ext/ipban/main.php b/ext/ipban/main.php index 99b36e78..8d1a5a36 100644 --- a/ext/ipban/main.php +++ b/ext/ipban/main.php @@ -48,7 +48,7 @@ class IPBanTable extends Table class RemoveIPBanEvent extends Event { - public $id; + public int $id; public function __construct(int $id) { @@ -59,10 +59,10 @@ class RemoveIPBanEvent extends Event class AddIPBanEvent extends Event { - public $ip; - public $mode; - public $reason; - public $expires; + public string $ip; + public string $mode; + public string $reason; + public ?string $expires; public function __construct(string $ip, string $mode, string $reason, ?string $expires) { @@ -77,7 +77,7 @@ class AddIPBanEvent extends Event class IPBan extends Extension { /** @var IPBanTheme */ - protected $theme; + protected ?Themelet $theme; public function get_priority(): int { diff --git a/ext/link_image/info.php b/ext/link_image/info.php index 57c9de6b..1ceefd79 100644 --- a/ext/link_image/info.php +++ b/ext/link_image/info.php @@ -4,12 +4,12 @@ class LinkImageInfo extends ExtensionInfo { public const KEY = "link_image"; - public $key = self::KEY; - public $name = "Link to Post"; - public $authors = ["Artanis"=>"artanis.00@gmail.com"]; - public $description = "Show various forms of link to each image, for copy & paste"; - public $license = self::LICENSE_GPLV2; - public $documentation = "There is one option in Board Config: Text Link Format. + public string $key = self::KEY; + public string $name = "Link to Post"; + public array $authors = ["Artanis"=>"artanis.00@gmail.com"]; + public string $description = "Show various forms of link to each image, for copy & paste"; + public string $license = self::LICENSE_GPLV2; + public ?string $documentation = "There is one option in Board Config: Text Link Format. It takes the following arguments as well as plain text.
      diff --git a/ext/link_image/main.php b/ext/link_image/main.php
      index d0fe036c..670b0600 100644
      --- a/ext/link_image/main.php
      +++ b/ext/link_image/main.php
      @@ -3,7 +3,7 @@
       class LinkImage extends Extension
       {
           /** @var LinkImageTheme */
      -    protected $theme;
      +    protected ?Themelet $theme;
       
           public function onDisplayingImage(DisplayingImageEvent $event)
           {
      @@ -23,7 +23,7 @@ class LinkImage extends Extension
               $config->set_default_string("ext_link-img_text-link_format", '$title - $id ($ext $size $filesize)');
           }
       
      -    private function data(Image $image)
      +    private function data(Image $image): array
           {
               global $config;
       
      diff --git a/ext/link_image/theme.php b/ext/link_image/theme.php
      index a8c15a5b..a1b92ff3 100644
      --- a/ext/link_image/theme.php
      +++ b/ext/link_image/theme.php
      @@ -54,7 +54,7 @@ class LinkImageTheme extends Themelet
               ));
           }
       
      -    protected function url(string $url, string $content, string $type)
      +    protected function url(string $url, string $content, string $type): string
           {
               if ($content == null) {
                   $content=$url;
      @@ -73,7 +73,7 @@ class LinkImageTheme extends Themelet
               return $text;
           }
       
      -    protected function img(string $src, string $type)
      +    protected function img(string $src, string $type): string
           {
               switch ($type) {
                   case "html":
      @@ -88,7 +88,7 @@ class LinkImageTheme extends Themelet
               return $text;
           }
       
      -    protected function link_code(string $label, string $content, $id=null)
      +    protected function link_code(string $label, string $content, $id=null): string
           {
               return	"
       			
    diff --git a/ext/livefeed/info.php b/ext/livefeed/info.php index 77204dfa..22056d6d 100644 --- a/ext/livefeed/info.php +++ b/ext/livefeed/info.php @@ -4,10 +4,10 @@ class LiveFeedInfo extends ExtensionInfo { public const KEY = "livefeed"; - public $key = self::KEY; - public $name = "Live Feed"; - public $authors = self::SHISH_AUTHOR; - public $license = self::LICENSE_GPLV2; - public $visibility = self::VISIBLE_ADMIN; - public $description = "Logs user-safe (no IPs) data to a UDP socket, eg IRCCat"; + public string $key = self::KEY; + public string $name = "Live Feed"; + public array $authors = self::SHISH_AUTHOR; + public string $license = self::LICENSE_GPLV2; + public string $visibility = self::VISIBLE_ADMIN; + public string $description = "Logs user-safe (no IPs) data to a UDP socket, eg IRCCat"; } diff --git a/ext/log_db/info.php b/ext/log_db/info.php index 4d4b76ce..7d206d06 100644 --- a/ext/log_db/info.php +++ b/ext/log_db/info.php @@ -4,10 +4,10 @@ class LogDatabaseInfo extends ExtensionInfo { public const KEY = "log_db"; - public $key = self::KEY; - public $name = "Logging (Database)"; - public $url = self::SHIMMIE_URL; - public $authors = self::SHISH_AUTHOR; - public $description = "Keep a record of SCore events (in the database)."; - public $visibility = self::VISIBLE_ADMIN; + public string $key = self::KEY; + public string $name = "Logging (Database)"; + public string $url = self::SHIMMIE_URL; + public array $authors = self::SHISH_AUTHOR; + public string $description = "Keep a record of SCore events (in the database)."; + public string $visibility = self::VISIBLE_ADMIN; } diff --git a/ext/log_db/main.php b/ext/log_db/main.php index 71ad422c..b5053f8e 100644 --- a/ext/log_db/main.php +++ b/ext/log_db/main.php @@ -8,6 +8,7 @@ use function MicroHTML\BR; use function MicroHTML\SELECT; use function MicroHTML\OPTION; use function MicroHTML\rawHTML; +use MicroHTML\HTMLElement; use MicroCRUD\ActionColumn; use MicroCRUD\Column; use MicroCRUD\DateTimeColumn; @@ -72,7 +73,7 @@ class ActorColumn extends Column ); } - public function modify_input_for_read($input) + public function modify_input_for_read($input): array { list($un, $ip) = $input; if (empty($un)) { @@ -84,7 +85,7 @@ class ActorColumn extends Column return [$un, $ip]; } - public function display($row) + public function display($row): HTMLElement { $ret = emptyHTML(); if ($row['username'] != "Anonymous") { @@ -206,7 +207,7 @@ class LogTable extends Table class LogDatabase extends Extension { /** @var LogDatabaseTheme */ - protected $theme; + protected ?Themelet $theme; public function onInitExt(InitExtEvent $event) { diff --git a/ext/log_logstash/info.php b/ext/log_logstash/info.php index ce5e1d7d..c6befc24 100644 --- a/ext/log_logstash/info.php +++ b/ext/log_logstash/info.php @@ -4,10 +4,10 @@ class LogLogstashInfo extends ExtensionInfo { public const KEY = "log_logstash"; - public $key = self::KEY; - public $name = "Logging (Logstash)"; - public $url = self::SHIMMIE_URL; - public $authors = self::SHISH_AUTHOR; - public $description = "Send log events to a network port."; - public $visibility = self::VISIBLE_ADMIN; + public string $key = self::KEY; + public string $name = "Logging (Logstash)"; + public string $url = self::SHIMMIE_URL; + public array $authors = self::SHISH_AUTHOR; + public string $description = "Send log events to a network port."; + public string $visibility = self::VISIBLE_ADMIN; } diff --git a/ext/log_net/info.php b/ext/log_net/info.php index 6f89598d..cc67ec7b 100644 --- a/ext/log_net/info.php +++ b/ext/log_net/info.php @@ -4,10 +4,10 @@ class LogNetInfo extends ExtensionInfo { public const KEY = "log_net"; - public $key = self::KEY; - public $name = "Logging (Network)"; - public $url = self::SHIMMIE_URL; - public $authors = self::SHISH_AUTHOR; - public $description = "Send log events to a network port."; - public $visibility = self::VISIBLE_ADMIN; + public string $key = self::KEY; + public string $name = "Logging (Network)"; + public string $url = self::SHIMMIE_URL; + public array $authors = self::SHISH_AUTHOR; + public string $description = "Send log events to a network port."; + public string $visibility = self::VISIBLE_ADMIN; } diff --git a/ext/log_net/main.php b/ext/log_net/main.php index 6f76064e..d6c0c196 100644 --- a/ext/log_net/main.php +++ b/ext/log_net/main.php @@ -2,7 +2,7 @@ class LogNet extends Extension { - private $count = 0; + private int $count = 0; public function onLog(LogEvent $event) { diff --git a/ext/media/events.php b/ext/media/events.php index 57e790ea..17375943 100644 --- a/ext/media/events.php +++ b/ext/media/events.php @@ -2,21 +2,21 @@ class MediaResizeEvent extends Event { - public $engine; - public $input_path; - public $input_mime; - public $output_path; - public $target_mime; - public $target_width; - public $target_height; - public $target_quality; - public $alpha_color; - public $minimize; - public $allow_upscale; - public $resize_type; + public string $engine; + public string $input_path; + public string $input_mime; + public string $output_path; + public ?string $target_mime; + public int $target_width; + public int $target_height; + public int $target_quality; + public string $alpha_color; + public bool $minimize; + public bool $allow_upscale; + public string $resize_type; public function __construct( - String $engine, + string $engine, string $input_path, string $input_mime, string $output_path, @@ -51,9 +51,9 @@ class MediaResizeEvent extends Event class MediaCheckPropertiesEvent extends Event { - public $image; - public $file_name; - public $mime; + public Image $image; + public string $file_name; + public string $mime; public function __construct(Image $image) { diff --git a/ext/media/info.php b/ext/media/info.php index a0f20c2b..ea4acca3 100644 --- a/ext/media/info.php +++ b/ext/media/info.php @@ -4,12 +4,12 @@ class MediaInfo extends ExtensionInfo { public const KEY = "media"; - public $key = self::KEY; - public $name = "Media"; - public $url = self::SHIMMIE_URL; - public $authors = ["Matthew Barbour"=>"matthew@darkholme.net"]; - public $license = self::LICENSE_WTFPL; - public $description = "Provides common functions and settings used for media operations."; - public $core = true; - public $visibility = self::VISIBLE_HIDDEN; + public string $key = self::KEY; + public string $name = "Media"; + public string $url = self::SHIMMIE_URL; + public array $authors = ["Matthew Barbour"=>"matthew@darkholme.net"]; + public string $license = self::LICENSE_WTFPL; + public string $description = "Provides common functions and settings used for media operations."; + public bool $core = true; + public string $visibility = self::VISIBLE_HIDDEN; } diff --git a/ext/media/main.php b/ext/media/main.php index a636814e..2ef88c17 100644 --- a/ext/media/main.php +++ b/ext/media/main.php @@ -15,7 +15,7 @@ class MediaException extends SCoreException class Media extends Extension { /** @var MediaTheme */ - protected $theme; + protected ?Themelet $theme; private const LOSSLESS_FORMATS = [ MimeType::WEBP_LOSSLESS, @@ -506,7 +506,7 @@ class Media extends Extension // } // } - public static function is_lossless(string $filename, string $mime) + public static function is_lossless(string $filename, string $mime): bool { if (in_array($mime, self::LOSSLESS_FORMATS)) { return true; @@ -514,7 +514,6 @@ class Media extends Extension switch ($mime) { case MimeType::WEBP: return MimeType::is_lossless_webp($filename); - break; } return false; } diff --git a/ext/media/theme.php b/ext/media/theme.php index 724b125b..67727439 100644 --- a/ext/media/theme.php +++ b/ext/media/theme.php @@ -12,7 +12,7 @@ class MediaTheme extends Themelet ); } - public function get_help_html() + public function get_help_html(): string { return '

    Search for posts based on the type of media.

    diff --git a/ext/mime/info.php b/ext/mime/info.php index b5771409..a4c0eaa9 100644 --- a/ext/mime/info.php +++ b/ext/mime/info.php @@ -4,11 +4,11 @@ class MimeSystemInfo extends ExtensionInfo { public const KEY = "mime"; - public $key = self::KEY; - public $name = "MIME"; - public $authors = ["Matthew Barbour"=>"matthew@darkholme.net"]; - public $license = self::LICENSE_WTFPL; - public $description = "Provides system mime-related functionality"; - public $core = true; - public $visibility = self::VISIBLE_HIDDEN; + public string $key = self::KEY; + public string $name = "MIME"; + public array $authors = ["Matthew Barbour"=>"matthew@darkholme.net"]; + public string $license = self::LICENSE_WTFPL; + public string $description = "Provides system mime-related functionality"; + public bool $core = true; + public string $visibility = self::VISIBLE_HIDDEN; } diff --git a/ext/mime/main.php b/ext/mime/main.php index de0f22e9..e0bc6225 100644 --- a/ext/mime/main.php +++ b/ext/mime/main.php @@ -7,7 +7,7 @@ require_once "mime_type.php"; class MimeSystem extends Extension { /** @var MimeSystemTheme */ - protected $theme; + protected ?Themelet $theme; const VERSION = "ext_mime_version"; diff --git a/ext/mime/theme.php b/ext/mime/theme.php index 5da350a7..af4da95c 100644 --- a/ext/mime/theme.php +++ b/ext/mime/theme.php @@ -2,7 +2,7 @@ class MimeSystemTheme extends Themelet { - public function get_help_html() + public function get_help_html(): string { $mimes = DataHandlerExtension::get_all_supported_mimes(); sort($mimes); diff --git a/ext/not_a_tag/info.php b/ext/not_a_tag/info.php index 2e7e028d..fb61f560 100644 --- a/ext/not_a_tag/info.php +++ b/ext/not_a_tag/info.php @@ -4,10 +4,10 @@ class NotATagInfo extends ExtensionInfo { public const KEY = "not_a_tag"; - public $key = self::KEY; - public $name = "Not A Tag"; - public $url = self::SHIMMIE_URL; - public $authors = self::SHISH_AUTHOR; - public $license = self::LICENSE_GPLV2; - public $description = "Redirect users to the rules if they use bad tags"; + public string $key = self::KEY; + public string $name = "Not A Tag"; + public string $url = self::SHIMMIE_URL; + public array $authors = self::SHISH_AUTHOR; + public string $license = self::LICENSE_GPLV2; + public string $description = "Redirect users to the rules if they use bad tags"; } diff --git a/ext/not_a_tag/main.php b/ext/not_a_tag/main.php index 2658fb71..cd3469d3 100644 --- a/ext/not_a_tag/main.php +++ b/ext/not_a_tag/main.php @@ -29,7 +29,7 @@ class NotATagTable extends Table class NotATag extends Extension { /** @var NotATagTheme */ - protected $theme; + protected ?Themelet $theme; public function get_priority(): int { diff --git a/ext/notes/info.php b/ext/notes/info.php index 1d9d2b85..92f935fb 100644 --- a/ext/notes/info.php +++ b/ext/notes/info.php @@ -4,9 +4,9 @@ class NotesInfo extends ExtensionInfo { public const KEY = "notes"; - public $key = self::KEY; - public $name = "Notes"; - public $authors = ["Sein Kraft"=>"mail@seinkraft.info"]; - public $license = self::LICENSE_GPLV2; - public $description = "Annotate images"; + public string $key = self::KEY; + public string $name = "Notes"; + public array $authors = ["Sein Kraft"=>"mail@seinkraft.info"]; + public string $license = self::LICENSE_GPLV2; + public string $description = "Annotate images"; } diff --git a/ext/notes/main.php b/ext/notes/main.php index f917b0c0..3957e35b 100644 --- a/ext/notes/main.php +++ b/ext/notes/main.php @@ -3,7 +3,7 @@ class Notes extends Extension { /** @var NotesTheme */ - protected $theme; + protected ?Themelet $theme; public function onDatabaseUpgrade(DatabaseUpgradeEvent $event) { diff --git a/ext/notes/theme.php b/ext/notes/theme.php index c6a2c6aa..e4b3b79c 100644 --- a/ext/notes/theme.php +++ b/ext/notes/theme.php @@ -1,7 +1,7 @@ Add a note --> @@ -11,7 +11,7 @@ class NotesTheme extends Themelet '; } - public function request_button($image_id) + public function request_button(int $image_id): string { return make_form(make_link("note/add_request")) . ' @@ -19,7 +19,7 @@ class NotesTheme extends Themelet '; } - public function nuke_notes_button($image_id) + public function nuke_notes_button(int $image_id): string { return make_form(make_link("note/nuke_notes")) . ' @@ -27,7 +27,7 @@ class NotesTheme extends Themelet '; } - public function nuke_requests_button($image_id) + public function nuke_requests_button(int $image_id): string { return make_form(make_link("note/nuke_requests")) . ' @@ -36,7 +36,7 @@ class NotesTheme extends Themelet '; } - public function search_notes_page(Page $page) + public function search_notes_page(Page $page): void { //IN DEVELOPMENT, NOT FULLY WORKING $html = '
    @@ -49,7 +49,7 @@ class NotesTheme extends Themelet } // check action POST on form - public function display_note_system(Page $page, $image_id, $recovered_notes, $adminOptions) + public function display_note_system(Page $page, int $image_id, array $recovered_notes, bool $adminOptions): void { $base_href = get_base_href(); @@ -180,7 +180,7 @@ class NotesTheme extends Themelet $page->add_block(new Block("Note Requests", $pool_images, "main", 20)); } - private function get_history($histories) + private function get_history(array $histories): string { global $user; @@ -248,7 +248,7 @@ class NotesTheme extends Themelet $this->display_paginator($page, "note/updated", null, $pageNumber, $totalPages); } - public function get_help_html() + public function get_help_html(): string { return '

    Search for posts with notes.

    diff --git a/ext/numeric_score/info.php b/ext/numeric_score/info.php index 9ee731a1..da96b18b 100644 --- a/ext/numeric_score/info.php +++ b/ext/numeric_score/info.php @@ -4,11 +4,11 @@ class NumericScoreInfo extends ExtensionInfo { public const KEY = "numeric_score"; - public $key = self::KEY; - public $name = "Post Scores (Numeric)"; - public $url = self::SHIMMIE_URL; - public $authors = self::SHISH_AUTHOR; - public $license = self::LICENSE_GPLV2; - public $description = "Allow users to score images"; - public $documentation ="Each registered user may vote a post +1 or -1, the image's score is the sum of all votes."; + public string $key = self::KEY; + public string $name = "Post Scores (Numeric)"; + public string $url = self::SHIMMIE_URL; + public array $authors = self::SHISH_AUTHOR; + public string $license = self::LICENSE_GPLV2; + public string $description = "Allow users to score images"; + public ?string $documentation ="Each registered user may vote a post +1 or -1, the image's score is the sum of all votes."; } diff --git a/ext/numeric_score/main.php b/ext/numeric_score/main.php index 2fda09e5..3a6a553f 100644 --- a/ext/numeric_score/main.php +++ b/ext/numeric_score/main.php @@ -2,9 +2,9 @@ class NumericScoreSetEvent extends Event { - public $image_id; - public $user; - public $score; + public int $image_id; + public User $user; + public int $score; public function __construct(int $image_id, User $user, int $score) { @@ -18,7 +18,7 @@ class NumericScoreSetEvent extends Event class NumericScore extends Extension { /** @var NumericScoreTheme */ - protected $theme; + protected ?Themelet $theme; public function onDisplayingImage(DisplayingImageEvent $event) { diff --git a/ext/numeric_score/theme.php b/ext/numeric_score/theme.php index 71551523..c79e7617 100644 --- a/ext/numeric_score/theme.php +++ b/ext/numeric_score/theme.php @@ -94,7 +94,7 @@ class NumericScoreTheme extends Themelet } - public function get_help_html() + public function get_help_html(): string { return '

    Search for posts that have received numeric scores by the score or by the scorer.

    diff --git a/ext/ouroboros_api/info.php b/ext/ouroboros_api/info.php index 9ff2b872..f17b3094 100644 --- a/ext/ouroboros_api/info.php +++ b/ext/ouroboros_api/info.php @@ -4,12 +4,12 @@ class OuroborosAPIInfo extends ExtensionInfo { public const KEY = "ouroboros_api"; - public $key = self::KEY; - public $name = "Ouroboros API"; - public $authors = ["Diftraku"=>"diftraku[at]derpy.me"]; - public $description = "Ouroboros-like API for Shimmie"; - public $version = "0.2"; - public $documentation = + public string $key = self::KEY; + public string $name = "Ouroboros API"; + public array $authors = ["Diftraku"=>"diftraku[at]derpy.me"]; + public string $description = "Ouroboros-like API for Shimmie"; + public ?string $version = "0.2"; + public ?string $documentation = "Currently working features
    • Post: diff --git a/ext/ouroboros_api/main.php b/ext/ouroboros_api/main.php index cd12affd..710d8cd4 100644 --- a/ext/ouroboros_api/main.php +++ b/ext/ouroboros_api/main.php @@ -6,162 +6,45 @@ class _SafeOuroborosImage /** * Author */ - - /** - * Post author - * @var string - */ - public $author = ''; - /** - * Post author user ID - * @var integer - */ - public $creator_id = null; - - /** - * Image - */ - - /** - * Image height - * @var integer - */ - public $height = null; - /** - * Image width - * @var integer - */ - public $width = null; - /** - * File extension - * @var string - */ - public $file_ext = ''; - /** - * File Size in bytes - * @var integer - */ - public $file_size = null; - /** - * URL to the static file - * @var string - */ - public $file_url = ''; - /** - * File MD5 hash - * @var string - */ - public $md5 = ''; + public string $author = ''; + public ?int $creator_id = null; + public ?int $height = null; + public ?int $width = null; + public string $file_ext = ''; + public ?int $file_size = null; + public string $file_url = ''; + public string $md5 = ''; /** * Post Meta */ - - /** - * (Unknown) Change - * @var integer - */ - public $change = null; - /** - * Timestamp for post creation - * @var integer - */ - public $created_at = null; - /** - * Post ID - * @var integer - */ - public $id = null; - /** - * Parent post ID - * @var integer - */ - public $parent_id = null; - /** - * Post content rating - * @var string - */ - public $rating = 'q'; - /** - * Post score - * @var integer - */ - public $score = 1; - /** - * Post source - * @var string - */ - public $source = ''; - /** - * Post status - * @var string - */ - public $status = ''; - /** - * Post tags - * @var string - */ - public $tags = 'tagme'; - /** - * Flag if the post has child posts - * @var bool - */ - public $has_children = false; - /** - * Flag if the post has comments - * @var bool - */ - public $has_comments = false; - /** - * Flag if the post has notes - * @var bool - */ - public $has_notes = false; - /** - * Post description - * @var string - */ - public $description = ''; + public ?int $change = null; + public ?array $created_at = null; + public ?int $id = null; + public ?int $parent_id = null; + public string $rating = 'q'; + public int $score = 1; + public ?string $source = ''; + public string $status = ''; + public string $tags = 'tagme'; + public bool $has_children = false; + public bool $has_comments = false; + public bool $has_notes = false; + public string $description = ''; /** * Thumbnail */ - - /** - * Thumbnail Height - * @var integer - */ - public $preview_height = null; - /** - * Thumbnail URL - * @var string - */ - public $preview_url = ''; - /** - * Thumbnail Width - * @var integer - */ - public $preview_width = null; + public ?int $preview_height = null; + public string $preview_url = ''; + public ?int $preview_width = null; /** * Downscaled Image */ - - /** - * Downscaled image height - * @var integer - */ - public $sample_height = null; - /** - * Downscaled image - * @var string - */ - public $sample_url = ''; - /** - * Downscaled image - * @var integer - */ - public $sample_width = null; + public ?int $sample_height = null; + public string $sample_url = ''; + public ?int $sample_width = null; public function __construct(Image $img) { @@ -217,24 +100,9 @@ class _SafeOuroborosImage class OuroborosPost extends _SafeOuroborosImage { - /** - * Multipart File - * @var array - */ - public $file = []; - - /** - * Create with rating locked - * @var bool - */ - public $is_rating_locked = false; - - /** - * Create with notes locked - * @var bool - */ - public $is_note_locked = false; - + public array $file = []; + public bool $is_rating_locked = false; + public bool $is_note_locked = false; /** * Initialize an OuroborosPost for creation @@ -310,11 +178,11 @@ class OuroborosPost extends _SafeOuroborosImage class _SafeOuroborosTag { - public $ambiguous = false; - public $count = 0; - public $id = 0; - public $name = ''; - public $type = 0; + public bool $ambiguous = false; + public int $count = 0; + public int $id = 0; + public string $name = ''; + public int $type = 0; public function __construct(array $tag) { @@ -326,8 +194,8 @@ class _SafeOuroborosTag class OuroborosAPI extends Extension { - private $event; - private $type; + private ?PageRequestEvent $event; + private ?string $type; const HEADER_HTTP_200 = 'OK'; const MSG_HTTP_200 = 'Request was successful'; @@ -701,7 +569,7 @@ class OuroborosAPI extends Extension $page->set_data($response); } - private function createItemXML(XMLWriter &$xml, string $type, $item) + private function createItemXML(XMLWriter $xml, string $type, $item) { $xml->startElement($type); foreach ($item as $key => $val) { diff --git a/ext/pm/info.php b/ext/pm/info.php index 79b83204..fa23153d 100644 --- a/ext/pm/info.php +++ b/ext/pm/info.php @@ -4,13 +4,13 @@ class PrivMsgInfo extends ExtensionInfo { public const KEY = "pm"; - public $key = self::KEY; - public $name = "Private Messaging"; - public $url = self::SHIMMIE_URL; - public $authors = self::SHISH_AUTHOR; - public $license = self::LICENSE_GPLV2; - public $description = "Allow users to send messages to eachother"; - public $documentation = + public string $key = self::KEY; + public string $name = "Private Messaging"; + public string $url = self::SHIMMIE_URL; + public array $authors = self::SHISH_AUTHOR; + public string $license = self::LICENSE_GPLV2; + public string $description = "Allow users to send messages to eachother"; + public ?string $documentation = "PMs show up on a user's profile page, readable by that user as well as board admins. To send a PM, visit another user's profile page and a box will be shown."; diff --git a/ext/pm/main.php b/ext/pm/main.php index 2d0ba333..613c6f6f 100644 --- a/ext/pm/main.php +++ b/ext/pm/main.php @@ -2,7 +2,7 @@ class SendPMEvent extends Event { - public $pm; + public PM $pm; public function __construct(PM $pm) { @@ -13,22 +13,15 @@ class SendPMEvent extends Event class PM { - /** @var int */ - public $id; - /** @var int */ - public $from_id; - /** @var string */ - public $from_ip; - /** @var int */ - public $to_id; + public int $id; + public int $from_id; + public string $from_ip; + public int $to_id; /** @var mixed */ public $sent_date; - /** @var string */ - public $subject; - /** @var string */ - public $message; - /** @var bool */ - public $is_read; + public string $subject; + public string $message; + public bool $is_read; public function __construct($from_id=0, string $from_ip="0.0.0.0", int $to_id=0, string $subject="A Message", string $message="Some Text", bool $read=false) { @@ -58,7 +51,7 @@ class PM class PrivMsg extends Extension { /** @var PrivMsgTheme */ - protected $theme; + protected ?Themelet $theme; public function onDatabaseUpgrade(DatabaseUpgradeEvent $event) { @@ -212,7 +205,7 @@ class PrivMsg extends Extension } - private function get_pms(User $user) + private function get_pms(User $user): array { global $database; diff --git a/ext/pm_triggers/info.php b/ext/pm_triggers/info.php index 97ffec1d..c6cf5740 100644 --- a/ext/pm_triggers/info.php +++ b/ext/pm_triggers/info.php @@ -4,11 +4,11 @@ class PMTriggerInfo extends ExtensionInfo { public const KEY = "pm_triggers"; - public $key = self::KEY; - public $name = "PM triggers"; - public $url = self::SHIMMIE_URL; - public $authors = self::SHISH_AUTHOR; - public $license = self::LICENSE_GPLV2; - public $description = "Send PMs in response to certain events (eg post deletion)"; - public $beta = true; + public string $key = self::KEY; + public string $name = "PM triggers"; + public string $url = self::SHIMMIE_URL; + public array $authors = self::SHISH_AUTHOR; + public string $license = self::LICENSE_GPLV2; + public string $description = "Send PMs in response to certain events (eg post deletion)"; + public bool $beta = true; } diff --git a/ext/pools/info.php b/ext/pools/info.php index ea812426..4e176dff 100644 --- a/ext/pools/info.php +++ b/ext/pools/info.php @@ -4,11 +4,11 @@ class PoolsInfo extends ExtensionInfo { public const KEY = "pools"; - public $key = self::KEY; - public $name = "Pools System"; - public $authors = ["Sein Kraft"=>"mail@seinkraft.info", "jgen"=>"jgen.tech@gmail.com", "Daku"=>"admin@codeanimu.net"]; - public $license = self::LICENSE_GPLV2; - public $description = "Allow users to create groups of images and order them."; - public $documentation = + public string $key = self::KEY; + public string $name = "Pools System"; + public array $authors = ["Sein Kraft"=>"mail@seinkraft.info", "jgen"=>"jgen.tech@gmail.com", "Daku"=>"admin@codeanimu.net"]; + public string $license = self::LICENSE_GPLV2; + public string $description = "Allow users to create groups of images and order them."; + public ?string $documentation = "This extension allows users to created named groups of images, and order the images within the group. Useful for related images like in a comic, etc."; } diff --git a/ext/pools/main.php b/ext/pools/main.php index c4d4366e..e6449f90 100644 --- a/ext/pools/main.php +++ b/ext/pools/main.php @@ -21,9 +21,8 @@ class PoolCreationException extends SCoreException class PoolAddPostsEvent extends Event { - public $pool_id; - - public $posts = []; + public int $pool_id; + public array $posts = []; public function __construct(int $pool_id, array $posts) { @@ -35,12 +34,11 @@ class PoolAddPostsEvent extends Event class PoolCreationEvent extends Event { - public $title; - public $user; - public $public; - public $description; - - public $new_id = -1; + public string $title; + public User $user; + public bool $public; + public string $description; + public int $new_id = -1; public function __construct( string $title, @@ -60,7 +58,7 @@ class PoolCreationEvent extends Event class PoolDeletionEvent extends Event { - public $pool_id; + public int $pool_id; public function __construct(int $pool_id) { @@ -71,14 +69,14 @@ class PoolDeletionEvent extends Event class Pool { - public $id; - public $user_id; - public $user_name; - public $public; - public $title; - public $description; - public $date; - public $posts; + public int $id; + public int $user_id; + public ?string $user_name; + public bool $public; + public string $title; + public string $description; + public string $date; + public int $posts; public function __construct(array $row) { @@ -106,7 +104,7 @@ function _image_to_id(Image $image): int class Pools extends Extension { /** @var PoolsTheme */ - protected $theme; + protected ?Themelet $theme; public function onInitExt(InitExtEvent $event) { diff --git a/ext/pools/test.php b/ext/pools/test.php index 5e574f27..94067c18 100644 --- a/ext/pools/test.php +++ b/ext/pools/test.php @@ -24,7 +24,7 @@ class PoolsTest extends ShimmiePHPUnitTestCase $this->assert_title("Error"); } - public function testCreate() + public function testCreate(): array { $this->log_in_as_user(); $image_id_1 = $this->post_image("tests/pbx_screenshot.jpg", "pbx"); @@ -111,7 +111,7 @@ class PoolsTest extends ShimmiePHPUnitTestCase } /** @depends testCreate */ - public function testRemovePosts($args) + public function testRemovePosts($args): array { [$pool_id, $image_ids] = $this->testCreate(); @@ -137,7 +137,7 @@ class PoolsTest extends ShimmiePHPUnitTestCase } /** @depends testCreate */ - public function testEditDescription($args) + public function testEditDescription($args): array { [$pool_id, $image_ids] = $this->testCreate(); diff --git a/ext/pools/theme.php b/ext/pools/theme.php index 6f5aea3b..97e2b4ef 100644 --- a/ext/pools/theme.php +++ b/ext/pools/theme.php @@ -380,7 +380,7 @@ class PoolsTheme extends Themelet $this->display_paginator($page, "pool/updated", null, $pageNumber, $totalPages); } - public function get_bulk_pool_selector(array $pools) + public function get_bulk_pool_selector(array $pools): string { $output = ""; } - public function get_bulk_pool_input(array $search_terms) + public function get_bulk_pool_input(array $search_terms): string { return ""; } - public function get_help_html() + public function get_help_html(): string { return '

      Search for posts that are in a pool.

      diff --git a/ext/post_peek/info.php b/ext/post_peek/info.php index 857f7b5c..f12a776c 100644 --- a/ext/post_peek/info.php +++ b/ext/post_peek/info.php @@ -4,9 +4,10 @@ class PostPeekInfo extends ExtensionInfo { public const KEY = "post_peek"; - public $key = self::KEY; - public $name = "Postt Peek"; - public $url = self::SHIMMIE_URL; - public $authors = ["Matthew Barbour"]; - public $license = self::LICENSE_WTFPL; + public string $key = self::KEY; + public string $name = "Post Peek"; + public string $url = self::SHIMMIE_URL; + public array $authors = ["Matthew Barbour"]; + public string $license = self::LICENSE_WTFPL; + public string $description = "Peek at posts"; } diff --git a/ext/post_titles/events/post_title_set_event.php b/ext/post_titles/events/post_title_set_event.php index 4aa3670c..b46f3dd6 100644 --- a/ext/post_titles/events/post_title_set_event.php +++ b/ext/post_titles/events/post_title_set_event.php @@ -2,10 +2,10 @@ class PostTitleSetEvent extends Event { - public $image; - public $title; + public Image $image; + public string $title; - public function __construct(Image $image, String $title) + public function __construct(Image $image, string $title) { parent::__construct(); $this->image = $image; diff --git a/ext/post_titles/info.php b/ext/post_titles/info.php index fcd4daa6..95567ef7 100644 --- a/ext/post_titles/info.php +++ b/ext/post_titles/info.php @@ -4,9 +4,9 @@ class PostTitlesInfo extends ExtensionInfo { public const KEY = "post_titles"; - public $key = self::KEY; - public $name = "Post Titles"; - public $authors = ["Matthew Barbour"=>"matthew@darkholme.net"]; - public $license = self::LICENSE_WTFPL; - public $description = "Add titles to media posts"; + public string $key = self::KEY; + public string $name = "Post Titles"; + public array $authors = ["Matthew Barbour"=>"matthew@darkholme.net"]; + public string $license = self::LICENSE_WTFPL; + public string $description = "Add titles to media posts"; } diff --git a/ext/post_titles/main.php b/ext/post_titles/main.php index d0e7aa9f..47cef813 100644 --- a/ext/post_titles/main.php +++ b/ext/post_titles/main.php @@ -6,7 +6,7 @@ require_once "events/post_title_set_event.php"; class PostTitles extends Extension { /** @var PostTitlesTheme */ - protected $theme; + protected ?Themelet $theme; public function get_priority(): int { diff --git a/ext/private_image/info.php b/ext/private_image/info.php index c46a8864..4e34931c 100644 --- a/ext/private_image/info.php +++ b/ext/private_image/info.php @@ -4,9 +4,9 @@ class PrivateImageInfo extends ExtensionInfo { public const KEY = "private_image"; - public $key = self::KEY; - public $name = "Private Post"; - public $authors = ["Matthew Barbour"=>"matthew@darkholme.net"]; - public $license = self::LICENSE_WTFPL; - public $description = "Allows users to mark images as private, which prevents other users from seeing them."; + public string $key = self::KEY; + public string $name = "Private Post"; + public array $authors = ["Matthew Barbour"=>"matthew@darkholme.net"]; + public string $license = self::LICENSE_WTFPL; + public string $description = "Allows users to mark images as private, which prevents other users from seeing them."; } diff --git a/ext/private_image/main.php b/ext/private_image/main.php index 08786317..90b97920 100644 --- a/ext/private_image/main.php +++ b/ext/private_image/main.php @@ -10,7 +10,7 @@ abstract class PrivateImageConfig class PrivateImage extends Extension { /** @var PrivateImageTheme */ - protected $theme; + protected ?Themelet $theme; public function onInitExt(InitExtEvent $event) { diff --git a/ext/private_image/theme.php b/ext/private_image/theme.php index dac0d9dd..5f249591 100644 --- a/ext/private_image/theme.php +++ b/ext/private_image/theme.php @@ -3,7 +3,7 @@ use function MicroHTML\INPUT; class PrivateImageTheme extends Themelet { - public function get_image_admin_html(Image $image) + public function get_image_admin_html(Image $image): string { if ($image->private===false) { $html = SHM_SIMPLE_FORM( @@ -22,8 +22,7 @@ class PrivateImageTheme extends Themelet return (string)$html; } - - public function get_help_html() + public function get_help_html(): string { return '

      Search for posts that are private/public.

      diff --git a/ext/qr_code/info.php b/ext/qr_code/info.php index 684f1531..17d01fad 100644 --- a/ext/qr_code/info.php +++ b/ext/qr_code/info.php @@ -4,13 +4,13 @@ class QRImageInfo extends ExtensionInfo { public const KEY = "qr_code"; - public $key = self::KEY; - public $name = "QR Codes"; - public $url = "http://seemslegit.com"; - public $authors = ["Zach Hall"=>"zach@sosguy.net"]; - public $license = self::LICENSE_GPLV2; - public $description = "Turns BBCode into HTML"; - public $documentation = + public string $key = self::KEY; + public string $name = "QR Codes"; + public string $url = "http://seemslegit.com"; + public array $authors = ["Zach Hall"=>"zach@sosguy.net"]; + public string $license = self::LICENSE_GPLV2; + public string $description = "Turns BBCode into HTML"; + public ?string $documentation = "Shows a QR Code for downloading a post to cell phones. Based on Artanis's Link to Post Extension Further modified by Shish to remove the 7MB local QR generator and replace it with a link to google chart APIs"; diff --git a/ext/qr_code/main.php b/ext/qr_code/main.php index 21dfb73b..ace2915d 100644 --- a/ext/qr_code/main.php +++ b/ext/qr_code/main.php @@ -3,7 +3,7 @@ class QRImage extends Extension { /** @var QRImageTheme */ - protected $theme; + protected ?Themelet $theme; public function onDisplayingImage(DisplayingImageEvent $event) { diff --git a/ext/random_image/info.php b/ext/random_image/info.php index bc6ac3a1..05c143b9 100644 --- a/ext/random_image/info.php +++ b/ext/random_image/info.php @@ -4,13 +4,13 @@ class RandomImageInfo extends ExtensionInfo { public const KEY = "random_image"; - public $key = self::KEY; - public $name = "Random Post"; - public $url = self::SHIMMIE_URL; - public $authors = self::SHISH_AUTHOR; - public $license = self::LICENSE_GPLV2; - public $description = "Do things with a random post"; - public $documentation = + public string $key = self::KEY; + public string $name = "Random Post"; + public string $url = self::SHIMMIE_URL; + public array $authors = self::SHISH_AUTHOR; + public string $license = self::LICENSE_GPLV2; + public string $description = "Do things with a random post"; + public ?string $documentation = "Viewing a random post
      Visit /random_image/view

      Downloading a random post diff --git a/ext/random_image/main.php b/ext/random_image/main.php index b9092f49..c87ec44a 100644 --- a/ext/random_image/main.php +++ b/ext/random_image/main.php @@ -3,7 +3,7 @@ class RandomImage extends Extension { /** @var RandomImageTheme */ - protected $theme; + protected ?Themelet $theme; public function onPageRequest(PageRequestEvent $event) { @@ -28,9 +28,7 @@ class RandomImage extends Extension } if ($action === "download") { - if (!is_null($image)) { - send_event(new ImageDownloadingEvent($image, $image->get_image_filename(), $image->get_mime())); - } + send_event(new ImageDownloadingEvent($image, $image->get_image_filename(), $image->get_mime())); } elseif ($action === "view") { send_event(new DisplayingImageEvent($image)); } elseif ($action === "widget") { diff --git a/ext/random_list/info.php b/ext/random_list/info.php index 76d9c161..04d02efc 100644 --- a/ext/random_list/info.php +++ b/ext/random_list/info.php @@ -4,13 +4,13 @@ class RandomListInfo extends ExtensionInfo { public const KEY = "random_list"; - public $key = self::KEY; - public $name = "Random List"; - public $url = "http://www.drudexsoftware.com"; - public $authors = ["Drudex Software"=>"support@drudexsoftware.com"]; - public $license = self::LICENSE_GPLV2; - public $description = "Allows displaying a page with random posts"; - public $documentation = + public string $key = self::KEY; + public string $name = "Random List"; + public string $url = "http://www.drudexsoftware.com"; + public array $authors = ["Drudex Software"=>"support@drudexsoftware.com"]; + public string $license = self::LICENSE_GPLV2; + public string $description = "Allows displaying a page with random posts"; + public ?string $documentation = "Random post list can be accessed through www.yoursite.com/random It is recommended that you create a link to this page so users know it exists."; } diff --git a/ext/random_list/main.php b/ext/random_list/main.php index 17d47267..a62d520f 100644 --- a/ext/random_list/main.php +++ b/ext/random_list/main.php @@ -3,7 +3,7 @@ class RandomList extends Extension { /** @var RandomListTheme */ - protected $theme; + protected ?Themelet $theme; public function onPageRequest(PageRequestEvent $event) { diff --git a/ext/random_list/theme.php b/ext/random_list/theme.php index cf45bb63..04ab4935 100644 --- a/ext/random_list/theme.php +++ b/ext/random_list/theme.php @@ -2,7 +2,7 @@ class RandomListTheme extends Themelet { - protected $search_terms; + protected array $search_terms; /** * #param string[] $search_terms diff --git a/ext/rating/info.php b/ext/rating/info.php index 39490b41..1b9b3c09 100644 --- a/ext/rating/info.php +++ b/ext/rating/info.php @@ -4,13 +4,13 @@ class RatingsInfo extends ExtensionInfo { public const KEY = "rating"; - public $key = self::KEY; - public $name = "Post Ratings"; - public $url = self::SHIMMIE_URL; - public $authors = self::SHISH_AUTHOR; - public $license = self::LICENSE_GPLV2; - public $description = "Allow users to rate images \"safe\", \"questionable\" or \"explicit\""; - public $documentation = + public string $key = self::KEY; + public string $name = "Post Ratings"; + public string $url = self::SHIMMIE_URL; + public array $authors = self::SHISH_AUTHOR; + public string $license = self::LICENSE_GPLV2; + public string $description = "Allow users to rate images \"safe\", \"questionable\" or \"explicit\""; + public ?string $documentation = "This shimmie extension provides filter:

      • rating = (safe|questionable|explicit|unknown) diff --git a/ext/rating/main.php b/ext/rating/main.php index 42ed72d6..a3b63d44 100644 --- a/ext/rating/main.php +++ b/ext/rating/main.php @@ -8,17 +8,10 @@ $_shm_ratings = []; class ImageRating { - /** @var string */ - public $name = null; - - /** @var string */ - public $code = null; - - /** @var string */ - public $search_term = null; - - /** @var int */ - public $order = 0; + public string $name; + public string $code; + public string $search_term; + public int $order = 0; public function __construct(string $code, string $name, string $search_term, int $order) { @@ -63,10 +56,8 @@ add_rating(new ImageRating("e", "Explicit", "explicit", 1000)); class RatingSetEvent extends Event { - /** @var Image */ - public $image; - /** @var string */ - public $rating; + public Image $image; + public string $rating; public function __construct(Image $image, string $rating) { @@ -89,11 +80,11 @@ abstract class RatingsConfig class Ratings extends Extension { /** @var RatingsTheme */ - protected $theme; + protected ?Themelet $theme; public const UNRATED_KEYWORDS = ["unknown", "unrated"]; - private $search_regexp; + private string $search_regexp; public function onInitExt(InitExtEvent $event) { @@ -263,7 +254,7 @@ class Ratings extends Extension $matches = []; if (is_null($event->term) && $this->no_rating_query($event->context)) { - $set = Ratings::privs_to_sql(Ratings::get_user_default_ratings($user)); + $set = Ratings::privs_to_sql(Ratings::get_user_default_ratings()); $event->add_querylet(new Querylet("rating IN ($set)")); } @@ -390,7 +381,7 @@ class Ratings extends Extension public function onPageRequest(PageRequestEvent $event) { - global $user, $page, $user_config; + global $user, $page; if ($event->page_matches("admin/bulk_rate")) { if (!$user->can(Permissions::BULK_EDIT_IMAGE_RATING)) { diff --git a/ext/rating/theme.php b/ext/rating/theme.php index 7ff8393e..f2f6dc5d 100644 --- a/ext/rating/theme.php +++ b/ext/rating/theme.php @@ -43,7 +43,7 @@ class RatingsTheme extends Themelet $page->add_block(new Block("Update Ratings", $html)); } - public function get_selection_rater_html(array $selected_options, bool $multiple = false, array $available_options = null) + public function get_selection_rater_html(array $selected_options, bool $multiple = false, array $available_options = null): string { $output = ""; } - public function get_help_html(array $ratings) + public function get_help_html(array $ratings): string { $output = '

        Search for posts with one or more possible ratings.

        diff --git a/ext/regen_thumb/info.php b/ext/regen_thumb/info.php index b4736aea..b7e4fd0f 100644 --- a/ext/regen_thumb/info.php +++ b/ext/regen_thumb/info.php @@ -4,13 +4,13 @@ class RegenThumbInfo extends ExtensionInfo { public const KEY = "regen_thumb"; - public $key = self::KEY; - public $name = "Regen Thumb"; - public $url = self::SHIMMIE_URL; - public $authors = self::SHISH_AUTHOR; - public $license = self::LICENSE_GPLV2; - public $description = "Regenerate a thumbnail image"; - public $documentation = + public string $key = self::KEY; + public string $name = "Regen Thumb"; + public string $url = self::SHIMMIE_URL; + public array $authors = self::SHISH_AUTHOR; + public string $license = self::LICENSE_GPLV2; + public string $description = "Regenerate a thumbnail image"; + public ?string $documentation = "This adds a button in the post control section on a post's view page, which allows an admin to regenerate a post's thumbnail; useful for instance if the first attempt failed due to lack of memory, and memory has since been increased."; diff --git a/ext/regen_thumb/main.php b/ext/regen_thumb/main.php index 79e90469..969acd73 100644 --- a/ext/regen_thumb/main.php +++ b/ext/regen_thumb/main.php @@ -4,7 +4,7 @@ class RegenThumb extends Extension { /** @var RegenThumbTheme */ - protected $theme; + protected ?Themelet $theme; public function regenerate_thumbnail(Image $image, bool $force = true): bool { @@ -160,7 +160,7 @@ class RegenThumb extends Extension } } - public function get_images(String $mime = null) + public function get_images(string $mime = null): array { global $database; diff --git a/ext/regen_thumb/theme.php b/ext/regen_thumb/theme.php index 97e0a044..1514e815 100644 --- a/ext/regen_thumb/theme.php +++ b/ext/regen_thumb/theme.php @@ -27,12 +27,12 @@ class RegenThumbTheme extends Themelet $page->add_block(new Block("Thumbnail", $this->build_thumb_html($image))); } - public function bulk_html() + public function bulk_html(): string { return ""; } - public function display_admin_block() + public function display_admin_block(): void { global $page, $database; diff --git a/ext/relationships/info.php b/ext/relationships/info.php index 541cc563..11d5f366 100644 --- a/ext/relationships/info.php +++ b/ext/relationships/info.php @@ -4,9 +4,9 @@ class RelationshipsInfo extends ExtensionInfo { public const KEY = "relationships"; - public $key = self::KEY; - public $name = "Post Relationships"; - public $authors = ["Angus Johnston"=>"admin@codeanimu.net"]; - public $license = self::LICENSE_GPLV2; - public $description = "Allow posts to have relationships (parent/child)."; + public string $key = self::KEY; + public string $name = "Post Relationships"; + public array $authors = ["Angus Johnston"=>"admin@codeanimu.net"]; + public string $license = self::LICENSE_GPLV2; + public string $description = "Allow posts to have relationships (parent/child)."; } diff --git a/ext/relationships/main.php b/ext/relationships/main.php index 9a89d5f3..a726ed27 100644 --- a/ext/relationships/main.php +++ b/ext/relationships/main.php @@ -2,8 +2,8 @@ class ImageRelationshipSetEvent extends Event { - public $child_id; - public $parent_id; + public int $child_id; + public int $parent_id; public function __construct(int $child_id, int $parent_id) { @@ -17,7 +17,7 @@ class ImageRelationshipSetEvent extends Event class Relationships extends Extension { /** @var RelationshipsTheme */ - protected $theme; + protected ?Themelet $theme; public const NAME = "Relationships"; diff --git a/ext/relationships/test.php b/ext/relationships/test.php index 8899651d..3db813b0 100644 --- a/ext/relationships/test.php +++ b/ext/relationships/test.php @@ -5,7 +5,7 @@ class RelationshipsTest extends ShimmiePHPUnitTestCase // Set by box //================================================================= - public function testNoParent() + public function testNoParent(): array { $this->log_in_as_user(); @@ -30,7 +30,7 @@ class RelationshipsTest extends ShimmiePHPUnitTestCase /** * @depends testNoParent */ - public function testSetParent($imgs) + public function testSetParent($imgs): array { [$image_1, $image_2, $image_3] = $this->testNoParent(); @@ -54,7 +54,7 @@ class RelationshipsTest extends ShimmiePHPUnitTestCase /** * @depends testSetParent */ - public function testChangeParent($imgs) + public function testChangeParent($imgs): array { [$image_1, $image_2, $image_3] = $this->testSetParent(null); send_event(new ImageRelationshipSetEvent($image_2->id, $image_3->id)); @@ -120,7 +120,7 @@ class RelationshipsTest extends ShimmiePHPUnitTestCase // Set by tag //================================================================= - public function testSetParentByTagBase() + public function testSetParentByTagBase(): array { $this->log_in_as_user(); $image_id_1 = $this->post_image("tests/pbx_screenshot.jpg", "pbx"); @@ -144,7 +144,7 @@ class RelationshipsTest extends ShimmiePHPUnitTestCase /** * @depends testSetParentByTagBase */ - public function testSetParentByTag($imgs) + public function testSetParentByTag($imgs): array { [$image_1, $image_2, $image_3] = $this->testSetParentByTagBase(); @@ -169,7 +169,7 @@ class RelationshipsTest extends ShimmiePHPUnitTestCase /** * @depends testSetParentByTag */ - public function testSetChildByTag($imgs) + public function testSetChildByTag($imgs): array { [$image_1, $image_2, $image_3] = $this->testSetParentByTag(null); diff --git a/ext/relationships/theme.php b/ext/relationships/theme.php index 8cbe1ab3..e37e22cb 100644 --- a/ext/relationships/theme.php +++ b/ext/relationships/theme.php @@ -48,7 +48,7 @@ class RelationshipsTheme extends Themelet } - public function get_help_html() + public function get_help_html(): string { return '

        Search for posts that have parent/child relationships.

        diff --git a/ext/report_image/info.php b/ext/report_image/info.php index 54771baa..48675dd1 100644 --- a/ext/report_image/info.php +++ b/ext/report_image/info.php @@ -4,11 +4,11 @@ class ReportImageInfo extends ExtensionInfo { public const KEY = "report_image"; - public $key = self::KEY; - public $name = "Report Posts"; - public $url = "http://atravelinggeek.com/"; - public $authors = ["ATravelingGeek"=>"atg@atravelinggeek.com"]; - public $license = self::LICENSE_GPLV2; - public $description = "Report posts as dupes/illegal/etc"; - public $version = "0.3a"; + public string $key = self::KEY; + public string $name = "Report Posts"; + public string $url = "http://atravelinggeek.com/"; + public array $authors = ["ATravelingGeek"=>"atg@atravelinggeek.com"]; + public string $license = self::LICENSE_GPLV2; + public string $description = "Report posts as dupes/illegal/etc"; + public ?string $version = "0.3a"; } diff --git a/ext/report_image/main.php b/ext/report_image/main.php index e1547706..98d856bc 100644 --- a/ext/report_image/main.php +++ b/ext/report_image/main.php @@ -2,8 +2,7 @@ class RemoveReportedImageEvent extends Event { - /** @var int */ - public $id; + public int $id; public function __construct(int $id) { @@ -14,8 +13,7 @@ class RemoveReportedImageEvent extends Event class AddReportedImageEvent extends Event { - /** @var ImageReport */ - public $report; + public ImageReport $report; public function __construct(ImageReport $report) { @@ -26,12 +24,9 @@ class AddReportedImageEvent extends Event class ImageReport { - /** @var int */ - public $user_id; - /** @var int */ - public $image_id; - /** @var string */ - public $reason; + public int $user_id; + public int $image_id; + public string $reason; public function __construct(int $image_id, int $user_id, string $reason) { @@ -44,7 +39,7 @@ class ImageReport class ReportImage extends Extension { /** @var ReportImageTheme */ - protected $theme; + protected ?Themelet $theme; public function onPageRequest(PageRequestEvent $event) { diff --git a/ext/res_limit/info.php b/ext/res_limit/info.php index b53bcf38..259c5344 100644 --- a/ext/res_limit/info.php +++ b/ext/res_limit/info.php @@ -4,10 +4,10 @@ class ResolutionLimitInfo extends ExtensionInfo { public const KEY = "res_limit"; - public $key = self::KEY; - public $name = "Resolution Limiter"; - public $url = self::SHIMMIE_URL; - public $authors = self::SHISH_AUTHOR; - public $license = self::LICENSE_GPLV2; - public $description = "Allows the admin to set min / max image dimensions"; + public string $key = self::KEY; + public string $name = "Resolution Limiter"; + public string $url = self::SHIMMIE_URL; + public array $authors = self::SHISH_AUTHOR; + public string $license = self::LICENSE_GPLV2; + public string $description = "Allows the admin to set min / max image dimensions"; } diff --git a/ext/resize/info.php b/ext/resize/info.php index 477d79ca..f6074d3c 100644 --- a/ext/resize/info.php +++ b/ext/resize/info.php @@ -10,10 +10,10 @@ class ResizeImageInfo extends ExtensionInfo { public const KEY = "resize"; - public $key = self::KEY; - public $name = "Resize Post"; - public $authors = ["jgen"=>"jgen.tech@gmail.com"]; - public $license = self::LICENSE_GPLV2; - public $description = "This extension allows admins to resize images."; - public $version = "0.1"; + public string $key = self::KEY; + public string $name = "Resize Post"; + public array $authors = ["jgen"=>"jgen.tech@gmail.com"]; + public string $license = self::LICENSE_GPLV2; + public string $description = "This extension allows admins to resize images."; + public ?string $version = "0.1"; } diff --git a/ext/resize/main.php b/ext/resize/main.php index f3a7af4c..f146b20e 100644 --- a/ext/resize/main.php +++ b/ext/resize/main.php @@ -16,7 +16,7 @@ abstract class ResizeConfig class ResizeImage extends Extension { /** @var ResizeImageTheme */ - protected $theme; + protected ?Themelet $theme; /** * Needs to be after the data processing extensions diff --git a/ext/resize/theme.php b/ext/resize/theme.php index f0827b8f..b7c0045f 100644 --- a/ext/resize/theme.php +++ b/ext/resize/theme.php @@ -5,7 +5,7 @@ class ResizeImageTheme extends Themelet /* * Display a link to resize an image */ - public function get_resize_html(Image $image) + public function get_resize_html(Image $image): string { global $config; @@ -18,7 +18,7 @@ class ResizeImageTheme extends Themelet if (!$default_height) { $default_height = $image->height; } - + $html = " ".make_form(make_link("resize/{$image->id}"), 'POST')." @@ -30,10 +30,10 @@ class ResizeImageTheme extends Themelet
        "; - + return $html; } - + public function display_resize_error(Page $page, string $title, string $message) { $page->set_title("Resize Image"); diff --git a/ext/rotate/info.php b/ext/rotate/info.php index adcff77e..6a815834 100644 --- a/ext/rotate/info.php +++ b/ext/rotate/info.php @@ -10,9 +10,9 @@ class RotateImageInfo extends ExtensionInfo { public const KEY = "rotate"; - public $key = self::KEY; - public $name = "Rotate Image"; - public $authors = ["jgen"=>"jgen.tech@gmail.com","Agasa"=>"hiroshiagasa@gmail.com"]; - public $license = self::LICENSE_GPLV2; - public $description = "Allows admins to rotate images."; + public string $key = self::KEY; + public string $name = "Rotate Image"; + public array $authors = ["jgen"=>"jgen.tech@gmail.com","Agasa"=>"hiroshiagasa@gmail.com"]; + public string $license = self::LICENSE_GPLV2; + public string $description = "Allows admins to rotate images."; } diff --git a/ext/rotate/main.php b/ext/rotate/main.php index c0b3d8a6..69306d31 100644 --- a/ext/rotate/main.php +++ b/ext/rotate/main.php @@ -15,7 +15,7 @@ class ImageRotateException extends SCoreException class RotateImage extends Extension { /** @var RotateImageTheme */ - protected $theme; + protected ?Themelet $theme; const SUPPORTED_MIME = [MimeType::JPEG, MimeType::PNG, MimeType::GIF, MimeType::WEBP]; diff --git a/ext/rss_comments/info.php b/ext/rss_comments/info.php index 68697673..a79c5a8a 100644 --- a/ext/rss_comments/info.php +++ b/ext/rss_comments/info.php @@ -4,10 +4,10 @@ class RSSCommentsInfo extends ExtensionInfo { public const KEY = "rss_comments"; - public $key = self::KEY; - public $name = "RSS for Comments"; - public $url = self::SHIMMIE_URL; - public $authors = self::SHISH_AUTHOR; - public $license = self::LICENSE_GPLV2; - public $description = "Self explanatory"; + public string $key = self::KEY; + public string $name = "RSS for Comments"; + public string $url = self::SHIMMIE_URL; + public array $authors = self::SHISH_AUTHOR; + public string $license = self::LICENSE_GPLV2; + public string $description = "Self explanatory"; } diff --git a/ext/rss_images/info.php b/ext/rss_images/info.php index 11af74cc..fb90bedb 100644 --- a/ext/rss_images/info.php +++ b/ext/rss_images/info.php @@ -4,10 +4,10 @@ class RSSImagesInfo extends ExtensionInfo { public const KEY = "rss_images"; - public $key = self::KEY; - public $name = "RSS for Posts"; - public $url = self::SHIMMIE_URL; - public $authors = self::SHISH_AUTHOR; - public $license = self::LICENSE_GPLV2; - public $description = "Self explanatory"; + public string $key = self::KEY; + public string $name = "RSS for Posts"; + public string $url = self::SHIMMIE_URL; + public array $authors = self::SHISH_AUTHOR; + public string $license = self::LICENSE_GPLV2; + public string $description = "Self explanatory"; } diff --git a/ext/rule34/info.php b/ext/rule34/info.php index fb95d9d6..6dabd3c4 100644 --- a/ext/rule34/info.php +++ b/ext/rule34/info.php @@ -4,13 +4,13 @@ class Rule34Info extends ExtensionInfo { public const KEY = "rule34"; - public $key = self::KEY; - public $name = "Rule34 Customisations"; - public $url = self::SHIMMIE_URL; - public $authors = self::SHISH_AUTHOR; - public $license = self::LICENSE_GPLV2; - public $description = "Extra site-specific bits"; - public $documentation = + public string $key = self::KEY; + public string $name = "Rule34 Customisations"; + public string $url = self::SHIMMIE_URL; + public array $authors = self::SHISH_AUTHOR; + public string $license = self::LICENSE_GPLV2; + public string $description = "Extra site-specific bits"; + public ?string $documentation = "Probably not much use to other sites, but it gives a few examples of how a shimmie-based site can be integrated with other systems"; - public $db_support = [DatabaseDriver::PGSQL]; # Only PG has the NOTIFY pubsub system + public array $db_support = [DatabaseDriver::PGSQL]; # Only PG has the NOTIFY pubsub system } diff --git a/ext/rule34/main.php b/ext/rule34/main.php index c6163151..860bff65 100644 --- a/ext/rule34/main.php +++ b/ext/rule34/main.php @@ -16,7 +16,7 @@ if ( // kill these glitched requests immediately class Rule34 extends Extension { /** @var Rule34Theme */ - protected $theme; + protected ?Themelet $theme; public function onImageDeletion(ImageDeletionEvent $event) { @@ -69,10 +69,10 @@ class Rule34 extends Extension public function onThumbnailGeneration(ThumbnailGenerationEvent $event) { - global $database, $user; - if ($user->can(Permissions::MANAGE_ADMINTOOLS)) { - #$database->notify("shm_image_bans", $event->hash); - } + # global $database, $user; + # if ($user->can(Permissions::MANAGE_ADMINTOOLS)) { + # $database->notify("shm_image_bans", $event->hash); + # } } public function onCommand(CommandEvent $event) diff --git a/ext/setup/info.php b/ext/setup/info.php index 66303012..7007bc2d 100644 --- a/ext/setup/info.php +++ b/ext/setup/info.php @@ -4,11 +4,11 @@ class SetupInfo extends ExtensionInfo { public const KEY = "setup"; - public $key = self::KEY; - public $name = "Board Config"; - public $url = self::SHIMMIE_URL; - public $authors = self::SHISH_AUTHOR; - public $description = "Allows the site admin to configure the board to his or her taste"; - public $core = true; - public $visibility = self::VISIBLE_HIDDEN; + public string $key = self::KEY; + public string $name = "Board Config"; + public string $url = self::SHIMMIE_URL; + public array $authors = self::SHISH_AUTHOR; + public string $description = "Allows the site admin to configure the board to his or her taste"; + public bool $core = true; + public string $visibility = self::VISIBLE_HIDDEN; } diff --git a/ext/setup/main.php b/ext/setup/main.php index 305d71fd..0ad382b6 100644 --- a/ext/setup/main.php +++ b/ext/setup/main.php @@ -8,8 +8,7 @@ include_once "config.php"; */ class ConfigSaveEvent extends Event { - /** @var Config */ - public $config; + public Config $config; public function __construct(Config $config) { @@ -23,11 +22,8 @@ class ConfigSaveEvent extends Event */ class SetupBuildingEvent extends Event { - /** @var SetupTheme */ - protected $theme; - - /** @var SetupPanel */ - public $panel; + protected SetupTheme $theme; + public SetupPanel $panel; public function __construct(SetupPanel $panel) { @@ -39,9 +35,8 @@ class SetupBuildingEvent extends Event class SetupPanel { /** @var SetupBlock[] */ - public $blocks = []; - /** @var BaseConfig */ - public $config; + public array $blocks = []; + public BaseConfig $config; public function __construct(BaseConfig $config) { @@ -58,12 +53,9 @@ class SetupPanel class SetupBlock extends Block { - /** @var string */ - public $header; - /** @var string */ - public $body; - /** @var BaseConfig */ - public $config; + public ?string $header; + public ?string $body; + public BaseConfig $config; public function __construct(string $title, BaseConfig $config) { @@ -298,7 +290,7 @@ class SetupBlock extends Block class Setup extends Extension { /** @var SetupTheme */ - protected $theme; + protected ?Themelet $theme; public function onInitExt(InitExtEvent $event) { diff --git a/ext/setup/theme.php b/ext/setup/theme.php index 1c039c1a..f7e78d13 100644 --- a/ext/setup/theme.php +++ b/ext/setup/theme.php @@ -77,7 +77,7 @@ class SetupTheme extends Themelet $page->add_block(new Block("Setup", $table)); } - protected function build_navigation() + protected function build_navigation(): string { return " Index @@ -86,7 +86,7 @@ class SetupTheme extends Themelet "; } - protected function sb_to_html(SetupBlock $block) + protected function sb_to_html(SetupBlock $block): string { $h = $block->header; $b = $block->body; diff --git a/ext/shimmie_api/info.php b/ext/shimmie_api/info.php index 878a55de..ae609d1a 100644 --- a/ext/shimmie_api/info.php +++ b/ext/shimmie_api/info.php @@ -4,12 +4,12 @@ class ShimmieApiInfo extends ExtensionInfo { public const KEY = "shimmie_api"; - public $key = self::KEY; - public $name = "Shimmie JSON API"; - public $url = self::SHIMMIE_URL; - public $authors = self::SHISH_AUTHOR; - public $description = "A JSON interface to shimmie data [WARNING]"; - public $documentation = + public string $key = self::KEY; + public string $name = "Shimmie JSON API"; + public string $url = self::SHIMMIE_URL; + public array $authors = self::SHISH_AUTHOR; + public string $description = "A JSON interface to shimmie data [WARNING]"; + public ?string $documentation = "Admin Warning - this exposes private data, eg IP addresses

        Developer Warning - the API is unstable; notably, private data may get hidden

        Usage: diff --git a/ext/shimmie_api/main.php b/ext/shimmie_api/main.php index 5fd27052..c3d4dfe9 100644 --- a/ext/shimmie_api/main.php +++ b/ext/shimmie_api/main.php @@ -2,21 +2,23 @@ class _SafeImage { - public $id; - public $height; - public $width; - public $hash; - public $filesize; - public $ext; - public $mime; - public $posted; - public $source; - public $owner_id; - public $tags; + public int $id; + public int $height; + public int $width; + public string $hash; + public int $filesize; + public string $ext; + public ?string $mime; + public int $posted; + public ?string $source; + public int $owner_id; + public array $tags; public function __construct(Image $img) { - $this->id = $img->id; + $_id = $img->id; + assert($_id != null); + $this->id = $_id; $this->height = $img->height; $this->width = $img->width; $this->hash = $img->hash; diff --git a/ext/site_description/info.php b/ext/site_description/info.php index adca4371..0440cec8 100644 --- a/ext/site_description/info.php +++ b/ext/site_description/info.php @@ -4,13 +4,13 @@ class SiteDescriptionInfo extends ExtensionInfo { public const KEY = "site_description"; - public $key = self::KEY; - public $name = "Site Description"; - public $url = self::SHIMMIE_URL; - public $authors = self::SHISH_AUTHOR; - public $license = self::LICENSE_GPLV2; - public $visibility = self::VISIBLE_ADMIN; - public $description = "A description for search engines"; - public $documentation = + public string $key = self::KEY; + public string $name = "Site Description"; + public string $url = self::SHIMMIE_URL; + public array $authors = self::SHISH_AUTHOR; + public string $license = self::LICENSE_GPLV2; + public string $visibility = self::VISIBLE_ADMIN; + public string $description = "A description for search engines"; + public ?string $documentation = "This extension sets the \"description\" meta tag in the header of pages so that search engines can pick it up"; } diff --git a/ext/sitemap/info.php b/ext/sitemap/info.php index d230056f..a01139d1 100644 --- a/ext/sitemap/info.php +++ b/ext/sitemap/info.php @@ -4,10 +4,10 @@ class XMLSitemapInfo extends ExtensionInfo { public const KEY = "sitemap"; - public $key = self::KEY; - public $name = "XML Sitemap"; - public $url = "http://drudexsoftware.com"; - public $authors = ["Sein Kraft"=>"mail@seinkraft.info","Drudex Software"=>"support@drudexsoftware.com"]; - public $license = self::LICENSE_GPLV2; - public $description = "Sitemap with caching & advanced priorities"; + public string $key = self::KEY; + public string $name = "XML Sitemap"; + public string $url = "http://drudexsoftware.com"; + public array $authors = ["Sein Kraft"=>"mail@seinkraft.info","Drudex Software"=>"support@drudexsoftware.com"]; + public string $license = self::LICENSE_GPLV2; + public string $description = "Sitemap with caching & advanced priorities"; } diff --git a/ext/sitemap/main.php b/ext/sitemap/main.php index 3983ce82..b2670c34 100644 --- a/ext/sitemap/main.php +++ b/ext/sitemap/main.php @@ -3,8 +3,8 @@ class XMLSitemap extends Extension { - private $sitemap_queue = ""; - private $sitemap_filepath = ""; // set onPageRequest + private string $sitemap_queue = ""; + private string $sitemap_filepath = ""; // set onPageRequest public function onPageRequest(PageRequestEvent $event) { diff --git a/ext/source_history/info.php b/ext/source_history/info.php index 2bc0c764..b7a99b60 100644 --- a/ext/source_history/info.php +++ b/ext/source_history/info.php @@ -4,9 +4,9 @@ class SourceHistoryInfo extends ExtensionInfo { public const KEY = "source_history"; - public $key = self::KEY; - public $name = "Source History"; - public $url = self::SHIMMIE_URL; - public $authors = self::SHISH_AUTHOR; - public $description = "Keep a record of source changes, and allows you to revert changes."; + public string $key = self::KEY; + public string $name = "Source History"; + public string $url = self::SHIMMIE_URL; + public array $authors = self::SHISH_AUTHOR; + public string $description = "Keep a record of source changes, and allows you to revert changes."; } diff --git a/ext/source_history/main.php b/ext/source_history/main.php index 5bf2fac3..09b3a515 100644 --- a/ext/source_history/main.php +++ b/ext/source_history/main.php @@ -3,7 +3,7 @@ class SourceHistory extends Extension { /** @var SourceHistoryTheme */ - protected $theme; + protected ?Themelet $theme; // in before source are actually set, so that "get current source" works public function get_priority(): int diff --git a/ext/source_history/theme.php b/ext/source_history/theme.php index 1b9cac66..64f93122 100644 --- a/ext/source_history/theme.php +++ b/ext/source_history/theme.php @@ -7,7 +7,7 @@ use function MicroHTML\rawHTML; class SourceHistoryTheme extends Themelet { - private $messages = []; + private array $messages = []; public function display_history_page(Page $page, int $image_id, array $history) { @@ -69,7 +69,7 @@ class SourceHistoryTheme extends Themelet public function display_revert_ip_results() { global $page; - $html = implode($this->messages, "\n"); + $html = implode("\n", $this->messages); $page->add_block(new Block("Bulk Revert Results", $html)); } diff --git a/ext/static_files/info.php b/ext/static_files/info.php index e5b30427..c01be17d 100644 --- a/ext/static_files/info.php +++ b/ext/static_files/info.php @@ -4,12 +4,12 @@ class StaticFilesInfo extends ExtensionInfo { public const KEY = "static_files"; - public $key = self::KEY; - public $name = "Static File Handler"; - public $url = self::SHIMMIE_URL; - public $authors = self::SHISH_AUTHOR; - public $license = self::LICENSE_GPLV2; - public $visibility = self::VISIBLE_HIDDEN; - public $description = 'If Shimmie can\'t handle a request, check static files ($theme/static/$filename, then ext/static_files/static/$filename)'; - public $core = true; + public string $key = self::KEY; + public string $name = "Static File Handler"; + public string $url = self::SHIMMIE_URL; + public array $authors = self::SHISH_AUTHOR; + public string $license = self::LICENSE_GPLV2; + public string $visibility = self::VISIBLE_HIDDEN; + public string $description = 'If Shimmie can\'t handle a request, check static files ($theme/static/$filename, then ext/static_files/static/$filename)'; + public bool $core = true; } diff --git a/ext/static_files/main.php b/ext/static_files/main.php index 407cce0a..f8d68d40 100644 --- a/ext/static_files/main.php +++ b/ext/static_files/main.php @@ -27,7 +27,7 @@ class StaticFiles extends Extension } } - private function count_main($blocks) + private function count_main($blocks): int { $n = 0; foreach ($blocks as $block) { diff --git a/ext/statsd/info.php b/ext/statsd/info.php index 42463632..dce66d27 100644 --- a/ext/statsd/info.php +++ b/ext/statsd/info.php @@ -4,12 +4,12 @@ class StatsDInterfaceInfo extends ExtensionInfo { public const KEY = "statsd"; - public $key = self::KEY; - public $name = "StatsD Interface"; - public $url = self::SHIMMIE_URL; - public $authors = self::SHISH_AUTHOR; - public $license = self::LICENSE_GPLV2; - public $visibility = self::VISIBLE_ADMIN; - public $description = "Sends Shimmie stats to a StatsD server"; - public $documentation = "define('STATSD_HOST', 'my.server.com:8125'); in shimmie.conf.php to set the host"; + public string $key = self::KEY; + public string $name = "StatsD Interface"; + public string $url = self::SHIMMIE_URL; + public array $authors = self::SHISH_AUTHOR; + public string $license = self::LICENSE_GPLV2; + public string $visibility = self::VISIBLE_ADMIN; + public string $description = "Sends Shimmie stats to a StatsD server"; + public ?string $documentation = "define('STATSD_HOST', 'my.server.com:8125'); in shimmie.conf.php to set the host"; } diff --git a/ext/statsd/main.php b/ext/statsd/main.php index b0ecc06b..a7136161 100644 --- a/ext/statsd/main.php +++ b/ext/statsd/main.php @@ -9,7 +9,7 @@ function dstat($name, $val) class StatsDInterface extends Extension { - public static $stats = []; + public static array $stats = []; private function _stats(string $type) { diff --git a/ext/system/info.php b/ext/system/info.php index 721dc57f..da70d43f 100644 --- a/ext/system/info.php +++ b/ext/system/info.php @@ -4,11 +4,11 @@ class SystemInfo extends ExtensionInfo { public const KEY = "system"; - public $key = self::KEY; - public $name = "System"; - public $authors = ["Matthew Barbour"=>"matthew@darkholme.net"]; - public $license = self::LICENSE_WTFPL; - public $description = "Provides system screen"; - public $core = true; - public $visibility = self::VISIBLE_HIDDEN; + public string $key = self::KEY; + public string $name = "System"; + public array $authors = ["Matthew Barbour"=>"matthew@darkholme.net"]; + public string $license = self::LICENSE_WTFPL; + public string $description = "Provides system screen"; + public bool $core = true; + public string $visibility = self::VISIBLE_HIDDEN; } diff --git a/ext/tag_categories/info.php b/ext/tag_categories/info.php index 723e4386..6ba73f1f 100644 --- a/ext/tag_categories/info.php +++ b/ext/tag_categories/info.php @@ -4,9 +4,9 @@ class TagCategoriesInfo extends ExtensionInfo { public const KEY = "tag_categories"; - public $key = self::KEY; - public $name = "Tag Categories"; - public $url = "https://code.shishnet.org/shimmie2/"; - public $authors = ["Daniel Oaks"=>"danneh@danneh.net"]; - public $description = "Let tags be split into 'categories', like Danbooru's tagging"; + public string $key = self::KEY; + public string $name = "Tag Categories"; + public string $url = "https://code.shishnet.org/shimmie2/"; + public array $authors = ["Daniel Oaks"=>"danneh@danneh.net"]; + public string $description = "Let tags be split into 'categories', like Danbooru's tagging"; } diff --git a/ext/tag_categories/main.php b/ext/tag_categories/main.php index 55d58c81..c12771a7 100644 --- a/ext/tag_categories/main.php +++ b/ext/tag_categories/main.php @@ -6,7 +6,7 @@ require_once "config.php"; class TagCategories extends Extension { /** @var TagCategoriesTheme */ - protected $theme; + protected ?Themelet $theme; public function onInitExt(InitExtEvent $event) { @@ -106,13 +106,13 @@ class TagCategories extends Extension } } - public function getDict() + public function getDict(): array { global $database; return $database->get_all('SELECT * FROM image_tag_categories;'); } - public function getKeyedDict($key_with = 'category') + public function getKeyedDict($key_with = 'category'): array { $tc_dict = $this->getDict(); $tc_keyed_dict = []; @@ -125,7 +125,7 @@ class TagCategories extends Extension return $tc_keyed_dict; } - public function getTagHtml(string $h_tag, $tag_category_dict, string $extra_text = '') + public function getTagHtml(string $h_tag, $tag_category_dict, string $extra_text = ''): string { $h_tag_no_underscores = str_replace("_", " ", $h_tag); diff --git a/ext/tag_categories/theme.php b/ext/tag_categories/theme.php index 79d4f6a3..4dab33df 100644 --- a/ext/tag_categories/theme.php +++ b/ext/tag_categories/theme.php @@ -99,7 +99,7 @@ class TagCategoriesTheme extends Themelet $page->add_block(new Block("Editing", $html, "main", 10)); } - public function get_help_html() + public function get_help_html(): string { return '

        Search for posts containing a certain number of tags with the specified tag category.

        diff --git a/ext/tag_edit/info.php b/ext/tag_edit/info.php index c3396597..0207ba88 100644 --- a/ext/tag_edit/info.php +++ b/ext/tag_edit/info.php @@ -4,13 +4,13 @@ class TagEditInfo extends ExtensionInfo { public const KEY = "tag_edit"; - public $key = self::KEY; - public $name = "Tag Editor"; - public $core = true; - public $url = self::SHIMMIE_URL; - public $authors = self::SHISH_AUTHOR; - public $description = "Allow images to have tags assigned to them"; - public $documentation = + public string $key = self::KEY; + public string $name = "Tag Editor"; + public bool $core = true; + public string $url = self::SHIMMIE_URL; + public array $authors = self::SHISH_AUTHOR; + public string $description = "Allow images to have tags assigned to them"; + public ?string $documentation = " Here is a list of the tagging metatags available out of the box; Shimmie extensions may provide other metatags:
          diff --git a/ext/tag_edit/main.php b/ext/tag_edit/main.php index 4613c357..21ff0de2 100644 --- a/ext/tag_edit/main.php +++ b/ext/tag_edit/main.php @@ -8,10 +8,8 @@ */ class OwnerSetEvent extends Event { - /** @var Image */ - public $image; - /** @var User */ - public $owner; + public Image $image; + public User $owner; public function __construct(Image $image, User $owner) { @@ -24,10 +22,8 @@ class OwnerSetEvent extends Event class SourceSetEvent extends Event { - /** @var Image */ - public $image; - /** @var string */ - public $source; + public Image $image; + public ?string $source; public function __construct(Image $image, string $source=null) { @@ -40,7 +36,7 @@ class SourceSetEvent extends Event class TagSetException extends SCoreException { - public $redirect; + public ?string $redirect; public function __construct(string $msg, ?string $redirect = null) { @@ -51,10 +47,9 @@ class TagSetException extends SCoreException class TagSetEvent extends Event { - /** @var Image */ - public $image; - public $tags; - public $metatags; + public Image $image; + public array $tags; + public array $metatags; /** * #param string[] $tags @@ -90,10 +85,8 @@ class TagSetEvent extends Event class LockSetEvent extends Event { - /** @var Image */ - public $image; - /** @var bool */ - public $locked; + public Image $image; + public bool $locked; public function __construct(Image $image, bool $locked) { @@ -108,9 +101,8 @@ class LockSetEvent extends Event */ class TagTermCheckEvent extends Event { - public $term = null; //tag - /** @var bool */ - public $metatag = false; + public string $term; + public bool $metatag = false; public function __construct(string $term) { @@ -124,8 +116,8 @@ class TagTermCheckEvent extends Event */ class TagTermParseEvent extends Event { - public $term = null; - public $image_id = null; + public string $term; + public int $image_id; public function __construct(string $term, int $image_id) { @@ -138,7 +130,7 @@ class TagTermParseEvent extends Event class TagEdit extends Extension { /** @var TagEditTheme */ - protected $theme; + protected ?Themelet $theme; public function onPageRequest(PageRequestEvent $event) { diff --git a/ext/tag_editcloud/info.php b/ext/tag_editcloud/info.php index f19e336a..327705c6 100644 --- a/ext/tag_editcloud/info.php +++ b/ext/tag_editcloud/info.php @@ -4,8 +4,8 @@ class TagEditCloudInfo extends ExtensionInfo { public const KEY = "tag_editcloud"; - public $key = self::KEY; - public $name = "Tag EditCloud"; - public $authors = ["AtomicDryad", "LaureeGrd"]; - public $description = "Add or remove tags to the editor via clicking."; + public string $key = self::KEY; + public string $name = "Tag EditCloud"; + public array $authors = ["AtomicDryad", "LaureeGrd"]; + public string $description = "Add or remove tags to the editor via clicking."; } diff --git a/ext/tag_editcloud/main.php b/ext/tag_editcloud/main.php index 27e2f89c..c9b6dbdb 100644 --- a/ext/tag_editcloud/main.php +++ b/ext/tag_editcloud/main.php @@ -94,6 +94,7 @@ class TagEditCloud extends Extension ["tag_min1" => $tags_min, "tag_min2" => $tags_min, "limit" => $max_count, "relevant_tags"=>$relevant_tags] ); break; + /** @noinspection PhpMissingBreakStatementInspection */ case 'c': if (Extension::is_enabled(TagCategoriesInfo::KEY)) { $tag_data = $database->get_all( diff --git a/ext/tag_editcloud/script.js b/ext/tag_editcloud/script.js index 71a9c287..e700b74b 100644 --- a/ext/tag_editcloud/script.js +++ b/ext/tag_editcloud/script.js @@ -2,7 +2,7 @@ Array.prototype.editcloud_contains = function (ele) { for (var i = 0; i < this.length; i++) { - if (this[i] == ele) { + if (this[i] === ele) { return true; } } @@ -12,7 +12,7 @@ Array.prototype.editcloud_remove = function (ele) { var arr = []; var count = 0; for (var i = 0; i < this.length; i++) { - if (this[i] != ele) { + if (this[i] !== ele) { arr[count] = this[i]; count++; } diff --git a/ext/tag_history/info.php b/ext/tag_history/info.php index 68d8cab3..fafa3d9b 100644 --- a/ext/tag_history/info.php +++ b/ext/tag_history/info.php @@ -4,8 +4,8 @@ class TagHistoryInfo extends ExtensionInfo { public const KEY = "tag_history"; - public $key = self::KEY; - public $name = "Tag History"; - public $authors = ["Bzchan"=>"bzchan@animemahou.com","jgen"=>"jgen.tech@gmail.com"]; - public $description = "Keep a record of tag changes, and allows you to revert changes."; + public string $key = self::KEY; + public string $name = "Tag History"; + public array $authors = ["Bzchan"=>"bzchan@animemahou.com","jgen"=>"jgen.tech@gmail.com"]; + public string $description = "Keep a record of tag changes, and allows you to revert changes."; } diff --git a/ext/tag_history/main.php b/ext/tag_history/main.php index f99a7df9..352ebb4b 100644 --- a/ext/tag_history/main.php +++ b/ext/tag_history/main.php @@ -3,7 +3,7 @@ class TagHistory extends Extension { /** @var TagHistoryTheme */ - protected $theme; + protected ?Themelet $theme; // in before tags are actually set, so that "get current tags" works public function get_priority(): int diff --git a/ext/tag_history/theme.php b/ext/tag_history/theme.php index c6dc822d..3dacfb82 100644 --- a/ext/tag_history/theme.php +++ b/ext/tag_history/theme.php @@ -8,7 +8,7 @@ use function MicroHTML\rawHTML; class TagHistoryTheme extends Themelet { - private $messages = []; + private array $messages = []; public function display_history_page(Page $page, int $image_id, array $history) { @@ -70,7 +70,7 @@ class TagHistoryTheme extends Themelet public function display_revert_ip_results() { global $page; - $html = implode($this->messages, "\n"); + $html = implode("\n", $this->messages); $page->add_block(new Block("Bulk Revert Results", $html)); } diff --git a/ext/tag_list/info.php b/ext/tag_list/info.php index 1d19e94b..408cf84b 100644 --- a/ext/tag_list/info.php +++ b/ext/tag_list/info.php @@ -4,11 +4,11 @@ class TagListInfo extends ExtensionInfo { public const KEY = "tag_list"; - public $key = self::KEY; - public $name = "Tag List"; - public $url = self::SHIMMIE_URL; - public $authors = self::SHISH_AUTHOR; - public $description = "Show the tags in various ways"; - public $core = true; - public $visibility = self::VISIBLE_HIDDEN; + public string $key = self::KEY; + public string $name = "Tag List"; + public string $url = self::SHIMMIE_URL; + public array $authors = self::SHISH_AUTHOR; + public string $description = "Show the tags in various ways"; + public bool $core = true; + public string $visibility = self::VISIBLE_HIDDEN; } diff --git a/ext/tag_list/main.php b/ext/tag_list/main.php index 2b8a38bb..c5474f76 100644 --- a/ext/tag_list/main.php +++ b/ext/tag_list/main.php @@ -5,7 +5,7 @@ require_once "config.php"; class TagList extends Extension { /** @var TagListTheme */ - protected $theme; + protected ?Themelet $theme; public function onInitExt(InitExtEvent $event) { @@ -23,7 +23,7 @@ class TagList extends Extension public function onPageRequest(PageRequestEvent $event) { - global $cache, $page, $database; + global $page; if ($event->page_matches("tags")) { $this->theme->set_navigation($this->build_navigation()); diff --git a/ext/tag_list/test.php b/ext/tag_list/test.php index ad13e7ab..0fb64b76 100644 --- a/ext/tag_list/test.php +++ b/ext/tag_list/test.php @@ -1,7 +1,7 @@ add_block(new Block("refine Search", $main_html, "left", 60)); } - public function return_tag($row, $tag_category_dict) + public function return_tag(array $row, array $tag_category_dict): array { global $config; diff --git a/ext/tag_tools/info.php b/ext/tag_tools/info.php index 6b0ac75a..147bdfda 100644 --- a/ext/tag_tools/info.php +++ b/ext/tag_tools/info.php @@ -4,10 +4,10 @@ class TagToolsInfo extends ExtensionInfo { public const KEY = "tag_tools"; - public $key = self::KEY; - public $name = "Tag Tools"; - public $url = self::SHIMMIE_URL; - public $authors = self::SHISH_AUTHOR; - public $license = self::LICENSE_GPLV2; - public $description = "Recount / Rename / Etc"; + public string $key = self::KEY; + public string $name = "Tag Tools"; + public string $url = self::SHIMMIE_URL; + public array $authors = self::SHISH_AUTHOR; + public string $license = self::LICENSE_GPLV2; + public string $description = "Recount / Rename / Etc"; } diff --git a/ext/tag_tools/main.php b/ext/tag_tools/main.php index 42d2d381..46c00243 100644 --- a/ext/tag_tools/main.php +++ b/ext/tag_tools/main.php @@ -4,7 +4,7 @@ declare(strict_types=1); class TagTools extends Extension { /** @var TagToolsTheme */ - protected $theme; + protected ?Themelet $theme; public function onAdminBuilding(AdminBuildingEvent $event) { @@ -19,7 +19,7 @@ class TagTools extends Extension } } - private function set_tag_case() + private function set_tag_case(): bool { global $database; $database->execute( @@ -30,7 +30,7 @@ class TagTools extends Extension return true; } - private function lowercase_all_tags() + private function lowercase_all_tags(): bool { global $database; $database->execute("UPDATE tags SET tag=lower(tag)"); @@ -38,7 +38,7 @@ class TagTools extends Extension return true; } - private function recount_tag_use() + private function recount_tag_use(): bool { global $database; $database->execute(" diff --git a/ext/tagger_xml/info.php b/ext/tagger_xml/info.php index 7d2edd1f..8e41a1f4 100644 --- a/ext/tagger_xml/info.php +++ b/ext/tagger_xml/info.php @@ -4,9 +4,9 @@ class TaggerXMLInfo extends ExtensionInfo { public const KEY = "tagger_xml"; - public $key = self::KEY; - public $name = "Tagger AJAX backend"; - public $authors = ["Artanis (Erik Youngren)"=>"artanis.00@gmail.com"]; - public $visibility = self::VISIBLE_HIDDEN; - public $description = "Advanced Tagging v2 AJAX backend"; + public string $key = self::KEY; + public string $name = "Tagger AJAX backend"; + public array $authors = ["Artanis (Erik Youngren)"=>"artanis.00@gmail.com"]; + public string $visibility = self::VISIBLE_HIDDEN; + public string $description = "Advanced Tagging v2 AJAX backend"; } diff --git a/ext/tagger_xml/main.php b/ext/tagger_xml/main.php index add487bf..54033851 100644 --- a/ext/tagger_xml/main.php +++ b/ext/tagger_xml/main.php @@ -35,7 +35,7 @@ class TaggerXML extends Extension } } - private function match_tag_list(string $s) + private function match_tag_list(string $s): string { global $database, $config; @@ -83,7 +83,7 @@ class TaggerXML extends Extension return $this->list_to_xml($tags, "search", $s, $count); } - private function image_tag_list(int $image_id) + private function image_tag_list(int $image_id): string { global $database; $tags = $database->execute(" diff --git a/ext/tips/info.php b/ext/tips/info.php index c5b85708..bdbda34c 100644 --- a/ext/tips/info.php +++ b/ext/tips/info.php @@ -4,11 +4,11 @@ class TipsInfo extends ExtensionInfo { public const KEY = "tips"; - public $key = self::KEY; - public $name = "Random Tip"; - public $authors = ["Sein Kraft"=>"mail@seinkraft.info"]; - public $license = "GPLv2"; - public $description = "Show a random line of text in the subheader space"; - public $documentation = "Formatting is done with HTML"; - public $db_support = [DatabaseDriver::MYSQL, DatabaseDriver::SQLITE]; // rand() ? + public string $key = self::KEY; + public string $name = "Random Tip"; + public array $authors = ["Sein Kraft"=>"mail@seinkraft.info"]; + public string $license = "GPLv2"; + public string $description = "Show a random line of text in the subheader space"; + public ?string $documentation = "Formatting is done with HTML"; + public array $db_support = [DatabaseDriver::MYSQL, DatabaseDriver::SQLITE]; // rand() ? } diff --git a/ext/tips/main.php b/ext/tips/main.php index 0b6ca226..7ff12e47 100644 --- a/ext/tips/main.php +++ b/ext/tips/main.php @@ -2,9 +2,10 @@ class CreateTipEvent extends Event { - public $enable; - public $image; - public $text; + public bool $enable; + public string $image; + public string $text; + public function __construct(bool $enable, string $image, string $text) { parent::__construct(); @@ -16,7 +17,7 @@ class CreateTipEvent extends Event class DeleteTipEvent extends Event { - public $tip_id; + public int $tip_id; public function __construct(int $tip_id) { parent::__construct(); @@ -27,7 +28,7 @@ class DeleteTipEvent extends Event class Tips extends Extension { /** @var TipsTheme */ - protected $theme; + protected ?Themelet $theme; public function onDatabaseUpgrade(DatabaseUpgradeEvent $event) { diff --git a/ext/transcode/info.php b/ext/transcode/info.php index 1f207038..0149c066 100644 --- a/ext/transcode/info.php +++ b/ext/transcode/info.php @@ -4,12 +4,12 @@ class TranscodeImageInfo extends ExtensionInfo { public const KEY = "transcode"; - public $key = self::KEY; - public $name = "Transcode Image"; - public $authors = ["Matthew Barbour"=>"matthew@darkholme.net"]; - public $license = self::LICENSE_WTFPL; - public $description = "Allows admins to automatically and manually transcode images."; - public $documentation = + public string $key = self::KEY; + public string $name = "Transcode Image"; + public array $authors = ["Matthew Barbour"=>"matthew@darkholme.net"]; + public string $license = self::LICENSE_WTFPL; + public string $description = "Allows admins to automatically and manually transcode images."; + public ?string $documentation = "Can transcode on-demand and automatically on upload. Config screen allows choosing an output format for each of the supported input formats. Supports GD and ImageMagick. Both support bmp, gif, jpg, png, and webp as inputs, and jpg, png, and lossy webp as outputs. ImageMagick additionally supports tiff and psd inputs, and webp lossless output. diff --git a/ext/transcode/main.php b/ext/transcode/main.php index 130f4d91..c320ae82 100644 --- a/ext/transcode/main.php +++ b/ext/transcode/main.php @@ -12,7 +12,7 @@ class ImageTranscodeException extends SCoreException class TranscodeImage extends Extension { /** @var TranscodeImageTheme */ - protected $theme; + protected ?Themelet $theme; const ACTION_BULK_TRANSCODE = "bulk_transcode"; diff --git a/ext/transcode/script.js b/ext/transcode/script.js index 3e962f92..009ce65f 100644 --- a/ext/transcode/script.js +++ b/ext/transcode/script.js @@ -1,8 +1,8 @@ function transcodeSubmit(e) { var mime = document.getElementById('transcode_mime').value; - if(!mime.includes("lossless=true") && format != "image/png") { + if(!mime.includes("lossless=true") && format !== "image/png") { var lossless = document.getElementById('image_lossless'); - if(lossless!=null && lossless.value=='1') { + if(lossless!=null && lossless.value==='1') { return confirm('You are about to transcode from a lossless format to a lossy format. Lossless formats compress with no quality loss, but converting to a lossy format always results in quality loss, and it will lose more quality every time it is done again on the same image. Are you sure you want to perform this transcode?'); } else { return confirm('Converting to a lossy format always results in quality loss, and it will lose more quality every time it is done again on the same image. Are you sure you want to perform this transcode?'); diff --git a/ext/transcode/theme.php b/ext/transcode/theme.php index 56bf1755..35affd95 100644 --- a/ext/transcode/theme.php +++ b/ext/transcode/theme.php @@ -5,7 +5,7 @@ class TranscodeImageTheme extends Themelet /* * Display a link to resize an image */ - public function get_transcode_html(Image $image, array $options) + public function get_transcode_html(Image $image, array $options): string { $html = " ".make_form( @@ -25,7 +25,7 @@ class TranscodeImageTheme extends Themelet return $html; } - public function get_transcode_picker_html(array $options) + public function get_transcode_picker_html(array $options): string { $html = ""; } - public function display_transcode_error(Page $page, string $title, string $message) + public function display_transcode_error(Page $page, string $title, string $message): void { $page->set_title("Transcode Image"); $page->set_heading("Transcode Image"); diff --git a/ext/transcode_video/info.php b/ext/transcode_video/info.php index 553de153..f4d95e41 100644 --- a/ext/transcode_video/info.php +++ b/ext/transcode_video/info.php @@ -4,10 +4,10 @@ class TranscodeVideoInfo extends ExtensionInfo { public const KEY = "transcode_video"; - public $key = self::KEY; - public $name = "Transcode Video"; - public $authors = ["Matthew Barbour"=>"matthew@darkholme.net"]; - public $license = self::LICENSE_WTFPL; - public $description = "Allows admins to automatically and manually transcode videos."; - public $documentation ="Requires ffmpeg"; + public string $key = self::KEY; + public string $name = "Transcode Video"; + public array $authors = ["Matthew Barbour"=>"matthew@darkholme.net"]; + public string $license = self::LICENSE_WTFPL; + public string $description = "Allows admins to automatically and manually transcode videos."; + public ?string $documentation ="Requires ffmpeg"; } diff --git a/ext/transcode_video/main.php b/ext/transcode_video/main.php index ce7a4613..01560b78 100644 --- a/ext/transcode_video/main.php +++ b/ext/transcode_video/main.php @@ -12,7 +12,7 @@ class VideoTranscodeException extends SCoreException class TranscodeVideo extends Extension { /** @var TranscodeVideoTheme */ - protected $theme; + protected ?Themelet $theme; const ACTION_BULK_TRANSCODE = "bulk_transcode_video"; @@ -54,8 +54,6 @@ class TranscodeVideo extends Extension public function onSetupBuilding(SetupBuildingEvent $event) { - global $config; - $sb = $event->panel->create_new_block("Video Transcode"); $sb->start_table(); $sb->add_bool_option(TranscodeVideoConfig::ENABLED, "Allow transcoding images: ", true); @@ -256,8 +254,6 @@ class TranscodeVideo extends Extension throw new VideoTranscodeException("ffmpeg path not configured"); } - $ext = Media::determine_ext($target_mime); - $command = new CommandBuilder($ffmpeg); $command->add_flag("-y"); // Bypass y/n prompts $command->add_flag("-i"); @@ -274,8 +270,6 @@ class TranscodeVideo extends Extension $command->add_flag("-map"); // Copies all streams $command->add_flag("0"); - $file_extension = FileExtension::get_for_mime($target_mime); - $command->add_flag("-f"); $format = self::FORMAT_NAMES[$target_mime]; $command->add_flag($format); diff --git a/ext/transcode_video/script.js b/ext/transcode_video/script.js index 6f78ac33..71a1a83e 100644 --- a/ext/transcode_video/script.js +++ b/ext/transcode_video/script.js @@ -1,11 +1,11 @@ function transcodeSubmit(e) { var format = document.getElementById('transcode_format').value; - if(format!="webp-lossless" && format != "png") { + if(format!=="webp-lossless" && format !== "png") { var lossless = document.getElementById('image_lossless'); - if(lossless!=null && lossless.value=='1') { + if(lossless!=null && lossless.value==='1') { return confirm('You are about to transcode from a lossless format to a lossy format. Lossless formats compress with no quality loss, but converting to a lossy format always results in quality loss, and it will lose more quality every time it is done again on the same image. Are you sure you want to perform this transcode?'); } else { return confirm('Converting to a lossy format always results in quality loss, and it will lose more quality every time it is done again on the same image. Are you sure you want to perform this transcode?'); } } -} \ No newline at end of file +} diff --git a/ext/transcode_video/theme.php b/ext/transcode_video/theme.php index 340d2398..48579667 100644 --- a/ext/transcode_video/theme.php +++ b/ext/transcode_video/theme.php @@ -5,7 +5,7 @@ class TranscodeVideoTheme extends Themelet /* * Display a link to resize an image */ - public function get_transcode_html(Image $image, array $options) + public function get_transcode_html(Image $image, array $options): string { $html = " ".make_form( @@ -25,7 +25,7 @@ class TranscodeVideoTheme extends Themelet return $html; } - public function get_transcode_picker_html(array $options) + public function get_transcode_picker_html(array $options): string { $html = ""; } - public function display_transcode_error(Page $page, string $title, string $message) + public function display_transcode_error(Page $page, string $title, string $message): void { $page->set_title("Transcode Video"); $page->set_heading("Transcode Video"); diff --git a/ext/trash/info.php b/ext/trash/info.php index d7daf35a..fb19d4fc 100644 --- a/ext/trash/info.php +++ b/ext/trash/info.php @@ -4,9 +4,9 @@ class TrashInfo extends ExtensionInfo { public const KEY = "trash"; - public $key = self::KEY; - public $name = "Trash"; - public $authors = ["Matthew Barbour"=>"matthew@darkholme.net"]; - public $license = self::LICENSE_WTFPL; - public $description = "Provides \"Trash\" or \"Recycle Bin\"-type functionality, storing deleted images for later recovery"; + public string $key = self::KEY; + public string $name = "Trash"; + public array $authors = ["Matthew Barbour"=>"matthew@darkholme.net"]; + public string $license = self::LICENSE_WTFPL; + public string $description = "Provides \"Trash\" or \"Recycle Bin\"-type functionality, storing deleted images for later recovery"; } diff --git a/ext/trash/main.php b/ext/trash/main.php index 3d473101..0ee6009d 100644 --- a/ext/trash/main.php +++ b/ext/trash/main.php @@ -8,7 +8,7 @@ abstract class TrashConfig class Trash extends Extension { /** @var TrashTheme */ - protected $theme; + protected ?Themelet $theme; public function get_priority(): int { diff --git a/ext/trash/theme.php b/ext/trash/theme.php index 74c9bf96..883a32df 100644 --- a/ext/trash/theme.php +++ b/ext/trash/theme.php @@ -3,7 +3,7 @@ use function MicroHTML\INPUT; class TrashTheme extends Themelet { - public function get_image_admin_html(int $image_id) + public function get_image_admin_html(int $image_id): string { return (string)SHM_SIMPLE_FORM( 'trash_restore/'.$image_id, @@ -13,7 +13,7 @@ class TrashTheme extends Themelet } - public function get_help_html() + public function get_help_html(): string { return '

          Search for posts in the trash.

          diff --git a/ext/update/info.php b/ext/update/info.php index 90c7b6ed..853255ce 100644 --- a/ext/update/info.php +++ b/ext/update/info.php @@ -4,10 +4,10 @@ class UpdateInfo extends ExtensionInfo { public const KEY = "update"; - public $key = self::KEY; - public $name = "Update"; - public $url = "http://www.codeanimu.net"; - public $authors = ["DakuTree"=>"dakutree@codeanimu.net"]; - public $license = self::LICENSE_GPLV2; - public $description = "Shimmie updater! (Requires admin panel extension & transload engine (cURL/fopen/Wget))"; + public string $key = self::KEY; + public string $name = "Update"; + public string $url = "http://www.codeanimu.net"; + public array $authors = ["DakuTree"=>"dakutree@codeanimu.net"]; + public string $license = self::LICENSE_GPLV2; + public string $description = "Shimmie updater! (Requires admin panel extension & transload engine (cURL/fopen/Wget))"; } diff --git a/ext/update/main.php b/ext/update/main.php index 94c24492..39aa3cca 100644 --- a/ext/update/main.php +++ b/ext/update/main.php @@ -3,7 +3,7 @@ class Update extends Extension { /** @var UpdateTheme */ - protected $theme; + protected ?Themelet $theme; public function onInitExt(InitExtEvent $event) { diff --git a/ext/upgrade/info.php b/ext/upgrade/info.php index 447a8408..31721e57 100644 --- a/ext/upgrade/info.php +++ b/ext/upgrade/info.php @@ -4,11 +4,11 @@ class UpgradeInfo extends ExtensionInfo { public const KEY = "upgrade"; - public $key = self::KEY; - public $name = "Database Upgrader"; - public $url = self::SHIMMIE_URL; - public $authors = self::SHISH_AUTHOR; - public $description = "Keeps things happy behind the scenes"; - public $visibility = self::VISIBLE_HIDDEN; - public $core = true; + public string $key = self::KEY; + public string $name = "Database Upgrader"; + public string $url = self::SHIMMIE_URL; + public array $authors = self::SHISH_AUTHOR; + public string $description = "Keeps things happy behind the scenes"; + public string $visibility = self::VISIBLE_HIDDEN; + public bool $core = true; } diff --git a/ext/upload/info.php b/ext/upload/info.php index 0752012d..1dc0105c 100644 --- a/ext/upload/info.php +++ b/ext/upload/info.php @@ -4,11 +4,11 @@ class UploadInfo extends ExtensionInfo { public const KEY = "upload"; - public $key = self::KEY; - public $name = "Uploader"; - public $url = self::SHIMMIE_URL; - public $authors = self::SHISH_AUTHOR; - public $description = "Allows people to upload files to the website"; - public $core = true; - public $visibility = self::VISIBLE_HIDDEN; + public string $key = self::KEY; + public string $name = "Uploader"; + public string $url = self::SHIMMIE_URL; + public array $authors = self::SHISH_AUTHOR; + public string $description = "Allows people to upload files to the website"; + public bool $core = true; + public string $visibility = self::VISIBLE_HIDDEN; } diff --git a/ext/upload/main.php b/ext/upload/main.php index 4345e8fc..566f20ce 100644 --- a/ext/upload/main.php +++ b/ext/upload/main.php @@ -7,22 +7,14 @@ require_once "config.php"; */ class DataUploadEvent extends Event { - /** @var string */ - public $tmpname; - /** @var array */ - public $metadata; - /** @var string */ - public $hash; - /** @var string */ - public $mime = ""; - /** @var int */ - public $image_id = -1; - /** @var int */ - public $replace_id = null; - /** @var bool */ - public $handled = false; - /** @var bool */ - public $merged = false; + public string $tmpname; + public array $metadata; + public string $hash; + public string $mime = ""; + public int $image_id = -1; + public ?int $replace_id = null; + public bool $handled = false; + public bool $merged = false; /** * Some data is being uploaded. @@ -86,10 +78,8 @@ class UploadException extends SCoreException class Upload extends Extension { /** @var UploadTheme */ - protected $theme; - - /** @var bool */ - public $is_full; + protected ?Themelet $theme; + public bool $is_full; /** * Early, so it can stop the DataUploadEvent before any data handlers see it. diff --git a/ext/upload/theme.php b/ext/upload/theme.php index 73d2d96a..be85e8b1 100644 --- a/ext/upload/theme.php +++ b/ext/upload/theme.php @@ -2,7 +2,7 @@ class UploadTheme extends Themelet { - protected $has_errors = false; + protected bool $has_errors = false; public function display_block(Page $page) { diff --git a/ext/user/events.php b/ext/user/events.php index 0fd73f1e..8b6a29fb 100644 --- a/ext/user/events.php +++ b/ext/user/events.php @@ -2,10 +2,9 @@ class UserBlockBuildingEvent extends Event { - /** @var array */ - public $parts = []; + public array $parts = []; - public function add_link(string $name, string $link, int $position=50) + public function add_link(string $name, string $link, int $position=50): void { while (isset($this->parts[$position])) { $position++; @@ -16,12 +15,9 @@ class UserBlockBuildingEvent extends Event class UserOperationsBuildingEvent extends Event { - /** @var array */ - public $parts = []; - /** @var User */ - public $user = []; - /** @var BaseConfig */ - public $user_config = []; + public array $parts = []; + public User $user; + public BaseConfig $user_config; public function __construct(User $user, BaseConfig $user_config) { @@ -30,7 +26,7 @@ class UserOperationsBuildingEvent extends Event $this->user_config = $user_config; } - public function add_html(string $html) + public function add_html(string $html): void { $this->parts[] = $html; } @@ -38,10 +34,8 @@ class UserOperationsBuildingEvent extends Event class UserPageBuildingEvent extends Event { - /** @var User */ - public $display_user; - /** @var array */ - public $stats = []; + public User $display_user; + public array $stats = []; public function __construct(User $display_user) { @@ -60,14 +54,10 @@ class UserPageBuildingEvent extends Event class UserCreationEvent extends Event { - /** @var string */ - public $username; - /** @var string */ - public $password; - /** @var string */ - public $email; - /** @var bool */ - public $login; + public string $username; + public string $password; + public string $email; + public bool $login; public function __construct(string $name, string $pass, string $email, bool $login) { @@ -81,7 +71,7 @@ class UserCreationEvent extends Event class UserLoginEvent extends Event { - public $user; + public User $user; public function __construct(User $user) { parent::__construct(); @@ -91,8 +81,7 @@ class UserLoginEvent extends Event class UserDeletionEvent extends Event { - /** @var int */ - public $id; + public int $id; public function __construct(int $id) { diff --git a/ext/user/info.php b/ext/user/info.php index 26409eb7..847a8551 100644 --- a/ext/user/info.php +++ b/ext/user/info.php @@ -4,10 +4,10 @@ class UserPageInfo extends ExtensionInfo { public const KEY = "user"; - public $key = self::KEY; - public $name = "User Management"; - public $authors = self::SHISH_AUTHOR; - public $description = "Allows people to sign up to the website"; - public $core = true; - public $visibility = self::VISIBLE_HIDDEN; + public string $key = self::KEY; + public string $name = "User Management"; + public array $authors = self::SHISH_AUTHOR; + public string $description = "Allows people to sign up to the website"; + public bool $core = true; + public string $visibility = self::VISIBLE_HIDDEN; } diff --git a/ext/user/main.php b/ext/user/main.php index 10d395a3..58be8215 100644 --- a/ext/user/main.php +++ b/ext/user/main.php @@ -3,6 +3,7 @@ require_once "events.php"; use function MicroHTML\A; +use MicroHTML\HTMLElement; use MicroCRUD\ActionColumn; use MicroCRUD\EnumColumn; use MicroCRUD\IntegerColumn; @@ -12,7 +13,7 @@ use MicroCRUD\Table; class UserNameColumn extends TextColumn { - public function display(array $row) + public function display(array $row): HTMLElement { return A(["href"=>make_link("user/{$row[$this->name]}")], $row[$this->name]); } @@ -22,11 +23,11 @@ class UserActionColumn extends ActionColumn { public function __construct() { - parent::__construct("id", "User Links"); + parent::__construct("id"); $this->sortable = false; } - public function display(array $row) + public function display(array $row): HTMLElement { return A(["href"=>make_link("post/list/user={$row['name']}/1")], "Posts"); } @@ -72,7 +73,7 @@ class NullUserException extends SCoreException class UserPage extends Extension { /** @var UserPageTheme $theme */ - public $theme; + public ?Themelet $theme; public function onInitExt(InitExtEvent $event) { @@ -231,7 +232,7 @@ class UserPage extends Extension } } - private function display_stats(UserPageBuildingEvent $event) + private function display_stats(UserPageBuildingEvent $event): void { global $user, $page, $config; @@ -294,7 +295,7 @@ class UserPage extends Extension if ($config->get_string("avatar_host") == "gravatar") { $sb->start_table_row(); $sb->start_table_cell(2); - $sb->add_label("
          Gravatar Options
          ", ); + $sb->add_label("
          Gravatar Options
          "); $sb->end_table_cell(); $sb->end_table_row(); @@ -400,12 +401,12 @@ class UserPage extends Extension if ($event->key===HelpPages::SEARCH) { $block = new Block(); $block->header = "Users"; - $block->body = $this->theme->get_help_html(); + $block->body = (string)$this->theme->get_help_html(); $event->add_block($block); } } - private function show_user_info() + private function show_user_info(): void { global $user, $page; // user info is shown on all pages @@ -419,7 +420,7 @@ class UserPage extends Extension } } - private function page_login($name, $pass) + private function page_login(string $name, string $pass): void { global $config, $page; @@ -445,7 +446,7 @@ class UserPage extends Extension } } - private function page_logout() + private function page_logout(): void { global $page, $config; $page->add_cookie("session", "", time() + 60 * 60 * 24 * $config->get_int('login_memory'), "/"); @@ -465,7 +466,7 @@ class UserPage extends Extension } } - private function page_recover(string $username) + private function page_recover(string $username): void { $my_user = User::by_name($username); if (is_null($my_user)) { @@ -477,7 +478,7 @@ class UserPage extends Extension } } - private function page_create() + private function page_create(): void { global $config, $page, $user; if (!$user->can(Permissions::CREATE_USER)) { @@ -508,7 +509,7 @@ class UserPage extends Extension } } - private function check_user_creation(UserCreationEvent $event) + private function check_user_creation(UserCreationEvent $event): void { $name = $event->username; //$pass = $event->password; @@ -549,7 +550,7 @@ class UserPage extends Extension return $user; } - private function set_login_cookie(string $name, string $pass) + private function set_login_cookie(string $name, string $pass): void { global $config, $page; @@ -589,7 +590,7 @@ class UserPage extends Extension } } - private function redirect_to_user(User $duser) + private function redirect_to_user(User $duser): void { global $page, $user; @@ -602,7 +603,7 @@ class UserPage extends Extension } } - private function change_name_wrapper(User $duser, $name) + private function change_name_wrapper(User $duser, string $name): void { global $page, $user; @@ -616,7 +617,7 @@ class UserPage extends Extension } } - private function change_password_wrapper(User $duser, string $pass1, string $pass2) + private function change_password_wrapper(User $duser, string $pass1, string $pass2): void { global $page, $user; @@ -637,7 +638,7 @@ class UserPage extends Extension } } - private function change_email_wrapper(User $duser, string $address) + private function change_email_wrapper(User $duser, string $address): void { global $page, $user; @@ -649,7 +650,7 @@ class UserPage extends Extension } } - private function change_class_wrapper(User $duser, string $class) + private function change_class_wrapper(User $duser, string $class): void { global $page, $user; @@ -702,7 +703,7 @@ class UserPage extends Extension ORDER BY MAX(date_sent) DESC", ["username"=>$duser->name]); } - private function delete_user(Page $page, bool $with_images=false, bool $with_comments=false) + private function delete_user(Page $page, bool $with_images=false, bool $with_comments=false): void { global $user, $config, $database; diff --git a/ext/user/theme.php b/ext/user/theme.php index 35854925..ca589dd4 100644 --- a/ext/user/theme.php +++ b/ext/user/theme.php @@ -15,6 +15,7 @@ use function \MicroHTML\BR; use function \MicroHTML\P; use function \MicroHTML\SELECT; use function \MicroHTML\OPTION; +use \MicroHTML\HTMLElement; class UserPageTheme extends Themelet { @@ -184,7 +185,7 @@ class UserPageTheme extends Themelet $page->add_block(new Block("Login", (string)$html, "left", 90)); } - private function _ip_list(string $name, array $ips) + private function _ip_list(string $name, array $ips): HTMLElement { $td = TD("$name: "); $n = 0; @@ -318,7 +319,7 @@ class UserPageTheme extends Themelet return (string)$html; } - public function get_help_html() + public function get_help_html(): HTMLElement { global $user; $output = emptyHTML(P("Search for posts posted by particular individuals.")); diff --git a/ext/user_config/info.php b/ext/user_config/info.php index 7316fba8..a5a2772f 100644 --- a/ext/user_config/info.php +++ b/ext/user_config/info.php @@ -4,11 +4,11 @@ class UserConfigInfo extends ExtensionInfo { public const KEY = "user_config"; - public $key = self::KEY; - public $name = "User-specific settings"; - public $authors = ["Matthew Barbour"=>"matthew@darkholme.net"]; - public $license = self::LICENSE_WTFPL; - public $description = "Provides system-wide support for user-specific settings"; - public $visibility = self::VISIBLE_HIDDEN; - public $core = true; + public string $key = self::KEY; + public string $name = "User-specific settings"; + public array $authors = ["Matthew Barbour"=>"matthew@darkholme.net"]; + public string $license = self::LICENSE_WTFPL; + public string $description = "Provides system-wide support for user-specific settings"; + public string $visibility = self::VISIBLE_HIDDEN; + public bool $core = true; } diff --git a/ext/user_config/main.php b/ext/user_config/main.php index 7d47abb3..97003f07 100644 --- a/ext/user_config/main.php +++ b/ext/user_config/main.php @@ -8,8 +8,8 @@ global $user_config; // so we can't reliably access this data until then. This event is triggered by the system after all of that is done. class InitUserConfigEvent extends Event { - public $user; - public $user_config; + public User $user; + public Config $user_config; public function __construct(User $user, Config $user_config) { @@ -22,14 +22,9 @@ class InitUserConfigEvent extends Event class UserOptionsBuildingEvent extends Event { - /** @var SetupTheme */ - protected $theme; - - /** @var SetupPanel */ - public $panel; - - /** @var User */ - public $user = []; + protected SetupTheme $theme; + public SetupPanel $panel; + public User $user; public function __construct(User $user, SetupPanel $panel) @@ -43,7 +38,7 @@ class UserOptionsBuildingEvent extends Event class UserConfig extends Extension { /** @var UserConfigTheme */ - protected $theme; + protected ?Themelet $theme; public const VERSION = "ext_user_config_version"; public const ENABLE_API_KEYS = "ext_user_config_enable_api_keys"; diff --git a/ext/user_config/theme.php b/ext/user_config/theme.php index 144eca67..b5660c0c 100644 --- a/ext/user_config/theme.php +++ b/ext/user_config/theme.php @@ -62,7 +62,7 @@ class UserConfigTheme extends Themelet $page->set_mode(PageMode::PAGE); } - protected function sb_to_html(SetupBlock $block) + protected function sb_to_html(SetupBlock $block): string { $h = $block->header; $b = $block->body; diff --git a/ext/varnish/info.php b/ext/varnish/info.php index cf2255f0..d7fadc16 100644 --- a/ext/varnish/info.php +++ b/ext/varnish/info.php @@ -4,11 +4,11 @@ class VarnishPurgerInfo extends ExtensionInfo { public const KEY = "varnish"; - public $key = self::KEY; - public $name = "Varnish Purger"; - public $url = self::SHIMMIE_URL; - public $authors = self::SHISH_AUTHOR; - public $license = self::LICENSE_GPLV2; - public $visibility = self::VISIBLE_ADMIN; - public $description = "Sends PURGE requests when a /post/view is updated"; + public string $key = self::KEY; + public string $name = "Varnish Purger"; + public string $url = self::SHIMMIE_URL; + public array $authors = self::SHISH_AUTHOR; + public string $license = self::LICENSE_GPLV2; + public string $visibility = self::VISIBLE_ADMIN; + public string $description = "Sends PURGE requests when a /post/view is updated"; } diff --git a/ext/view/events/displaying_image_event.php b/ext/view/events/displaying_image_event.php index 92d5d4bf..646f7d3c 100644 --- a/ext/view/events/displaying_image_event.php +++ b/ext/view/events/displaying_image_event.php @@ -11,8 +11,7 @@ */ class DisplayingImageEvent extends Event { - /** @var Image */ - public $image; + public Image $image; public function __construct(Image $image) { diff --git a/ext/view/events/image_admin_block_building_event.php b/ext/view/events/image_admin_block_building_event.php index 4b2e51da..eabd9d45 100644 --- a/ext/view/events/image_admin_block_building_event.php +++ b/ext/view/events/image_admin_block_building_event.php @@ -3,11 +3,9 @@ class ImageAdminBlockBuildingEvent extends Event { /** @var string[] */ - public $parts = []; - /** @var Image */ - public $image = null; - /** @var User */ - public $user = null; + public array $parts = []; + public Image $image; + public User $user; public function __construct(Image $image, User $user) { diff --git a/ext/view/events/image_info_box_building_event.php b/ext/view/events/image_info_box_building_event.php index feec79c6..b5b2c7ed 100644 --- a/ext/view/events/image_info_box_building_event.php +++ b/ext/view/events/image_info_box_building_event.php @@ -2,12 +2,9 @@ class ImageInfoBoxBuildingEvent extends Event { - /** @var array */ - public $parts = []; - /** @var Image */ - public $image; - /** @var User */ - public $user; + public array $parts = []; + public Image $image; + public User $user; public function __construct(Image $image, User $user) { diff --git a/ext/view/events/image_info_set_event.php b/ext/view/events/image_info_set_event.php index a318b82f..b58502a3 100644 --- a/ext/view/events/image_info_set_event.php +++ b/ext/view/events/image_info_set_event.php @@ -2,8 +2,7 @@ class ImageInfoSetEvent extends Event { - /** @var Image */ - public $image; + public Image $image; public function __construct(Image $image) { diff --git a/ext/view/info.php b/ext/view/info.php index 8e8dd0ae..ea786717 100644 --- a/ext/view/info.php +++ b/ext/view/info.php @@ -4,11 +4,11 @@ class ViewImageInfo extends ExtensionInfo { public const KEY = "view"; - public $key = self::KEY; - public $name = "Post Viewer"; - public $url = self::SHIMMIE_URL; - public $authors = self::SHISH_AUTHOR; - public $description = "Allows users to see uploaded posts"; - public $core = true; - public $visibility = self::VISIBLE_HIDDEN; + public string $key = self::KEY; + public string $name = "Post Viewer"; + public string $url = self::SHIMMIE_URL; + public array $authors = self::SHISH_AUTHOR; + public string $description = "Allows users to see uploaded posts"; + public bool $core = true; + public string $visibility = self::VISIBLE_HIDDEN; } diff --git a/ext/view/main.php b/ext/view/main.php index 552088fb..a1dc5a47 100644 --- a/ext/view/main.php +++ b/ext/view/main.php @@ -12,7 +12,7 @@ use function MicroHTML\TD; class ViewImage extends Extension { /** @var ViewImageTheme */ - protected $theme; + protected ?Themelet $theme; public function onPageRequest(PageRequestEvent $event) { diff --git a/ext/view/theme.php b/ext/view/theme.php index 677d4889..12678dcd 100644 --- a/ext/view/theme.php +++ b/ext/view/theme.php @@ -38,7 +38,7 @@ class ViewImageTheme extends Themelet } } - protected function get_query() + protected function get_query(): ?string { if (isset($_GET['search'])) { $query = "search=".url_escape(Tag::caret($_GET['search'])); @@ -48,7 +48,7 @@ class ViewImageTheme extends Themelet return $query; } - protected function build_pin(Image $image) + protected function build_pin(Image $image): string { $query = $this->get_query(); $h_prev = "Prev"; @@ -72,7 +72,7 @@ class ViewImageTheme extends Themelet return "$h_pin
          $h_search"; } - protected function build_info(Image $image, $editor_parts) + protected function build_info(Image $image, $editor_parts): string { global $user; diff --git a/ext/wiki/info.php b/ext/wiki/info.php index 1948dc77..5e59fd6c 100644 --- a/ext/wiki/info.php +++ b/ext/wiki/info.php @@ -4,11 +4,11 @@ class WikiInfo extends ExtensionInfo { public const KEY = "wiki"; - public $key = self::KEY; - public $name = "Simple Wiki"; - public $url = self::SHIMMIE_URL; - public $authors = [self::SHISH_NAME=>self::SHISH_EMAIL, "LaureeGrd"=>"laureegrd@gmail.com"]; - public $license = self::LICENSE_GPLV2; - public $description = "A simple wiki, for those who don't want the hugeness of mediawiki"; - public $documentation = "Standard formatting APIs are used (This will be BBCode by default)"; + public string $key = self::KEY; + public string $name = "Simple Wiki"; + public string $url = self::SHIMMIE_URL; + public array $authors = [self::SHISH_NAME=>self::SHISH_EMAIL, "LaureeGrd"=>"laureegrd@gmail.com"]; + public string $license = self::LICENSE_GPLV2; + public string $description = "A simple wiki, for those who don't want the hugeness of mediawiki"; + public ?string $documentation = "Standard formatting APIs are used (This will be BBCode by default)"; } diff --git a/ext/wiki/main.php b/ext/wiki/main.php index 8520d3d6..8ea892d8 100644 --- a/ext/wiki/main.php +++ b/ext/wiki/main.php @@ -2,10 +2,8 @@ class WikiUpdateEvent extends Event { - /** @var User */ - public $user; - /** @var WikiPage */ - public $wikipage; + public User $user; + public WikiPage $wikipage; public function __construct(User $user, WikiPage $wikipage) { @@ -17,10 +15,10 @@ class WikiUpdateEvent extends Event class WikiDeleteRevisionEvent extends Event { - public $title; - public $revision; + public string $title; + public int $revision; - public function __construct($title, $revision) + public function __construct(string $title, int $revision) { parent::__construct(); $this->title = $title; @@ -30,9 +28,9 @@ class WikiDeleteRevisionEvent extends Event class WikiDeletePageEvent extends Event { - public $title; + public string $title; - public function __construct($title) + public function __construct(string $title) { parent::__construct(); $this->title = $title; @@ -45,29 +43,14 @@ class WikiUpdateException extends SCoreException class WikiPage { - /** @var int|string */ - public $id; - - /** @var int */ - public $owner_id; - - /** @var string */ - public $owner_ip; - - /** @var string */ - public $date; - - /** @var string */ - public $title; - - /** @var int */ - public $revision; - - /** @var bool */ - public $locked; - - /** @var string */ - public $body; + public int $id; + public int $owner_id; + public string $owner_ip; + public string $date; + public string $title; + public int $revision; + public bool $locked; + public string $body; public function __construct(array $row=null) { @@ -107,7 +90,7 @@ abstract class WikiConfig class Wiki extends Extension { /** @var WikiTheme */ - protected $theme; + protected ?Themelet $theme; public function onInitExt(InitExtEvent $event) { @@ -210,7 +193,7 @@ class Wiki extends Extension } } elseif ($event->page_matches("wiki_admin/delete_revision")) { if ($user->can(Permissions::WIKI_ADMIN)) { - send_event(new WikiDeleteRevisionEvent($_POST["title"], $_POST["revision"])); + send_event(new WikiDeleteRevisionEvent($_POST["title"], (int)$_POST["revision"])); $u_title = url_escape($_POST["title"]); $page->set_mode(PageMode::REDIRECT); $page->set_redirect(make_link("wiki/$u_title")); @@ -361,22 +344,22 @@ class Wiki extends Extension public static function format_tag_wiki_page(WikiPage $page) { global $database, $config; - + $row = $database->get_row(" SELECT * FROM tags WHERE tag = :title ", ["title"=>$page->title]); - + if (!empty($row)) { $template = $config->get_string(WikiConfig::TAG_PAGE_TEMPLATE); - + //CATEGORIES if (class_exists("TagCategories")) { $tagcategories = new TagCategories; $tag_category_dict = $tagcategories->getKeyedDict(); } - + //ALIASES $aliases = $database->get_col(" SELECT oldtag @@ -384,53 +367,52 @@ class Wiki extends Extension WHERE newtag = :title ORDER BY oldtag ASC ", ["title"=>$row["tag"]]); - + if (!empty($aliases)) { $template = str_replace("{aliases}", implode(", ", $aliases), $template); } else { $template = str_replace("{aliases}", $config->get_string(WikiConfig::EMPTY_TAGINFO), $template); } - + //Things before this line will be passed through html_escape. $template = format_text($template); //Things after this line will NOT be escaped!!! Be careful what you add. - + if (class_exists("AutoTagger")) { $auto_tags = $database->get_one(" SELECT additional_tags FROM auto_tag WHERE tag = :title ", ["title"=>$row["tag"]]); - + if (!empty($auto_tags)) { $auto_tags = Tag::explode($auto_tags); $f_auto_tags = []; - + $tag_list_t = new TagListTheme; - + foreach ($auto_tags as $a_tag) { $a_row = $database->get_row(" SELECT * FROM tags WHERE tag = :title ", ["title"=>$a_tag]); - + $tag_html = $tag_list_t->return_tag($a_row, $tag_category_dict ?? []); array_push($f_auto_tags, $tag_html[1]); } - + $template = str_replace("{autotags}", implode(", ", $f_auto_tags), $template); } else { $template = str_replace("{autotags}", format_text($config->get_string(WikiConfig::EMPTY_TAGINFO)), $template); } } } - + //Insert page body AT LAST to avoid replacing its contents with the actions above. - $formatted = str_replace("{body}", format_text($page->body), $template ?? "{body}"); - return $formatted; + return str_replace("{body}", format_text($page->body), $template ?? "{body}"); } - + /** Diff implemented in pure php, written from scratch. Copyright (C) 2003 Daniel Unterberger @@ -462,7 +444,7 @@ class Wiki extends Extension Contact: d.u.diff@holomind.de **/ - private function arr_diff($f1, $f2, $show_equal = 0) + private function arr_diff(array $f1, array $f2, int $show_equal = 0): string { $c1 = 0 ; # current line of left $c2 = 0 ; # current line of right @@ -641,7 +623,7 @@ class Wiki extends Extension /** * callback function to format the diffence-lines with your 'style' */ - private function formatline(int $nr1, int $nr2, string $stat, &$value): string + private function formatline(int $nr1, int $nr2, string $stat, $value): string { #change to $value if problems if (trim($value) == "") { return ""; @@ -651,17 +633,14 @@ class Wiki extends Extension case "=": // return $nr1. " : $nr2 : = ".htmlentities( $value ) ."
          "; return "$value\n"; - break; case "+": //return $nr1. " : $nr2 : + ".htmlentities( $value ) ."
          "; return "+++ $value\n"; - break; case "-": //return $nr1. " : $nr2 : - ".htmlentities( $value ) ."
          "; return "--- $value\n"; - break; default: throw new RuntimeException("stat needs to be =, + or -"); diff --git a/ext/wiki/theme.php b/ext/wiki/theme.php index 4381175b..6125de16 100644 --- a/ext/wiki/theme.php +++ b/ext/wiki/theme.php @@ -48,7 +48,7 @@ class WikiTheme extends Themelet $page->add_block(new Block("Editor", $this->create_edit_html($wiki_page))); } - protected function create_edit_html(WikiPage $page) + protected function create_edit_html(WikiPage $page): string { $h_title = html_escape($page->title); $i_revision = $page->revision + 1; @@ -71,7 +71,7 @@ class WikiTheme extends Themelet "; } - protected function create_display_html(WikiPage $page) + protected function create_display_html(WikiPage $page): string { global $user; diff --git a/ext/word_filter/info.php b/ext/word_filter/info.php index fa32e9d7..1e168a6c 100644 --- a/ext/word_filter/info.php +++ b/ext/word_filter/info.php @@ -4,10 +4,10 @@ class WordFilterInfo extends ExtensionInfo { public const KEY = "word_filter"; - public $key = self::KEY; - public $name = "Word Filter"; - public $url = self::SHIMMIE_URL; - public $authors = self::SHISH_AUTHOR; - public $license = self::LICENSE_GPLV2; - public $description = "Simple search and replace"; + public string $key = self::KEY; + public string $name = "Word Filter"; + public string $url = self::SHIMMIE_URL; + public array $authors = self::SHISH_AUTHOR; + public string $license = self::LICENSE_GPLV2; + public string $description = "Simple search and replace"; } diff --git a/tests/bootstrap.php b/tests/bootstrap.php index d9dd05af..0409f6e1 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -41,10 +41,10 @@ $_tracer->end(); abstract class ShimmiePHPUnitTestCase extends TestCase { - protected static $anon_name = "anonymous"; - protected static $admin_name = "demo"; - protected static $user_name = "test"; - protected $wipe_time = "test"; + protected static string $anon_name = "anonymous"; + protected static string $admin_name = "demo"; + protected static string $user_name = "test"; + protected string $wipe_time = "test"; public static function setUpBeforeClass(): void { @@ -92,7 +92,7 @@ abstract class ShimmiePHPUnitTestCase extends TestCase $_tracer->end(); # get_called_class() } - protected static function create_user(string $name) + protected static function create_user(string $name): void { if (is_null(User::by_name($name))) { $userPage = new UserPage(); @@ -148,31 +148,31 @@ abstract class ShimmiePHPUnitTestCase extends TestCase } // page things - protected function assert_title(string $title) + protected function assert_title(string $title): void { global $page; $this->assertStringContainsString($title, $page->title); } - protected function assert_title_matches($title) + protected function assert_title_matches($title): void { global $page; $this->assertStringMatchesFormat($title, $page->title); } - protected function assert_no_title(string $title) + protected function assert_no_title(string $title): void { global $page; $this->assertStringNotContainsString($title, $page->title); } - protected function assert_response(int $code) + protected function assert_response(int $code): void { global $page; $this->assertEquals($code, $page->code); } - protected function page_to_text(string $section=null) + protected function page_to_text(string $section=null): string { global $page; if ($page->mode == PageMode::PAGE) { @@ -188,32 +188,33 @@ abstract class ShimmiePHPUnitTestCase extends TestCase return $page->data; } else { $this->assertTrue(false, "Page mode is not PAGE or DATA"); + return ""; } } - protected function assert_text(string $text, string $section=null) + protected function assert_text(string $text, string $section=null): void { $this->assertStringContainsString($text, $this->page_to_text($section)); } - protected function assert_no_text(string $text, string $section=null) + protected function assert_no_text(string $text, string $section=null): void { $this->assertStringNotContainsString($text, $this->page_to_text($section)); } - protected function assert_content(string $content) + protected function assert_content(string $content): void { global $page; $this->assertStringContainsString($content, $page->data); } - protected function assert_no_content(string $content) + protected function assert_no_content(string $content): void { global $page; $this->assertStringNotContainsString($content, $page->data); } - protected function assert_search_results($tags, $results) + protected function assert_search_results($tags, $results): void { $images = Image::find_images(0, null, $tags); $ids = []; @@ -224,17 +225,17 @@ abstract class ShimmiePHPUnitTestCase extends TestCase } // user things - protected static function log_in_as_admin() + protected static function log_in_as_admin(): void { send_event(new UserLoginEvent(User::by_name(self::$admin_name))); } - protected static function log_in_as_user() + protected static function log_in_as_user(): void { send_event(new UserLoginEvent(User::by_name(self::$user_name))); } - protected static function log_out() + protected static function log_out(): void { global $config; send_event(new UserLoginEvent(User::by_id($config->get_int("anon_id", 0)))); @@ -253,7 +254,7 @@ abstract class ShimmiePHPUnitTestCase extends TestCase return $dae->image_id; } - protected function delete_image(int $image_id) + protected function delete_image(int $image_id): void { $img = Image::by_id($image_id); if ($img) { diff --git a/themes/danbooru/page.class.php b/themes/danbooru/page.class.php index 5b593d63..bd5d7055 100644 --- a/themes/danbooru/page.class.php +++ b/themes/danbooru/page.class.php @@ -43,8 +43,7 @@ Tips * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ class Page extends BasePage { - /** @var bool */ - public $left_enabled = true; + public bool $left_enabled = true; public function disable_left() { diff --git a/themes/danbooru/view.theme.php b/themes/danbooru/view.theme.php index 059be8ea..2bf167e9 100644 --- a/themes/danbooru/view.theme.php +++ b/themes/danbooru/view.theme.php @@ -12,7 +12,7 @@ class CustomViewImageTheme extends ViewImageTheme $page->add_block(new Block(null, $this->build_pin($image), "main", 11)); } - private function build_stats(Image $image) + private function build_stats(Image $image): string { $h_owner = html_escape($image->get_owner()->name); $h_ownerlink = "$h_owner"; diff --git a/themes/danbooru2/page.class.php b/themes/danbooru2/page.class.php index 26eec382..19e942bb 100644 --- a/themes/danbooru2/page.class.php +++ b/themes/danbooru2/page.class.php @@ -44,7 +44,7 @@ Tips class Page extends BasePage { - public $left_enabled = true; + public bool $left_enabled = true; public function disable_left() { $this->left_enabled = false; diff --git a/themes/futaba/comment.theme.php b/themes/futaba/comment.theme.php index d577d784..78250ec8 100644 --- a/themes/futaba/comment.theme.php +++ b/themes/futaba/comment.theme.php @@ -2,9 +2,9 @@ class CustomCommentListTheme extends CommentListTheme { - public $inner_id = 0; + public int $inner_id = 0; - public function display_comment_list(array $images, int $page_number, int $total_pages, bool $can_post) + public function display_comment_list(array $images, int $page_number, int $total_pages, bool $can_post): void { global $config, $page; @@ -49,12 +49,12 @@ class CustomCommentListTheme extends CommentListTheme } } - public function display_recent_comments(array $comments) + public function display_recent_comments(array $comments): void { // sidebar fails in this theme } - public function build_upload_box() + public function build_upload_box(): string { return "[[ insert upload-and-comment extension here ]]"; } diff --git a/themes/futaba/page.class.php b/themes/futaba/page.class.php index 452514ef..f8e4be45 100644 --- a/themes/futaba/page.class.php +++ b/themes/futaba/page.class.php @@ -2,7 +2,7 @@ class Page extends BasePage { - public $left_enabled = true; + public bool $left_enabled = true; public function disable_left() { $this->left_enabled = false; diff --git a/themes/lite/page.class.php b/themes/lite/page.class.php index 84b27cb2..8655389a 100644 --- a/themes/lite/page.class.php +++ b/themes/lite/page.class.php @@ -10,8 +10,7 @@ class Page extends BasePage { - /** @var bool */ - public $left_enabled = true; + public bool $left_enabled = true; public function disable_left() { diff --git a/themes/lite/setup.theme.php b/themes/lite/setup.theme.php index 0740304f..4e1a2fbc 100644 --- a/themes/lite/setup.theme.php +++ b/themes/lite/setup.theme.php @@ -8,13 +8,13 @@ */ class CustomSetupTheme extends SetupTheme { - protected function sb_to_html(SetupBlock $block) + protected function sb_to_html(SetupBlock $block): string { $h = $block->header; $b = $block->body; $i = preg_replace('/[^a-zA-Z0-9]/', '_', $h) . "-setup"; $html = " - +
          $h
          $b
          diff --git a/themes/lite/user_config.theme.php b/themes/lite/user_config.theme.php index c1b6f68e..d3a4dc29 100644 --- a/themes/lite/user_config.theme.php +++ b/themes/lite/user_config.theme.php @@ -8,13 +8,13 @@ */ class CustomUserConfigTheme extends UserConfigTheme { - protected function sb_to_html(SetupBlock $block) + protected function sb_to_html(SetupBlock $block): string { $h = $block->header; $b = $block->body; $i = preg_replace('/[^a-zA-Z0-9]/', '_', $h) . "-setup"; $html = " - +
          $h
          $b
          diff --git a/themes/material/home.theme.php b/themes/material/home.theme.php index 595d42ea..bfcf3cf8 100644 --- a/themes/material/home.theme.php +++ b/themes/material/home.theme.php @@ -2,7 +2,7 @@ class CustomHomeTheme extends HomeTheme { - public function display_page(Page $page, $sitename, $base_href, $theme_name, $body) + public function display_page(Page $page, string $sitename, string $base_href, string $theme_name, string $body): void { $page->set_mode(PageMode::DATA); $page->add_auto_html_headers(); @@ -28,7 +28,7 @@ EOD ); } - public function build_body(string $sitename, string $main_links, string $main_text, string $contact_link, $num_comma, string $counter_text) + public function build_body(string $sitename, string $main_links, string $main_text, string $contact_link, $num_comma, string $counter_text): string { $message_html = empty($main_text) ? "" : "
          $main_text
          "; $counter_html = empty($counter_text) ? "" : "
          $counter_text
          "; diff --git a/themes/material/page.class.php b/themes/material/page.class.php index 8db7aa12..d0f45b27 100644 --- a/themes/material/page.class.php +++ b/themes/material/page.class.php @@ -187,7 +187,7 @@ class Page extends BasePage EOD; } - public function rework_navigation(Block $block) + public function rework_navigation(Block $block): string { // $h = $block->header; $b = $block->body; diff --git a/themes/material/view.theme.php b/themes/material/view.theme.php index f82ababc..19164e89 100644 --- a/themes/material/view.theme.php +++ b/themes/material/view.theme.php @@ -20,7 +20,7 @@ class CustomViewImageTheme extends ViewImageTheme } } - protected function build_pin(Image $image) + protected function build_pin(Image $image): string { if (isset($_GET['search'])) { $query = "search=".url_escape($_GET['search']); @@ -36,7 +36,7 @@ class CustomViewImageTheme extends ViewImageTheme } - protected function build_info(Image $image, $editor_parts) + protected function build_info(Image $image, $editor_parts): string { global $user; diff --git a/themes/rule34v2/home.theme.php b/themes/rule34v2/home.theme.php index 83604879..4e4f8681 100644 --- a/themes/rule34v2/home.theme.php +++ b/themes/rule34v2/home.theme.php @@ -2,7 +2,7 @@ class CustomHomeTheme extends HomeTheme { - public function display_page(Page $page, $sitename, $base_href, $theme_name, $body) + public function display_page(Page $page, string $sitename, string $base_href, string $theme_name, string $body): void { $page->set_mode("data"); $page->add_auto_html_headers(); @@ -36,7 +36,7 @@ EOD ); } - public function build_body(string $sitename, string $main_links, string $main_text, string $contact_link, $num_comma, string $counter_text) + public function build_body(string $sitename, string $main_links, string $main_text, string $contact_link, $num_comma, string $counter_text): string { $main_links_html = empty($main_links) ? "" : ""; $message_html = empty($main_text) ? "" : "
          $main_text
          ";