diff --git a/composer.json b/composer.json index 5b91691f..509164c6 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,7 @@ ], "require" : { - "php" : ">=7.0", + "php" : ">=7.1", "ext-pdo": "*", "flexihash/flexihash" : "^2.0.0", diff --git a/core/basethemelet.php b/core/basethemelet.php index 6f4b9060..77af37d4 100644 --- a/core/basethemelet.php +++ b/core/basethemelet.php @@ -9,13 +9,8 @@ class BaseThemelet { /** * Generic error message display - * - * @param int $code - * @param string $title - * @param string $message - * @return void */ - public function display_error(int $code, string $title, string $message) { + public function display_error(int $code, string $title, string $message): void { global $page; $page->set_code($code); $page->set_title($title); @@ -35,9 +30,8 @@ class BaseThemelet { /** * A specific, common error message - * @return void */ - public function display_permission_denied() { + public function display_permission_denied(): void { $this->display_error(403, "Permission Denied", "You do not have permission to access this page"); } @@ -45,9 +39,6 @@ class BaseThemelet { /** * Generic thumbnail code; returns HTML rather than adding * a block since thumbs tend to go inside blocks... - * - * @param Image $image - * @return string */ public function build_thumb_html(Image $image): string { global $config; diff --git a/core/block.php b/core/block.php index 02eb3484..737ca3f8 100644 --- a/core/block.php +++ b/core/block.php @@ -66,9 +66,6 @@ class Block { /** * Get the HTML for this block. - * - * @param bool $hidable - * @return string */ public function get_html(bool $hidable=false): string { $h = $this->header; diff --git a/core/config.php b/core/config.php index 8513f40c..7fee9760 100644 --- a/core/config.php +++ b/core/config.php @@ -10,44 +10,30 @@ interface Config { * Save the list of name:value pairs to wherever they came from, * so that the next time a page is loaded it will use the new * configuration. - * - * @param null|string $name - * @return void */ - public function save(string $name=null); + public function save(string $name=null): void; //@{ /*--------------------------------- SET ------------------------------------------------------*/ /** * Set a configuration option to a new value, regardless of what the value is at the moment. - * @param string $name - * @param null|int $value - * @return void */ - public function set_int(string $name, $value); + public function set_int(string $name, ?int $value): void; /** * Set a configuration option to a new value, regardless of what the value is at the moment. - * @param string $name - * @param null|string $value - * @return void */ - public function set_string(string $name, $value); + public function set_string(string $name, ?string $value): void; /** * Set a configuration option to a new value, regardless of what the value is at the moment. - * @param string $name * @param null|bool|string $value - * @return void */ - public function set_bool(string $name, $value); + public function set_bool(string $name, $value): void; /** * Set a configuration option to a new value, regardless of what the value is at the moment. - * @param string $name - * @param array $value - * @return void */ - public function set_array(string $name, array $value); + public function set_array(string $name, array $value): void; //@} /*--------------------------------------------------------------------------------------------*/ //@{ /*-------------------------------- SET DEFAULT -----------------------------------------------*/ @@ -58,12 +44,8 @@ interface Config { * This has the advantage that the values will show up in the "advanced" setup * page where they can be modified, while calling get_* with a "default" * parameter won't show up. - * - * @param string $name - * @param int $value - * @return void */ - public function set_default_int(string $name, int $value); + public function set_default_int(string $name, int $value): void; /** * Set a configuration option to a new value, if there is no value currently. @@ -72,12 +54,8 @@ interface Config { * This has the advantage that the values will show up in the "advanced" setup * page where they can be modified, while calling get_* with a "default" * parameter won't show up. - * - * @param string $name - * @param string|null $value - * @return void */ - public function set_default_string(string $name, string $value); + public function set_default_string(string $name, string $value): void; /** * Set a configuration option to a new value, if there is no value currently. @@ -86,12 +64,8 @@ interface Config { * This has the advantage that the values will show up in the "advanced" setup * page where they can be modified, while calling get_* with a "default" * parameter won't show up. - * - * @param string $name - * @param bool $value - * @return void */ - public function set_default_bool(string $name, bool $value); + public function set_default_bool(string $name, bool $value): void; /** * Set a configuration option to a new value, if there is no value currently. @@ -100,46 +74,30 @@ interface Config { * This has the advantage that the values will show up in the "advanced" setup * page where they can be modified, while calling get_* with a "default" * parameter won't show up. - * - * @param string $name - * @param array $value - * @return void */ - public function set_default_array(string $name, array $value); + public function set_default_array(string $name, array $value): void; //@} /*--------------------------------------------------------------------------------------------*/ //@{ /*--------------------------------- GET ------------------------------------------------------*/ /** * Pick a value out of the table by name, cast to the appropriate data type. - * @param string $name - * @param null|int $default - * @return int */ - public function get_int(string $name, $default=null); + public function get_int(string $name, ?int $default=null): ?int; /** * Pick a value out of the table by name, cast to the appropriate data type. - * @param string $name - * @param null|string $default - * @return string */ - public function get_string(string $name, $default=null); + public function get_string(string $name, ?string $default=null): ?string; /** * Pick a value out of the table by name, cast to the appropriate data type. - * @param string $name - * @param null|bool|string $default - * @return bool */ - public function get_bool(string $name, $default=null); + public function get_bool(string $name, ?bool $default=null): ?bool; /** * Pick a value out of the table by name, cast to the appropriate data type. - * @param string $name - * @param array|null $default - * @return array */ - public function get_array(string $name, array $default=array()); + public function get_array(string $name, ?array $default=array()): ?array; //@} /*--------------------------------------------------------------------------------------------*/ } diff --git a/core/database.php b/core/database.php index c33db38e..57720293 100644 --- a/core/database.php +++ b/core/database.php @@ -206,10 +206,6 @@ class Database { /** * Execute an SQL query and return a 2D array. - * - * @param string $query - * @param array $args - * @return array */ public function get_all(string $query, array $args=array()): array { $_start = microtime(true); @@ -220,10 +216,6 @@ class Database { /** * Execute an SQL query and return a single row. - * - * @param string $query - * @param array $args - * @return array|null */ public function get_row(string $query, array $args=array()) { $_start = microtime(true); @@ -234,10 +226,6 @@ class Database { /** * Execute an SQL query and return the first column of each row. - * - * @param string $query - * @param array $args - * @return array */ public function get_col(string $query, array $args=array()): array { $_start = microtime(true); @@ -252,10 +240,6 @@ class Database { /** * Execute an SQL query and return the the first row => the second row. - * - * @param string $query - * @param array $args - * @return array */ public function get_pairs(string $query, array $args=array()): array { $_start = microtime(true); @@ -270,10 +254,6 @@ class Database { /** * Execute an SQL query and return a single value. - * - * @param string $query - * @param array $args - * @return mixed|null */ public function get_one(string $query, array $args=array()) { $_start = microtime(true); @@ -284,9 +264,6 @@ class Database { /** * Get the ID of the last inserted row. - * - * @param string|null $seq - * @return int */ public function get_last_insert_id(string $seq): int { if($this->engine->name == "pgsql") { @@ -299,11 +276,8 @@ class Database { /** * Create a table from pseudo-SQL. - * - * @param string $name - * @param string $data */ - public function create_table(string $name, string $data) { + public function create_table(string $name, string $data): void { if(is_null($this->engine)) { $this->connect_engine(); } $data = trim($data, ", \t\n\r\0\x0B"); // mysql doesn't like trailing commas $this->execute($this->engine->create_table_sql($name, $data)); @@ -312,7 +286,6 @@ class Database { /** * Returns the number of tables present in the current database. * - * @return int * @throws SCoreException */ public function count_tables(): int { diff --git a/core/event.php b/core/event.php index 1544f920..3010da6f 100644 --- a/core/event.php +++ b/core/event.php @@ -75,9 +75,6 @@ class PageRequestEvent extends Event { * Test if the requested path matches a given pattern. * * If it matches, store the remaining path elements in $args - * - * @param string $name - * @return bool */ public function page_matches(string $name): bool { $parts = explode("/", $name); @@ -98,11 +95,8 @@ class PageRequestEvent extends Event { /** * Get the n th argument of the page request (if it exists.) - * - * @param int $n - * @return string|null The argument (string) or NULL */ - public function get_arg(int $n) { + public function get_arg(int $n): ?string { $offset = $this->part_count + $n; if($offset >= 0 && $offset < $this->arg_count) { return $this->args[$offset]; @@ -114,7 +108,6 @@ class PageRequestEvent extends Event { /** * Returns the number of arguments the page request has. - * @return int */ public function count_args(): int { return int_escape($this->arg_count - $this->part_count); @@ -166,7 +159,7 @@ class CommandEvent extends Event { public $args = array(); /** - * @param string[] $args + * #param string[] $args */ public function __construct(array $args) { global $user; diff --git a/core/extension.php b/core/extension.php index f07f074e..5aaf3975 100644 --- a/core/extension.php +++ b/core/extension.php @@ -102,11 +102,8 @@ abstract class Extension { /** * Find the theme object for a given extension. - * - * @param string $base - * @return Themelet|null */ - private function get_theme_object(string $base) { + private function get_theme_object(string $base): ?Themelet { $custom = 'Custom'.$base.'Theme'; $normal = $base.'Theme'; @@ -124,7 +121,6 @@ abstract class Extension { /** * Override this to change the priority of the extension, * lower numbered ones will receive events first. - * @return int */ public function get_priority(): int { return 50; diff --git a/core/imageboard/event.php b/core/imageboard/event.php index 916ea597..ff7def1c 100644 --- a/core/imageboard/event.php +++ b/core/imageboard/event.php @@ -14,9 +14,6 @@ class ImageAdditionEvent extends Event { * Inserts a new image into the database with its associated * information. Also calls TagSetEvent to set the tags for * this new image. - * - * @see TagSetEvent - * @param Image $image The new image to add. */ public function __construct(Image $image) { $this->image = $image; @@ -43,8 +40,6 @@ class ImageDeletionEvent extends Event { * * Used by things like tags and comments handlers to * clean out related rows in their tables. - * - * @param Image $image The image being deleted. */ public function __construct(Image $image) { $this->image = $image; @@ -66,9 +61,6 @@ class ImageReplaceEvent extends Event { * Updates an existing ID in the database to use a new image * file, leaving the tags and such unchanged. Also removes * the old image file and thumbnail from the disk. - * - * @param int $id The ID of the image to replace. - * @param Image $image The image object of the new image to use. */ public function __construct(int $id, Image $image) { $this->id = $id; @@ -98,10 +90,6 @@ class ThumbnailGenerationEvent extends Event { /** * Request a thumbnail be made for an image object - * - * @param string $hash The unique hash of the image - * @param string $type The type of the image - * @param bool $force Regenerate the thumbnail even if one already exists */ public function __construct(string $hash, string $type, bool $force=false) { $this->hash = $hash; @@ -125,17 +113,13 @@ class ParseLinkTemplateEvent extends Event { /** @var \Image */ public $image; - /** - * @param string $link The formatted link - * @param Image $image The image who's link is being parsed - */ public function __construct(string $link, Image $image) { $this->link = $link; $this->original = $link; $this->image = $image; } - public function replace(string $needle, string $replace) { + public function replace(string $needle, string $replace): void { $this->link = str_replace($needle, $replace, $this->link); } } diff --git a/core/imageboard/image.php b/core/imageboard/image.php index f3fce5e7..7fa9d2e5 100644 --- a/core/imageboard/image.php +++ b/core/imageboard/image.php @@ -53,10 +53,8 @@ class Image { /** * One will very rarely construct an image directly, more common * would be to use Image::by_id, Image::by_hash, etc. - * - * @param null|mixed[] $row */ - public function __construct(array $row=null) { + public function __construct(?array $row=null) { if(!is_null($row)) { foreach($row as $name => $value) { // some databases use table.name rather than name @@ -95,11 +93,8 @@ class Image { /** * Search for an array of images * - * @param int $start - * @param int $limit - * @param string[] $tags - * @throws SCoreException - * @return Image[] + * #param string[] $tags + * #return Image[] */ public static function find_images(int $start, int $limit, array $tags=array()): array { global $database, $user, $config; @@ -209,8 +204,7 @@ class Image { /** * Count the number of image results for a given search * - * @param string[] $tags - * @return int + * #param string[] $tags */ public static function count_images(array $tags=array()): int { global $database; @@ -242,8 +236,7 @@ class Image { /** * Count the number of pages for a given search * - * @param string[] $tags - * @return float + * #param string[] $tags */ public static function count_pages(array $tags=array()): float { global $config; @@ -260,11 +253,9 @@ class Image { * Rather than simply $this_id + 1, one must take into account * deleted images and search queries * - * @param string[] $tags - * @param bool $next - * @return Image + * #param string[] $tags */ - public function get_next(array $tags=array(), bool $next=true) { + public function get_next(array $tags=array(), bool $next=true): ?Image { global $database; if($next) { @@ -298,26 +289,21 @@ class Image { /** * The reverse of get_next * - * @param string[] $tags - * @return Image + * #param string[] $tags */ - public function get_prev(array $tags=array()) { + public function get_prev(array $tags=array()): ?Image { return $this->get_next($tags, false); } /** * Find the User who owns this Image - * - * @return User */ - public function get_owner() { + public function get_owner(): User { return User::by_id($this->owner_id); } /** * Set the image's owner. - * - * @param User $owner */ public function set_owner(User $owner) { global $database; @@ -327,16 +313,16 @@ class Image { SET owner_id=:owner_id WHERE id=:id ", array("owner_id"=>$owner->id, "id"=>$this->id)); - log_info("core_image", "Owner for Image #{$this->id} set to {$owner->name}", false, array("image_id" => $this->id)); + log_info("core_image", "Owner for Image #{$this->id} set to {$owner->name}", null, array("image_id" => $this->id)); } } /** * Get this image's tags as an array. * - * @return string[] + * #return string[] */ - public function get_tag_array() { + public function get_tag_array(): array { global $database; if(!isset($this->tag_array)) { $this->tag_array = $database->get_col(" @@ -352,40 +338,29 @@ class Image { /** * Get this image's tags as a string. - * - * @return string */ - public function get_tag_list() { + public function get_tag_list(): string { return Tag::implode($this->get_tag_array()); } /** * Get the URL for the full size image - * - * @return string */ - public function get_image_link() { + public function get_image_link(): string { return $this->get_link('image_ilink', '_images/$hash/$id%20-%20$tags.$ext', 'image/$id.$ext'); } /** * Get the URL for the thumbnail - * - * @return string */ - public function get_thumb_link() { + public function get_thumb_link(): string { return $this->get_link('image_tlink', '_thumbs/$hash/thumb.jpg', 'thumb/$id.jpg'); } /** * Check configured template for a link, then try nice URL, then plain URL - * - * @param string $template - * @param string $nice - * @param string $plain - * @return string */ - private function get_link($template, $nice, $plain) { + private function get_link(string $template, string $nice, string $plain): string { global $config; $image_link = $config->get_string($template); @@ -407,10 +382,8 @@ class Image { /** * Get the tooltip for this image, formatted according to the * configured template. - * - * @return string */ - public function get_tooltip() { + public function get_tooltip(): string { global $config; $tt = $this->parse_link_template($config->get_string('image_tip'), "no_escape"); @@ -436,86 +409,67 @@ class Image { /** * Figure out where the full size image is on disk. - * - * @return string */ - public function get_image_filename() { + public function get_image_filename(): string { return warehouse_path("images", $this->hash); } /** * Figure out where the thumbnail is on disk. - * - * @return string */ - public function get_thumb_filename() { + public function get_thumb_filename(): string { return warehouse_path("thumbs", $this->hash); } /** * Get the original filename. - * - * @return string */ - public function get_filename() { + public function get_filename(): string { return $this->filename; } /** * Get the image's mime type. - * - * @return string */ - public function get_mime_type() { + public function get_mime_type(): string { return getMimeType($this->get_image_filename(), $this->get_ext()); } /** * Get the image's filename extension - * - * @return string */ - public function get_ext() { + public function get_ext(): string { return $this->ext; } /** * Get the image's source URL - * - * @return string */ - public function get_source() { + public function get_source(): string { return $this->source; } /** * Set the image's source URL - * - * @param string $new_source */ - public function set_source(string $new_source) { + public function set_source(string $new_source): void { global $database; $old_source = $this->source; if(empty($new_source)) $new_source = null; if($new_source != $old_source) { $database->execute("UPDATE images SET source=:source WHERE id=:id", array("source"=>$new_source, "id"=>$this->id)); - log_info("core_image", "Source for Image #{$this->id} set to: $new_source (was $old_source)", false, array("image_id" => $this->id)); + log_info("core_image", "Source for Image #{$this->id} set to: $new_source (was $old_source)", null, array("image_id" => $this->id)); } } /** * Check if the image is locked. - * @return bool */ - public function is_locked() { + public function is_locked(): bool { return $this->locked; } - /** - * @param bool $tf - * @throws SCoreException - */ - public function set_locked($tf) { + public function set_locked(bool $tf) { global $database; $ln = $tf ? "Y" : "N"; $sln = $database->scoreql_to_sql('SCORE_BOOL_'.$ln); @@ -523,7 +477,7 @@ class Image { $sln = str_replace('"', "", $sln); if(bool_escape($sln) !== $this->locked) { $database->execute("UPDATE images SET locked=:yn WHERE id=:id", array("yn"=>$sln, "id"=>$this->id)); - log_info("core_image", "Setting Image #{$this->id} lock to: $ln", false, array("image_id" => $this->id)); + log_info("core_image", "Setting Image #{$this->id} lock to: $ln", null, array("image_id" => $this->id)); } } @@ -532,7 +486,7 @@ class Image { * * Normally in preparation to set them to a new set. */ - public function delete_tags_from_image() { + public function delete_tags_from_image(): void { global $database; if($database->get_driver_name() == "mysql") { //mysql < 5.6 has terrible subquery optimization, using EXISTS / JOIN fixes this @@ -633,10 +587,9 @@ class Image { /** * Send list of metatags to be parsed. * - * @param string[] $metatags - * @param int $image_id + * #param string[] $metatags */ - public function parse_metatags($metatags, $image_id) { + public function parse_metatags(array $metatags, int $image_id): void { foreach($metatags as $tag) { $ttpe = new TagTermParseEvent($tag, $image_id, TRUE); send_event($ttpe); @@ -646,11 +599,11 @@ class Image { /** * Delete this image from the database and disk */ - public function delete() { + public function delete(): void { global $database; $this->delete_tags_from_image(); $database->execute("DELETE FROM images WHERE id=:id", array("id"=>$this->id)); - log_info("core_image", 'Deleted Image #'.$this->id.' ('.$this->hash.')', false, array("image_id" => $this->id)); + log_info("core_image", 'Deleted Image #'.$this->id.' ('.$this->hash.')', null, array("image_id" => $this->id)); unlink($this->get_image_filename()); unlink($this->get_thumb_filename()); @@ -660,20 +613,13 @@ class Image { * This function removes an image (and thumbnail) from the DISK ONLY. * It DOES NOT remove anything from the database. */ - public function remove_image_only() { - log_info("core_image", 'Removed Image File ('.$this->hash.')', false, array("image_id" => $this->id)); + public function remove_image_only(): void { + log_info("core_image", 'Removed Image File ('.$this->hash.')', null, array("image_id" => $this->id)); @unlink($this->get_image_filename()); @unlink($this->get_thumb_filename()); } - /** - * Someone please explain this - * - * @param string $tmpl - * @param string $_escape - * @return string - */ - public function parse_link_template($tmpl, $_escape="url_escape", $n=0) { + public function parse_link_template(string $tmpl, string $_escape="url_escape", int $n=0): string { global $config; // don't bother hitting the database if it won't be used... @@ -746,8 +692,7 @@ class Image { } /** - * @param string[] $terms - * @return \Querylet + * #param string[] $terms */ private static function build_search_querylet(array $terms): Querylet { global $database; @@ -888,8 +833,7 @@ class Image { * All the subqueries are executed every time for every row in the * images table. Yes, MySQL does suck this much. * - * @param TagQuerylet[] $tag_querylets - * @return Querylet + * #param TagQuerylet[] $tag_querylets */ private static function build_accurate_search_querylet(array $tag_querylets): Querylet { global $database; @@ -950,10 +894,9 @@ class Image { * this function exists because mysql is a turd, see the docs for * build_accurate_search_querylet() for a full explanation * - * @param TagQuerylet[] $tag_querylets - * @return Querylet + * #param TagQuerylet[] $tag_querylets */ - private static function build_ugly_search_querylet($tag_querylets) { + private static function build_ugly_search_querylet(array $tag_querylets): Querylet { global $database; $positive_tag_count = 0; diff --git a/core/imageboard/misc.php b/core/imageboard/misc.php index cbc0e723..3f7fc599 100644 --- a/core/imageboard/misc.php +++ b/core/imageboard/misc.php @@ -7,7 +7,6 @@ * Move a file from PHP's temporary area into shimmie's image storage * hierarchy, or throw an exception trying. * - * @param DataUploadEvent $event * @throws UploadException */ function move_upload_to_archive(DataUploadEvent $event) { @@ -24,10 +23,9 @@ function move_upload_to_archive(DataUploadEvent $event) { /** * Add a directory full of images * - * @param $base string - * @return array|string[] + * #return string[] */ -function add_dir($base) { +function add_dir(string $base): array { $results = array(); foreach(list_files($base) as $full_path) { @@ -49,13 +47,7 @@ function add_dir($base) { return $results; } -/** - * @param string $tmpname - * @param string $filename - * @param string $tags - * @throws UploadException - */ -function add_image($tmpname, $filename, $tags) { +function add_image(string $tmpname, string $filename, string $tags): void { assert(file_exists($tmpname)); $pathinfo = pathinfo($filename); @@ -78,11 +70,9 @@ function add_image($tmpname, $filename, $tags) { * Given a full size pair of dimensions, return a pair scaled down to fit * into the configured thumbnail square, with ratio intact * - * @param int $orig_width - * @param int $orig_height - * @return integer[] + * #return int[] */ -function get_thumbnail_size(int $orig_width, int $orig_height) { +function get_thumbnail_size(int $orig_width, int $orig_height): array { global $config; if($orig_width === 0) $orig_width = 192; diff --git a/core/imageboard/tag.php b/core/imageboard/tag.php index e3e7df7b..594c731b 100644 --- a/core/imageboard/tag.php +++ b/core/imageboard/tag.php @@ -18,9 +18,7 @@ class Tag { /** * Turn a human-supplied string into a valid tag array. * - * @param string $tags - * @param bool $tagme add "tagme" if the string is empty - * @return string[] + * #return string[] */ public static function explode(string $tags, bool $tagme=true): array { global $database; diff --git a/core/logging.php b/core/logging.php index b39c4137..85d60c3e 100644 --- a/core/logging.php +++ b/core/logging.php @@ -16,74 +16,29 @@ define("SCORE_LOG_NOTSET", 0); * When parsing a user request, a flash message should give info to the user * When taking action, a log event should be stored by the server * Quite often, both of these happen at once, hence log_*() having $flash - * - * $flash = null (default) - log to server only, no flash message - * $flash = true - show the message to the user as well - * $flash = "some string" - log the message, flash the string - * - * @param string $section - * @param int $priority - * @param string $message - * @param bool|string $flash - * @param array $args */ -function log_msg(string $section, int $priority, string $message, $flash=false, $args=array()) { +function log_msg(string $section, int $priority, string $message, ?string $flash=null, $args=array()) { send_event(new LogEvent($section, $priority, $message, $args)); $threshold = defined("CLI_LOG_LEVEL") ? CLI_LOG_LEVEL : 0; if((PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') && ($priority >= $threshold)) { print date("c")." $section: $message\n"; } - if($flash === true) { - flash_message($message); - } - else if(is_string($flash)) { + if(!is_null($flash)) { flash_message($flash); } } // More shorthand ways of logging -/** - * @param string $section - * @param string $message - * @param bool|string $flash - * @param array $args - */ -function log_debug( string $section, string $message, $flash=false, $args=array()) {log_msg($section, SCORE_LOG_DEBUG, $message, $flash, $args);} -/** - * @param string $section - * @param string $message - * @param bool|string $flash - * @param array $args - */ -function log_info( string $section, string $message, $flash=false, $args=array()) {log_msg($section, SCORE_LOG_INFO, $message, $flash, $args);} -/** - * @param string $section - * @param string $message - * @param bool|string $flash - * @param array $args - */ -function log_warning( string $section, string $message, $flash=false, $args=array()) {log_msg($section, SCORE_LOG_WARNING, $message, $flash, $args);} -/** - * @param string $section - * @param string $message - * @param bool|string $flash - * @param array $args - */ -function log_error( string $section, string $message, $flash=false, $args=array()) {log_msg($section, SCORE_LOG_ERROR, $message, $flash, $args);} -/** - * @param string $section - * @param string $message - * @param bool|string $flash - * @param array $args - */ -function log_critical(string $section, string $message, $flash=false, $args=array()) {log_msg($section, SCORE_LOG_CRITICAL, $message, $flash, $args);} +function log_debug( string $section, string $message, ?string $flash=null, $args=array()) {log_msg($section, SCORE_LOG_DEBUG, $message, $flash, $args);} +function log_info( string $section, string $message, ?string $flash=null, $args=array()) {log_msg($section, SCORE_LOG_INFO, $message, $flash, $args);} +function log_warning( string $section, string $message, ?string $flash=null, $args=array()) {log_msg($section, SCORE_LOG_WARNING, $message, $flash, $args);} +function log_error( string $section, string $message, ?string $flash=null, $args=array()) {log_msg($section, SCORE_LOG_ERROR, $message, $flash, $args);} +function log_critical(string $section, string $message, ?string $flash=null, $args=array()) {log_msg($section, SCORE_LOG_CRITICAL, $message, $flash, $args);} /** * Get a unique ID for this request, useful for grouping log messages. - * - * @return string */ function get_request_id(): string { static $request_id = null; diff --git a/core/page.php b/core/page.php index 83960e19..c0f85ed0 100644 --- a/core/page.php +++ b/core/page.php @@ -45,7 +45,6 @@ class Page { /** * Set what this page should do; "page", "data", or "redirect". - * @param string $mode */ public function set_mode(string $mode) { $this->mode = $mode; @@ -53,7 +52,6 @@ class Page { /** * Set the page's MIME type. - * @param string $type */ public function set_type(string $type) { $this->type = $type; @@ -73,7 +71,6 @@ class Page { /** * Set the raw data to be sent. - * @param string $data */ public function set_data(string $data) { $this->data = $data; @@ -81,7 +78,6 @@ class Page { /** * Set the recommended download filename. - * @param string $filename */ public function set_filename(string $filename) { $this->filename = $filename; @@ -99,7 +95,6 @@ class Page { /** * Set the URL to redirect to (remember to use make_link() if linking * to a page in the same site). - * @param string $redirect */ public function set_redirect(string $redirect) { $this->redirect = $redirect; @@ -140,40 +135,35 @@ class Page { /** * Set the HTTP status code - * @param int $code */ - public function set_code(int $code) { + public function set_code(int $code): void { $this->code = $code; } - public function set_title(string $title) { + public function set_title(string $title): void { $this->title = $title; } - public function set_heading(string $heading) { + public function set_heading(string $heading): void { $this->heading = $heading; } - public function set_subheading(string $subheading) { + public function set_subheading(string $subheading): void { $this->subheading = $subheading; } /** * Add a line to the HTML head section. - * @param string $line - * @param int $position */ - public function add_html_header(string $line, int $position=50) { + public function add_html_header(string $line, int $position=50): void { while(isset($this->html_headers[$position])) $position++; $this->html_headers[$position] = $line; } /** * Add a http header to be sent to the client. - * @param string $line - * @param int $position */ - public function add_http_header(string $line, int $position=50) { + public function add_http_header(string $line, int $position=50): void { while(isset($this->http_headers[$position])) $position++; $this->http_headers[$position] = $line; } @@ -182,22 +172,13 @@ class Page { * The counterpart for get_cookie, this works like php's * setcookie method, but prepends the site-wide cookie prefix to * the $name argument before doing anything. - * - * @param string $name - * @param string $value - * @param int $time - * @param string $path */ - public function add_cookie(string $name, $value, $time, $path) { + public function add_cookie(string $name, string $value, int $time, string $path): void { $full_name = COOKIE_PREFIX."_".$name; $this->cookies[] = array($full_name, $value, $time, $path); } - /** - * @param string $name - * @return string|null - */ - public function get_cookie(string $name) { + public function get_cookie(string $name): ?string { $full_name = COOKIE_PREFIX."_".$name; if(isset($_COOKIE[$full_name])) { return $_COOKIE[$full_name]; @@ -209,7 +190,6 @@ class Page { /** * Get all the HTML headers that are currently set and return as a string. - * @return string */ public function get_all_html_headers(): string { $data = ''; @@ -223,13 +203,12 @@ class Page { /** * Removes all currently set HTML headers (Be careful..). */ - public function delete_all_html_headers() { + public function delete_all_html_headers(): void { $this->html_headers = array(); } /** * Add a Block of data to the page. - * @param Block $block */ public function add_block(Block $block) { $this->blocks[] = $block; @@ -242,7 +221,7 @@ class Page { /** * Display the page according to the mode and data given. */ - public function display() { + public function display(): void { global $page, $user; header("HTTP/1.0 {$this->code} Shimmie"); @@ -314,7 +293,7 @@ class Page { * * TODO: This should really be configurable somehow... */ - public function add_auto_html_headers() { + public function add_auto_html_headers(): void { global $config; $data_href = get_base_href(); diff --git a/core/polyfills.php b/core/polyfills.php index 3a19e636..8081a0db 100644 --- a/core/polyfills.php +++ b/core/polyfills.php @@ -5,10 +5,6 @@ /** * Remove an item from an array - * - * @param array $array - * @param mixed $to_remove - * @return array */ function array_remove(array $array, $to_remove): array { $array = array_unique($array); @@ -25,10 +21,6 @@ function array_remove(array $array, $to_remove): array { * Adds an item to an array. * * Also removes duplicate values from the array. - * - * @param array $array - * @param mixed $element - * @return array */ function array_add(array $array, $element): array { // Could we just use array_push() ? @@ -40,9 +32,6 @@ function array_add(array $array, $element): array { /** * Return the unique elements of an array, case insensitively - * - * @param array $array - * @return array */ function array_iunique(array $array): array { $ok = array(); @@ -64,10 +53,6 @@ function array_iunique(array $array): array { * Figure out if an IP is in a specified range * * from http://uk.php.net/network - * - * @param string $IP - * @param string $CIDR - * @return bool */ function ip_in_range(string $IP, string $CIDR): bool { list ($net, $mask) = explode("/", $CIDR); @@ -87,8 +72,6 @@ function ip_in_range(string $IP, string $CIDR): bool { * * from a patch by Christian Walde; only intended for use in the * "extension manager" extension, but it seems to fit better here - * - * @param string $f */ function deltree(string $f) { //Because Windows (I know, bad excuse) @@ -132,9 +115,6 @@ function deltree(string $f) { * Copy an entire file hierarchy * * from a comment on http://uk.php.net/copy - * - * @param string $source - * @param string $target */ function full_copy(string $source, string $target) { if(is_dir($source)) { @@ -163,10 +143,6 @@ function full_copy(string $source, string $target) { /** * Return a list of all the regular files in a directory and subdirectories - * - * @param string $base - * @param string $_sub_dir - * @return array file list */ function list_files(string $base, string $_sub_dir=""): array { assert(is_dir($base)); @@ -208,10 +184,9 @@ function list_files(string $base, string $_sub_dir=""): array { if (!function_exists('http_parse_headers')) { #http://www.php.net/manual/en/function.http-parse-headers.php#112917 /** - * @param string $raw_headers - * @return string[] + * #return string[] */ - function http_parse_headers ($raw_headers){ + function http_parse_headers (string $raw_headers): array { $headers = array(); // $headers = []; foreach (explode("\n", $raw_headers) as $i => $h) { @@ -236,17 +211,13 @@ if (!function_exists('http_parse_headers')) { #http://www.php.net/manual/en/func /** * HTTP Headers can sometimes be lowercase which will cause issues. * In cases like these, we need to make sure to check for them if the camelcase version does not exist. - * - * @param array $headers - * @param string $name - * @return string|bool */ -function findHeader(array $headers, string $name) { +function findHeader(array $headers, string $name): ?string { if (!is_array($headers)) { - return false; + return null; } - $header = false; + $header = null; if(array_key_exists($name, $headers)) { $header = $headers[$name]; @@ -296,10 +267,6 @@ const MIME_TYPE_MAP = [ * The contents of this function are taken from the __getMimeType() function * from the "Amazon S3 PHP class" which is Copyright (c) 2008, Donovan Schönknecht * and released under the 'Simplified BSD License'. - * - * @param string $file File path - * @param string $ext - * @return string */ function getMimeType(string $file, string $ext=""): string { // Static extension lookup @@ -332,24 +299,17 @@ function getMimeType(string $file, string $ext=""): string { return 'application/octet-stream'; } -/** - * @param string $mime_type - * @return bool|string - */ -function getExtension(string $mime_type) { +function getExtension(?string $mime_type): ?string { if(empty($mime_type)){ - return false; + return null; } $ext = array_search($mime_type, MIME_TYPE_MAP); - return ($ext ? $ext : false); + return ($ext ? $ext : null); } /** * Like glob, with support for matching very long patterns with braces. - * - * @param string $pattern - * @return array */ function zglob(string $pattern): array { $results = array(); @@ -375,8 +335,6 @@ function zglob(string $pattern): array { * function should return /gallery * * PHP really, really sucks. - * - * @return string */ function get_base_href(): string { if(defined("BASE_HREF")) return BASE_HREF; @@ -413,31 +371,22 @@ function endsWith(string $haystack, string $needle): bool { /** * Make some data safe for printing into HTML - * - * @param string $input - * @return string */ -function html_escape($input): string { +function html_escape(string $input): string { return htmlentities($input, ENT_QUOTES, "UTF-8"); } /** * Unescape data that was made safe for printing into HTML - * - * @param string $input - * @return string */ -function html_unescape($input): string { +function html_unescape(string $input): string { return html_entity_decode($input, ENT_QUOTES, "UTF-8"); } /** * Make sure some data is safe to be used in integer context - * - * @param string $input - * @return int */ -function int_escape($input): int { +function int_escape(string $input): int { /* Side note, Casting to an integer is FASTER than using intval. http://hakre.wordpress.com/2010/05/13/php-casting-vs-intval/ @@ -447,11 +396,8 @@ function int_escape($input): int { /** * Make sure some data is safe to be used in URL context - * - * @param string $input - * @return string */ -function url_escape($input): string { +function url_escape(string $input): string { /* Shish: I have a feeling that these three lines are important, possibly for searching for tags with slashes in them like fate/stay_night green-ponies: indeed~ @@ -482,11 +428,8 @@ function url_escape($input): string { /** * Make sure some data is safe to be used in SQL context - * - * @param string $input - * @return string */ -function sql_escape($input): string { +function sql_escape(string $input): string { global $database; return $database->escape($input); } @@ -494,9 +437,6 @@ function sql_escape($input): string { /** * Turn all manner of HTML / INI / JS / DB booleans into a PHP one - * - * @param mixed $input - * @return boolean */ function bool_escape($input): bool { /* @@ -530,11 +470,8 @@ function bool_escape($input): bool { /** * Some functions require a callback function for escaping, * but we might not want to alter the data - * - * @param string $input - * @return string */ -function no_escape($input) { +function no_escape(string $input): string { return $input; } @@ -573,14 +510,8 @@ function xml_tag(string $name, array $attrs=array(), array $children=array()): s /** * Original PHP code by Chirp Internet: www.chirp.com.au * Please acknowledge use of this code by including this header. - * - * @param string $string input data - * @param int $limit how long the string should be - * @param string $break where to break the string - * @param string $pad what to add to the end of the string after truncating - * @return string */ -function truncate($string, $limit, $break=" ", $pad="...") { +function truncate(string $string, int $limit, string $break=" ", string $pad="..."): string{ // return with no change if string is shorter than $limit if(strlen($string) <= $limit) return $string; @@ -596,9 +527,6 @@ function truncate($string, $limit, $break=" ", $pad="...") { /** * Turn a human readable filesize into an integer, eg 1KB -> 1024 - * - * @param string $limit - * @return int */ function parse_shorthand_int(string $limit): int { if(preg_match('/^([\d\.]+)([gmk])?b?$/i', (string)$limit, $m)) { @@ -622,9 +550,6 @@ function parse_shorthand_int(string $limit): int { /** * Turn an integer into a human readable filesize, eg 1024 -> 1KB - * - * @param integer $int - * @return string */ function to_shorthand_int(int $int): string { assert($int >= 0); @@ -646,10 +571,6 @@ function to_shorthand_int(int $int): string { /** * Turn a date into a time, a date, an "X minutes ago...", etc - * - * @param string $date - * @param bool $html - * @return string */ function autodate(string $date, bool $html=true): string { $cpu = date('c', strtotime($date)); @@ -659,9 +580,6 @@ function autodate(string $date, bool $html=true): string { /** * Check if a given string is a valid date-time. ( Format: yyyy-mm-dd hh:mm:ss ) - * - * @param string $dateTime - * @return bool */ function isValidDateTime(string $dateTime): bool { if (preg_match("/^(\d{4})-(\d{2})-(\d{2}) ([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])$/", $dateTime, $matches)) { @@ -675,9 +593,6 @@ function isValidDateTime(string $dateTime): bool { /** * Check if a given string is a valid date. ( Format: yyyy-mm-dd ) - * - * @param string $date - * @return bool */ function isValidDate(string $date): bool { if (preg_match("/^(\d{4})-(\d{2})-(\d{2})$/", $date, $matches)) { diff --git a/core/send_event.php b/core/send_event.php index 473e0bc6..55328935 100644 --- a/core/send_event.php +++ b/core/send_event.php @@ -57,11 +57,7 @@ function _set_event_listeners() { } } -/** - * @param array $event_listeners - * @param string $path - */ -function _dump_event_listeners($event_listeners, $path) { +function _dump_event_listeners(array $event_listeners, string $path): void { $p = "<"."?php\n"; foreach(get_declared_classes() as $class) { @@ -86,10 +82,6 @@ function _dump_event_listeners($event_listeners, $path) { file_put_contents($path, $p); } -/** - * @param string $ext_name Main class name (eg ImageIO as opposed to ImageIOTheme or ImageIOTest) - * @return bool - */ function ext_is_live(string $ext_name): bool { if (class_exists($ext_name)) { /** @var Extension $ext */ @@ -106,10 +98,8 @@ $_shm_event_count = 0; /** * Send an event to all registered Extensions. - * - * @param Event $event */ -function send_event(Event $event) { +function send_event(Event $event): void { global $_shm_event_listeners, $_shm_event_count, $_shm_ctx; if(!isset($_shm_event_listeners[get_class($event)])) return; $method_name = "on".str_replace("Event", "", get_class($event)); diff --git a/core/sys_config.php b/core/sys_config.php index 7f07e6db..8c26f2a9 100644 --- a/core/sys_config.php +++ b/core/sys_config.php @@ -40,7 +40,7 @@ _d("TIMEZONE", null); // string timezone _d("CORE_EXTS", "bbcode,user,mail,upload,image,view,handle_pixel,ext_manager,setup,upgrade,handle_404,handle_static,comment,tag_list,index,tag_edit,alias_editor"); // extensions to always enable _d("EXTRA_EXTS", ""); // string optional extra extensions _d("BASE_URL", null); // string force a specific base URL (default is auto-detect) -_d("MIN_PHP_VERSION", '7.0');// string minimum supported PHP version +_d("MIN_PHP_VERSION", '7.1');// string minimum supported PHP version _d("SLOW_PAGES", null); // float log pages which take more time than this _d("ENABLED_MODS", "imageboard"); diff --git a/core/urls.php b/core/urls.php index eceb44c5..7185e839 100644 --- a/core/urls.php +++ b/core/urls.php @@ -8,12 +8,8 @@ * things like the nice URLs setting. * * eg make_link("post/list") becomes "/v2/index.php?q=post/list" - * - * @param null|string $page - * @param null|string $query - * @return string */ -function make_link(string $page=null, string $query=null): string { +function make_link(?string $page=null, ?string $query=null): string { global $config; if(is_null($page)) $page = $config->get_string('main_page'); @@ -47,9 +43,6 @@ function make_link(string $page=null, string $query=null): string { /** * Take the current URL and modify some parameters - * - * @param array $changes - * @return string */ function modify_current_url(array $changes): string { return modify_url($_SERVER['QUERY_STRING'], $changes); @@ -89,11 +82,8 @@ function modify_url(string $url, array $changes): string { /** * Turn a relative link into an absolute one, including hostname - * - * @param string $link - * @return string */ -function make_http(string $link) { +function make_http(string $link): string { if(strpos($link, "://") > 0) { return $link; } diff --git a/core/user.php b/core/user.php index 49868789..68676738 100644 --- a/core/user.php +++ b/core/user.php @@ -1,11 +1,6 @@ get_string("theme", "default"); @@ -27,11 +18,7 @@ function get_theme(): string { return $theme; } -/** - * Gets contact link as mailto: or http: - * @return string|null - */ -function contact_link() { +function contact_link(): ?string { global $config; $text = $config->get_string('contact_link'); if(is_null($text)) return null; @@ -57,8 +44,6 @@ function contact_link() { /** * Check if HTTPS is enabled for the server. - * - * @return bool True if HTTPS is enabled */ function is_https_enabled(): bool { return (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off'); @@ -66,12 +51,8 @@ function is_https_enabled(): bool { /** * Compare two Block objects, used to sort them before being displayed - * - * @param Block $a - * @param Block $b - * @return int */ -function blockcmp(Block $a, Block $b) { +function blockcmp(Block $a, Block $b): int { if($a->position == $b->position) { return 0; } @@ -82,8 +63,6 @@ function blockcmp(Block $a, Block $b) { /** * Figure out PHP's internal memory limit - * - * @return int */ function get_memory_limit(): int { global $config; @@ -131,9 +110,6 @@ function get_memory_limit(): int { /** * Get the currently active IP, masked to make it not change when the last * octet or two change, for use in session cookies and such - * - * @param Config $config - * @return string */ function get_session_ip(Config $config): string { $mask = $config->get_string("session_hash_mask", "255.255.0.0"); @@ -151,9 +127,6 @@ function get_session_ip(Config $config): string { * Generally one should flash a message in onPageRequest and log a message wherever * the action actually takes place (eg onWhateverElse) - but much of the time, actions * are taken from within onPageRequest... - * - * @param string $text - * @param string $type */ function flash_message(string $text, string $type="info") { global $page; @@ -168,9 +141,6 @@ function flash_message(string $text, string $type="info") { /** * A shorthand way to send a TextFormattingEvent and get the results. - * - * @param string $string - * @return string */ function format_text(string $string): string { $tfe = new TextFormattingEvent($string); @@ -197,12 +167,7 @@ function data_path(string $filename): string { return $filename; } -/** - * @param string $url - * @param string $mfile - * @return array|bool - */ -function transload(string $url, string $mfile) { +function transload(string $url, string $mfile): ?array { global $config; if($config->get_string("transload_engine") === "curl" && function_exists("curl_init")) { @@ -241,7 +206,7 @@ function transload(string $url, string $mfile) { $fp_in = @fopen($url, "r"); $fp_out = fopen($mfile, "w"); if(!$fp_in || !$fp_out) { - return false; + return null; } $length = 0; while(!feof($fp_in) && $length <= $config->get_int('upload_size')) { @@ -257,16 +222,13 @@ function transload(string $url, string $mfile) { return $headers; } - return false; + return null; } /** * Get the active contents of a .php file - * - * @param string $fname - * @return string|null */ -function manual_include(string $fname) { +function manual_include(string $fname): ?string { static $included = array(); if(!file_exists($fname)) return null; @@ -321,8 +283,6 @@ $_shm_load_start = microtime(true); /** * Collects some debug information (execution time, memory usage, queries, etc) * and formats it to stick in the footer of the page. - * - * @return string debug info to add to the page. */ function get_debug_info(): string { global $config, $_shm_event_count, $database, $_shm_load_start; @@ -380,8 +340,7 @@ function score_assert_handler($file, $line, $code, $desc = null) { /** @privatesection */ function _version_check() { - if(MIN_PHP_VERSION) - { + if(MIN_PHP_VERSION) { if(version_compare(phpversion(), MIN_PHP_VERSION, ">=") === FALSE) { print " Shimmie (SCore Engine) does not support versions of PHP lower than ".MIN_PHP_VERSION." @@ -434,10 +393,6 @@ function _sanitise_environment() { } -/** - * @param string $_theme - * @return string[] - */ function _get_themelet_files(string $_theme): array { $base_themelets = array(); if(file_exists('themes/'.$_theme.'/custompage.class.php')) $base_themelets[] = 'themes/'.$_theme.'/custompage.class.php'; @@ -453,7 +408,6 @@ function _get_themelet_files(string $_theme): array { /** * Used to display fatal errors to the web user. - * @param Exception $e */ function _fatal_error(Exception $e) { $version = VERSION; @@ -485,9 +439,6 @@ function _fatal_error(Exception $e) { * * Necessary because various servers and various clients * think that / is special... - * - * @param string $str - * @return string */ function _decaret(string $str): string { $out = ""; @@ -523,10 +474,7 @@ function _get_user(): User { return $user; } -/** - * @return string|null - */ -function _get_query() { +function _get_query(): string { return (@$_POST["q"]?:@$_GET["q"])?:"/"; } @@ -535,14 +483,14 @@ function _get_query() { * Code coverage * \* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -function _start_coverage() { +function _start_coverage(): void { if(function_exists("xdebug_start_code_coverage")) { #xdebug_start_code_coverage(XDEBUG_CC_UNUSED|XDEBUG_CC_DEAD_CODE); xdebug_start_code_coverage(XDEBUG_CC_UNUSED); } } -function _end_coverage() { +function _end_coverage(): void { if(function_exists("xdebug_get_code_coverage")) { // Absolute path is necessary because working directory // inside register_shutdown_function is unpredictable. @@ -564,10 +512,6 @@ function _end_coverage() { * and a link to ban that IP (if the user is allowed to ban IPs) * * FIXME: also check that IP ban ext is installed - * - * @param string $ip - * @param string $ban_reason - * @return string */ function show_ip(string $ip, string $ban_reason): string { global $user; @@ -580,14 +524,6 @@ function show_ip(string $ip, string $ban_reason): string { /** * Make a form tag with relevant auth token and stuff - * - * @param string $target - * @param string $method - * @param bool $multipart - * @param string $form_id - * @param string $onsubmit - * - * @return string */ function make_form(string $target, string $method="POST", bool $multipart=False, string $form_id="", string $onsubmit=""): string { global $user; diff --git a/ext/admin/main.php b/ext/admin/main.php index 04da836c..752ae64e 100644 --- a/ext/admin/main.php +++ b/ext/admin/main.php @@ -132,7 +132,7 @@ class AdminPage extends Extension { $images = Image::find_images(0, 1000000, Tag::explode($query)); $count = count($images); - log_warning("admin", "Mass-deleting $count images from $query", true); + log_warning("admin", "Mass-deleting $count images from $query", "Mass deleted $count images"); foreach($images as $image) { if($reason && class_exists("ImageBan")) { send_event(new AddImageHashBanEvent($image->hash, $reason)); @@ -150,14 +150,14 @@ class AdminPage extends Extension { $database->execute($database->scoreql_to_sql( "UPDATE tags SET tag=:tag1 WHERE SCORE_STRNORM(tag) = SCORE_STRNORM(:tag2)" ), array("tag1" => $_POST['tag'], "tag2" => $_POST['tag'])); - log_info("admin", "Fixed the case of ".html_escape($_POST['tag']), true); + log_info("admin", "Fixed the case of ".html_escape($_POST['tag']), "Fixed case"); return true; } private function lowercase_all_tags() { global $database; $database->execute("UPDATE tags SET tag=lower(tag)"); - log_warning("admin", "Set all tags to lowercase", true); + log_warning("admin", "Set all tags to lowercase", "Set all tags to lowercase"); return true; } @@ -171,7 +171,7 @@ class AdminPage extends Extension { ) "); $database->Execute("DELETE FROM tags WHERE count=0"); - log_warning("admin", "Re-counted tags", true); + log_warning("admin", "Re-counted tags", "Re-counted tags"); return true; } diff --git a/ext/alias_editor/main.php b/ext/alias_editor/main.php index b3f5fb6b..40c0117a 100644 --- a/ext/alias_editor/main.php +++ b/ext/alias_editor/main.php @@ -48,7 +48,7 @@ class AliasEditor extends Extension { if($user->can("manage_alias_list")) { if(isset($_POST['oldtag'])) { $database->execute("DELETE FROM aliases WHERE oldtag=:oldtag", array("oldtag" => $_POST['oldtag'])); - log_info("alias_editor", "Deleted alias for ".$_POST['oldtag'], true); + log_info("alias_editor", "Deleted alias for ".$_POST['oldtag'], "Deleted alias"); $page->set_mode("redirect"); $page->set_redirect(make_link("alias/list")); @@ -90,7 +90,7 @@ class AliasEditor extends Extension { $tmp = $_FILES['alias_file']['tmp_name']; $contents = file_get_contents($tmp); $this->add_alias_csv($database, $contents); - log_info("alias_editor", "Imported aliases from file", true); # FIXME: how many? + log_info("alias_editor", "Imported aliases from file", "Imported aliases"); # FIXME: how many? $page->set_mode("redirect"); $page->set_redirect(make_link("alias/list")); } @@ -116,7 +116,7 @@ class AliasEditor extends Extension { } else { $database->execute("INSERT INTO aliases(oldtag, newtag) VALUES(:oldtag, :newtag)", $pair); - log_info("alias_editor", "Added alias for {$event->oldtag} -> {$event->newtag}", true); + log_info("alias_editor", "Added alias for {$event->oldtag} -> {$event->newtag}", "Added alias"); } } @@ -158,7 +158,6 @@ class AliasEditor extends Extension { * Add alias *after* mass tag editing, else the MTE will * search for the images and be redirected to the alias, * missing out the images tagged with the old tag. - * @return int */ public function get_priority(): int {return 60;} } diff --git a/ext/alias_editor/theme.php b/ext/alias_editor/theme.php index 02b7a3a1..51e65f2b 100644 --- a/ext/alias_editor/theme.php +++ b/ext/alias_editor/theme.php @@ -5,12 +5,8 @@ class AliasEditorTheme extends Themelet { * Show a page of aliases. * * Note: $can_manage = whether things like "add new alias" should be shown - * - * @param array $aliases An array of ($old_tag => $new_tag) - * @param int $pageNumber - * @param int $totalPages */ - public function display_aliases($aliases, $pageNumber, $totalPages) { + public function display_aliases(array $aliases, int $pageNumber, int $totalPages): void { global $page, $user; $can_manage = $user->can("manage_alias_list"); diff --git a/ext/arrowkey_navigation/main.php b/ext/arrowkey_navigation/main.php index 023ca87b..01a504f7 100644 --- a/ext/arrowkey_navigation/main.php +++ b/ext/arrowkey_navigation/main.php @@ -11,8 +11,6 @@ class ArrowkeyNavigation extends Extension { /** * Adds functionality for post/view on images. - * - * @param DisplayingImageEvent $event */ public function onDisplayingImage(DisplayingImageEvent $event) { $prev_url = make_http(make_link("post/prev/".$event->image->id)); @@ -22,8 +20,6 @@ class ArrowkeyNavigation extends Extension { /** * Adds functionality for post/list. - * - * @param PageRequestEvent $event */ public function onPageRequest(PageRequestEvent $event) { if($event->page_matches("post/list")) { @@ -36,11 +32,8 @@ class ArrowkeyNavigation extends Extension { /** * Adds the javascript to the page with the given urls. - * - * @param string $prev_url - * @param string $next_url */ - private function add_arrowkeys_code($prev_url, $next_url) { + private function add_arrowkeys_code(string $prev_url, string $next_url) { global $page; $page->add_html_header("