diff --git a/composer.lock b/composer.lock index 5fad216b..ff2a0d95 100644 --- a/composer.lock +++ b/composer.lock @@ -614,12 +614,12 @@ "source": { "type": "git", "url": "https://github.com/shish/gqla.git", - "reference": "6b30c17214389013314cc3441e0db766fee8119c" + "reference": "3b9d2973c0587f10f3b57990585fbdb7588ce54f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/shish/gqla/zipball/6b30c17214389013314cc3441e0db766fee8119c", - "reference": "6b30c17214389013314cc3441e0db766fee8119c", + "url": "https://api.github.com/repos/shish/gqla/zipball/3b9d2973c0587f10f3b57990585fbdb7588ce54f", + "reference": "3b9d2973c0587f10f3b57990585fbdb7588ce54f", "shasum": "" }, "require": { @@ -659,7 +659,7 @@ "issues": "https://github.com/shish/gqla/issues", "source": "https://github.com/shish/gqla/tree/main" }, - "time": "2023-02-04T12:47:18+00:00" + "time": "2023-02-04T20:10:44+00:00" }, { "name": "shish/microcrud", @@ -770,16 +770,16 @@ }, { "name": "webonyx/graphql-php", - "version": "v15.0.3", + "version": "v15.1.0", "source": { "type": "git", "url": "https://github.com/webonyx/graphql-php.git", - "reference": "bfa78b44a93c00ebc9a1bc92497bc170a0e3b656" + "reference": "c58c08f3e2d6c43a8e0bb4bcc61ecb2a3e4f85df" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/webonyx/graphql-php/zipball/bfa78b44a93c00ebc9a1bc92497bc170a0e3b656", - "reference": "bfa78b44a93c00ebc9a1bc92497bc170a0e3b656", + "url": "https://api.github.com/repos/webonyx/graphql-php/zipball/c58c08f3e2d6c43a8e0bb4bcc61ecb2a3e4f85df", + "reference": "c58c08f3e2d6c43a8e0bb4bcc61ecb2a3e4f85df", "shasum": "" }, "require": { @@ -828,7 +828,7 @@ ], "support": { "issues": "https://github.com/webonyx/graphql-php/issues", - "source": "https://github.com/webonyx/graphql-php/tree/v15.0.3" + "source": "https://github.com/webonyx/graphql-php/tree/v15.1.0" }, "funding": [ { @@ -836,7 +836,7 @@ "type": "open_collective" } ], - "time": "2023-02-02T21:59:56+00:00" + "time": "2023-02-04T15:00:26+00:00" } ], "packages-dev": [ @@ -2657,12 +2657,12 @@ "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "8072151d4782529eca00770db6dccbb49ce4cdb1" + "reference": "e7b1615e3e887d6c719121c6d4a44b0ab9645555" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/8072151d4782529eca00770db6dccbb49ce4cdb1", - "reference": "8072151d4782529eca00770db6dccbb49ce4cdb1", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/e7b1615e3e887d6c719121c6d4a44b0ab9645555", + "reference": "e7b1615e3e887d6c719121c6d4a44b0ab9645555", "shasum": "" }, "require": { @@ -2735,7 +2735,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", - "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6" + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.3" }, "funding": [ { @@ -2751,7 +2751,7 @@ "type": "tidelift" } ], - "time": "2023-02-04T08:53:49+00:00" + "time": "2023-02-04T13:37:15+00:00" }, { "name": "psr/cache", diff --git a/core/imageboard/image.php b/core/imageboard/image.php index faec4c3f..dce56070 100644 --- a/core/imageboard/image.php +++ b/core/imageboard/image.php @@ -503,9 +503,7 @@ class Image #[Field(name: "nice_name")] public function get_nice_image_name(): string { - $plte = new ParseLinkTemplateEvent('$id - $tags.$ext', $this); - send_event($plte); - return $plte->text; + return send_event(new ParseLinkTemplateEvent('$id - $tags.$ext', $this))->text; } /** @@ -550,9 +548,7 @@ class Image public function get_tooltip(): string { global $config; - $plte = new ParseLinkTemplateEvent($config->get_string(ImageConfig::TIP), $this); - send_event($plte); - return $plte->text; + return send_event(new ParseLinkTemplateEvent($config->get_string(ImageConfig::TIP), $this))->text; } /** @@ -563,9 +559,7 @@ class Image public function get_info(): string { global $config; - $plte = new ParseLinkTemplateEvent($config->get_string(ImageConfig::INFO), $this); - send_event($plte); - return $plte->text; + return send_event(new ParseLinkTemplateEvent($config->get_string(ImageConfig::INFO), $this))->text; } diff --git a/core/imageboard/misc.php b/core/imageboard/misc.php index f36e63e1..b65938ab 100644 --- a/core/imageboard/misc.php +++ b/core/imageboard/misc.php @@ -53,9 +53,7 @@ function add_image(string $tmpname, string $filename, string $tags): int $metadata['tags'] = Tag::explode($tags); $metadata['source'] = null; - $due = new DataUploadEvent($tmpname, $metadata); - send_event($due); - + $due = send_event(new DataUploadEvent($tmpname, $metadata)); return $due->image_id; } diff --git a/core/util.php b/core/util.php index 894308d2..d3a73552 100644 --- a/core/util.php +++ b/core/util.php @@ -207,8 +207,7 @@ function get_session_ip(Config $config): string */ function format_text(string $string): string { - $event = new TextFormattingEvent($string); - send_event($event); + $event = send_event(new TextFormattingEvent($string)); return $event->formatted; } diff --git a/ext/auto_tagger/main.php b/ext/auto_tagger/main.php index a4abf1d3..370cdac5 100644 --- a/ext/auto_tagger/main.php +++ b/ext/auto_tagger/main.php @@ -259,8 +259,7 @@ class AutoTagger extends Extension foreach ($image_ids as $image_id) { $image_id = (int) $image_id; $image = Image::by_id($image_id); - $event = new TagSetEvent($image, $image->get_tag_array()); - send_event($event); + send_event(new TagSetEvent($image, $image->get_tag_array())); } } } diff --git a/ext/bulk_import_export/main.php b/ext/bulk_import_export/main.php index 93c5b843..03982ae2 100644 --- a/ext/bulk_import_export/main.php +++ b/ext/bulk_import_export/main.php @@ -126,8 +126,7 @@ class BulkImportExport extends DataHandlerExtension foreach ($event->items as $image) { $img_loc = warehouse_path(Image::IMAGE_DIR, $image->hash, false); - $export_event = new BulkExportEvent($image); - send_event($export_event); + $export_event = send_event(new BulkExportEvent($image)); $data = $export_event->fields; $data["hash"] = $image->hash; $data["tags"] = $image->get_tag_array(); diff --git a/ext/comment/main.php b/ext/comment/main.php index 615d3c16..3de9cdc5 100644 --- a/ext/comment/main.php +++ b/ext/comment/main.php @@ -221,8 +221,7 @@ class CommentList extends Extension if (isset($_POST['image_id']) && isset($_POST['comment'])) { try { $i_iid = int_escape($_POST['image_id']); - $cpe = new CommentPostingEvent(int_escape($_POST['image_id']), $user, $_POST['comment']); - send_event($cpe); + send_event(new CommentPostingEvent(int_escape($_POST['image_id']), $user, $_POST['comment'])); $page->set_mode(PageMode::REDIRECT); $page->set_redirect(make_link("post/view/$i_iid", null, "comment_on_$i_iid")); } catch (CommentPostingException $ex) { diff --git a/ext/comment/theme.php b/ext/comment/theme.php index d212ece0..c7ba9e94 100644 --- a/ext/comment/theme.php +++ b/ext/comment/theme.php @@ -198,8 +198,7 @@ class CommentListTheme extends Themelet { global $config, $user; - $tfe = new TextFormattingEvent($comment->comment); - send_event($tfe); + $tfe = send_event(new TextFormattingEvent($comment->comment)); $i_uid = $comment->owner_id; $h_name = html_escape($comment->owner_name); diff --git a/ext/cron_uploader/main.php b/ext/cron_uploader/main.php index 36defedf..5e49a03d 100644 --- a/ext/cron_uploader/main.php +++ b/ext/cron_uploader/main.php @@ -481,8 +481,7 @@ class CronUploader extends Extension } $metadata ['tags'] = $tagArray; $metadata ['source'] = null; - $event = new DataUploadEvent($tmpname, $metadata); - send_event($event); + $event = send_event(new DataUploadEvent($tmpname, $metadata)); // Generate info message if ($event->image_id == -1) { diff --git a/ext/forum/theme.php b/ext/forum/theme.php index 302221f7..9e7bab4e 100644 --- a/ext/forum/theme.php +++ b/ext/forum/theme.php @@ -106,10 +106,7 @@ class ForumTheme extends Themelet $current_post++; $message = $post["message"]; - $tfe = new TextFormattingEvent($message); - send_event($tfe); - $message = $tfe->formatted; - + $message = send_event(new TextFormattingEvent($message))->formatted; $message = str_replace('\n\r', '
', $message); $message = str_replace('\r\n', '
', $message); $message = str_replace('\n', '
', $message); diff --git a/ext/help_pages/main.php b/ext/help_pages/main.php index 28519599..2a208c46 100644 --- a/ext/help_pages/main.php +++ b/ext/help_pages/main.php @@ -44,9 +44,7 @@ class HelpPages extends Extension private function get_pages(): array { if ($this->pages==null) { - $e = new HelpPageListBuildingEvent(); - send_event($e); - $this->pages = $e->pages; + $this->pages = send_event(new HelpPageListBuildingEvent())->pages; } return $this->pages; } @@ -74,8 +72,7 @@ class HelpPages extends Extension $this->theme->display_help_page($title); - $hpbe = new HelpPageBuildingEvent($name); - send_event($hpbe); + $hpbe = send_event(new HelpPageBuildingEvent($name)); asort($hpbe->blocks); foreach ($hpbe->blocks as $key=>$value) { diff --git a/ext/index/main.php b/ext/index/main.php index 3bb56976..446732e1 100644 --- a/ext/index/main.php +++ b/ext/index/main.php @@ -114,8 +114,7 @@ class Index extends Extension $page->set_mode(PageMode::REDIRECT); $page->set_redirect(make_link('post/view/'.$images[0]->id)); } else { - $plbe = new PostListBuildingEvent($search_terms); - send_event($plbe); + $plbe = send_event(new PostListBuildingEvent($search_terms)); $this->theme->set_page($page_number, $total_pages, $search_terms); $this->theme->display_page($page, $images); diff --git a/ext/index/theme.php b/ext/index/theme.php index b9984bf8..411a11a2 100644 --- a/ext/index/theme.php +++ b/ext/index/theme.php @@ -122,8 +122,7 @@ and of course start organising your images :-) // only show first line of wiki $short_wiki_description = explode("\n", $wikiPage->body, 2)[0]; - $tfe = new TextFormattingEvent($short_wiki_description); - send_event($tfe); + $tfe = send_event(new TextFormattingEvent($short_wiki_description)); $short_wiki_description = $tfe->formatted; } $wikiLink = make_link("wiki/$st"); diff --git a/ext/notes/main.php b/ext/notes/main.php index ce3702e0..67df6f02 100644 --- a/ext/notes/main.php +++ b/ext/notes/main.php @@ -305,7 +305,7 @@ class Notes extends Extension ]; // validate parameters - if (array_search(null, $note)|| strlen($note['noteText']) == 0) { + if (empty($note['note'])) { return; } diff --git a/ext/ouroboros_api/main.php b/ext/ouroboros_api/main.php index c2ab19b8..07ec46c2 100644 --- a/ext/ouroboros_api/main.php +++ b/ext/ouroboros_api/main.php @@ -171,10 +171,7 @@ class OuroborosPost extends _SafeOuroborosImage $this->is_note_locked = $post['is_note_locked']; } if (array_key_exists('parent_id', $post)) { - $this->parent_id = filter_var( - $post['parent_id'], - FILTER_SANITIZE_NUMBER_INT - ); + $this->parent_id = int_escape($post['parent_id']); } } } @@ -386,8 +383,7 @@ class OuroborosAPI extends Extension } $meta['extension'] = pathinfo($meta['filename'], PATHINFO_EXTENSION); try { - $upload = new DataUploadEvent($meta['file'], $meta); - send_event($upload); + send_event(new DataUploadEvent($meta['file'], $meta)); $image = Image::by_hash($meta['hash']); if (!is_null($image)) { $this->sendResponse(200, make_link('post/view/' . $image->id), true); diff --git a/ext/pools/main.php b/ext/pools/main.php index 017d136e..85fff391 100644 --- a/ext/pools/main.php +++ b/ext/pools/main.php @@ -236,14 +236,12 @@ class Pools extends Extension case "create": // ADD _POST try { $title = $_POST["title"]; - $event = new PoolCreationEvent( + $event = send_event(new PoolCreationEvent( $title, $user, bool_escape($_POST["public"]), $_POST["description"] - ); - - send_event($event); + )); $page->set_mode(PageMode::REDIRECT); $page->set_redirect(make_link("pool/view/" . $event->new_id)); } catch (PoolCreationException $e) { @@ -588,8 +586,7 @@ class Pools extends Extension return; } $new_pool_title = $_POST['bulk_pool_new']; - $pce = new PoolCreationEvent($new_pool_title); - send_event($pce); + $pce = send_event(new PoolCreationEvent($new_pool_title)); send_event(new PoolAddPostsEvent($pce->new_id, iterator_map_to_array("Shimmie2\_image_to_id", $event->items))); break; } diff --git a/ext/pools/theme.php b/ext/pools/theme.php index cbdfdd4b..79f8c2ec 100644 --- a/ext/pools/theme.php +++ b/ext/pools/theme.php @@ -144,8 +144,7 @@ class PoolsTheme extends Themelet $this->sidebar_options($page, $pool, $check_all); } } - $tfe = new TextFormattingEvent($pool->description); - send_event($tfe); + $tfe = send_event(new TextFormattingEvent($pool->description)); $page->add_block(new Block(html_escape($pool->title), $tfe->formatted, "main", 10)); } } diff --git a/ext/rating/main.php b/ext/rating/main.php index 0c551412..ba54383a 100644 --- a/ext/rating/main.php +++ b/ext/rating/main.php @@ -295,8 +295,7 @@ class Ratings extends Extension $ratings = array_intersect(str_split($ratings), Ratings::get_user_class_privs($user)); $rating = $ratings[0]; $image = Image::by_id($event->image_id); - $re = new RatingSetEvent($image, $rating); - send_event($re); + send_event(new RatingSetEvent($image, $rating)); } } diff --git a/ext/regen_thumb/main.php b/ext/regen_thumb/main.php index 9c4119b0..76327f29 100644 --- a/ext/regen_thumb/main.php +++ b/ext/regen_thumb/main.php @@ -12,8 +12,7 @@ class RegenThumb extends Extension public function regenerate_thumbnail(Image $image, bool $force = true): bool { global $cache; - $event = new ThumbnailGenerationEvent($image->hash, $image->get_mime(), $force); - send_event($event); + $event = send_event(new ThumbnailGenerationEvent($image->hash, $image->get_mime(), $force)); $cache->delete("thumb-block:{$image->id}"); return $event->generated; } @@ -126,8 +125,7 @@ class RegenThumb extends Extension continue; } } - $event = new ThumbnailGenerationEvent($image["hash"], $image["mime"], $force); - send_event($event); + $event = send_event(new ThumbnailGenerationEvent($image["hash"], $image["mime"], $force)); if ($event->generated) { $i++; } diff --git a/ext/report_image/theme.php b/ext/report_image/theme.php index fdfd0324..82dd33c2 100644 --- a/ext/report_image/theme.php +++ b/ext/report_image/theme.php @@ -21,8 +21,7 @@ class ReportImageTheme extends Themelet $reporter_name = html_escape($report['reporter_name']); $userlink = "$reporter_name"; - $iabbe = new ImageAdminBlockBuildingEvent($image, $user, "report"); - send_event($iabbe); + $iabbe = send_event(new ImageAdminBlockBuildingEvent($image, $user, "report")); ksort($iabbe->parts); $actions = join("
", $iabbe->parts); diff --git a/ext/resize/main.php b/ext/resize/main.php index 1a86b43c..96ca6ec3 100644 --- a/ext/resize/main.php +++ b/ext/resize/main.php @@ -192,15 +192,14 @@ class ResizeImage extends Extension throw new ImageResizeException("Unable to save temporary image file."); } - $mre = new MediaResizeEvent( + send_event(new MediaResizeEvent( $config->get_string(ResizeConfig::ENGINE), $event->path, $event->mime, $tmp_filename, $new_width, $new_height - ); - send_event($mre); + )); if ($event->file_modified===true&&$event->path!=$event->image->get_image_filename()) { // This means that we're dealing with a temp file that will need cleaned up diff --git a/ext/system/main.php b/ext/system/main.php index 2cb66073..f33a7a12 100644 --- a/ext/system/main.php +++ b/ext/system/main.php @@ -11,8 +11,7 @@ class System extends Extension global $page; if ($event->page_matches("system")) { - $e = new PageSubNavBuildingEvent("system"); - send_event($e); + $e = send_event(new PageSubNavBuildingEvent("system")); usort($e->links, "Shimmie2\sort_nav_links"); $link = $e->links[0]->link; diff --git a/ext/tag_edit/main.php b/ext/tag_edit/main.php index 69010372..51d70a31 100644 --- a/ext/tag_edit/main.php +++ b/ext/tag_edit/main.php @@ -74,8 +74,7 @@ class TagSetEvent extends Event continue; } - $ttpe = new TagTermCheckEvent($tag); - send_event($ttpe); + $ttpe = send_event(new TagTermCheckEvent($tag)); //seperate tags from metatags if (!$ttpe->metatag) { diff --git a/ext/tagger_xml/main.php b/ext/tagger_xml/main.php index b736b98d..e945e2eb 100644 --- a/ext/tagger_xml/main.php +++ b/ext/tagger_xml/main.php @@ -72,7 +72,7 @@ class TaggerXML extends Extension $count = ["max"=>$count]; } else { $q_from = "FROM `tags`"; - $count = null; + $count = []; } $tags = $database->execute( @@ -97,33 +97,26 @@ class TaggerXML extends Extension return $this->list_to_xml($tags, "image", (string)$image_id); } - private function list_to_xml(\FFSPHP\PDOStatement $tags, string $type, string $query, ?array$misc=null): string + private function list_to_xml(\FFSPHP\PDOStatement $tags, string $type, string $query, ?array $misc=[]): string { - // @phpstan-ignore-next-line - $r = $tags->_numOfRows; - - $s_misc = ""; + $props = [ + "id"=>$type, + "query"=>$query, + // @phpstan-ignore-next-line + "rows"=>$tags->_numOfRows + ]; if (!is_null($misc)) { foreach ($misc as $attr => $val) { - $s_misc .= " ".$attr."=\"".$val."\""; + $props[$attr] = $val; } } - $result = ""; + $list = new \MicroHTML\HTMLElement("list", [$props]); foreach ($tags as $tag) { - $result .= $this->tag_to_xml($tag); + $list->appendChild(new \MicroHTML\HTMLElement("tag", [["id"=>$tag["id"], "count"=>$tag["count"]], $tag["tag"]])); } - return $result.""; - } - private function tag_to_xml(\PDORow $tag): string - { - return - "". - html_escape($tag['tag']). - ""; + return (string)($list); } private function count(string $query, $values) diff --git a/ext/user/main.php b/ext/user/main.php index 0f4fe62c..35710c94 100644 --- a/ext/user/main.php +++ b/ext/user/main.php @@ -116,8 +116,7 @@ class UserPage extends Extension } elseif ($event->get_arg(0) == "create") { $this->page_create(); } elseif ($event->get_arg(0) == "create_other") { - $uce = new UserCreationEvent($_POST['name'], $_POST['pass1'], $_POST['email'], false); - send_event($uce); + send_event(new UserCreationEvent($_POST['name'], $_POST['pass1'], $_POST['email'], false)); $page->set_mode(PageMode::REDIRECT); $page->set_redirect(make_link("admin")); $page->flash("Created new user"); @@ -180,8 +179,7 @@ class UserPage extends Extension "You aren't logged in. First do that, then you can see your stats." ); } elseif (!is_null($display_user) && ($display_user->id != $config->get_int("anon_id"))) { - $e = new UserPageBuildingEvent($display_user); - send_event($e); + $e = send_event(new UserPageBuildingEvent($display_user)); $this->display_stats($e); } else { $this->theme->display_error( @@ -248,15 +246,13 @@ class UserPage extends Extension if ($user->id == $event->display_user->id || $user->can("edit_user_info")) { $user_config = UserConfig::get_for_user($event->display_user->id); - $uobe = new UserOperationsBuildingEvent($event->display_user, $user_config); - send_event($uobe); + $uobe = send_event(new UserOperationsBuildingEvent($event->display_user, $user_config)); $page->add_block(new Block("Operations", $this->theme->build_operations($event->display_user, $uobe), "main", 60)); } } if ($user->id == $event->display_user->id) { - $ubbe = new UserBlockBuildingEvent(); - send_event($ubbe); + $ubbe = send_event(new UserBlockBuildingEvent()); ksort($ubbe->parts); $this->theme->display_user_links($page, $user, $ubbe->parts); } @@ -423,8 +419,7 @@ class UserPage extends Extension if ($user->is_anonymous()) { $this->theme->display_login_block($page); } else { - $ubbe = new UserBlockBuildingEvent(); - send_event($ubbe); + $ubbe = send_event(new UserBlockBuildingEvent()); ksort($ubbe->parts); $this->theme->display_user_block($page, $user, $ubbe->parts); } @@ -508,8 +503,7 @@ class UserPage extends Extension throw new UserCreationException("Error in captcha"); } - $uce = new UserCreationEvent($_POST['name'], $_POST['pass1'], $_POST['email'], true); - send_event($uce); + $uce = send_event(new UserCreationEvent($_POST['name'], $_POST['pass1'], $_POST['email'], true)); $this->set_login_cookie($uce->username); $page->set_mode(PageMode::REDIRECT); $page->set_redirect(make_link("user")); diff --git a/ext/user/theme.php b/ext/user/theme.php index fad854bc..2a400765 100644 --- a/ext/user/theme.php +++ b/ext/user/theme.php @@ -67,8 +67,7 @@ class UserPageTheme extends Themelet $tac = $config->get_string("login_tac", ""); if ($config->get_bool("login_tac_bbcode")) { - $tfe = new TextFormattingEvent($tac); - send_event($tfe); + $tfe = send_event(new TextFormattingEvent($tac)); $tac = $tfe->formatted; } diff --git a/ext/user_config/main.php b/ext/user_config/main.php index 4e91ed40..150b9567 100644 --- a/ext/user_config/main.php +++ b/ext/user_config/main.php @@ -138,16 +138,7 @@ class UserConfig extends Extension $this->theme->display_permission_denied(); } else { if ($event->count_args() == 0) { - $display_user = ($event->count_args() == 0) ? $user : User::by_name($event->get_arg(0)); - - if ($user->id!=$display_user->id && !$user->can(Permissions::CHANGE_OTHER_USER_SETTING)) { - $this->theme->display_permission_denied(); - return; - } - - $uobe = new UserOptionsBuildingEvent($display_user, new SetupPanel($user_config)); - send_event($uobe); - + $uobe = send_event(new UserOptionsBuildingEvent($user, new SetupPanel($user_config))); $this->theme->display_user_config_page($page, $uobe->user, $uobe->panel); } elseif ($event->get_arg(0) == "save" && $user->check_auth_token()) { $input = validate_input([ diff --git a/ext/varnish/main.php b/ext/varnish/main.php index cfe0d226..fff2a8c3 100644 --- a/ext/varnish/main.php +++ b/ext/varnish/main.php @@ -37,8 +37,6 @@ class VarnishPurger extends Extension throw new SCoreException('PURGE ' . $url . ' unsuccessful (HTTP '. $httpCode . ')'); } curl_close($ch); - assert(!is_null($result) && !is_null($httpCode)); - //return $result; } public function onCommentPosting(CommentPostingEvent $event) diff --git a/ext/view/main.php b/ext/view/main.php index acbaf3b8..ceb2c83d 100644 --- a/ext/view/main.php +++ b/ext/view/main.php @@ -101,13 +101,11 @@ class ViewImage extends Extension $this->theme->display_meta_headers($image); - $iibbe = new ImageInfoBoxBuildingEvent($image, $user); - send_event($iibbe); + $iibbe = send_event(new ImageInfoBoxBuildingEvent($image, $user)); ksort($iibbe->parts); $this->theme->display_page($image, $iibbe->parts); - $iabbe = new ImageAdminBlockBuildingEvent($image, $user, "view"); - send_event($iabbe); + $iabbe = send_event(new ImageAdminBlockBuildingEvent($image, $user, "view")); ksort($iabbe->parts); $this->theme->display_admin_block($page, $iabbe->parts); } diff --git a/ext/wiki/theme.php b/ext/wiki/theme.php index c1d4ccce..66b315a6 100644 --- a/ext/wiki/theme.php +++ b/ext/wiki/theme.php @@ -21,8 +21,7 @@ class WikiTheme extends Themelet $nav_page->body = ""; } - $tfe = new TextFormattingEvent($nav_page->body); - send_event($tfe); + $tfe = send_event(new TextFormattingEvent($nav_page->body)); // only the admin can edit the sidebar if ($user->can(Permissions::WIKI_ADMIN)) { diff --git a/tests/bootstrap.php b/tests/bootstrap.php index a1accb69..612c8838 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -247,13 +247,12 @@ abstract class ShimmiePHPUnitTestCase extends TestCase // post things protected function post_image(string $filename, string $tags): int { - $dae = new DataUploadEvent($filename, [ + $dae = send_event(new DataUploadEvent($filename, [ "filename" => $filename, "extension" => pathinfo($filename, PATHINFO_EXTENSION), "tags" => Tag::explode($tags), "source" => null, - ]); - send_event($dae); + ])); // if($dae->image_id == -1) throw new \Exception("Upload failed :("); return $dae->image_id; } @@ -262,8 +261,7 @@ abstract class ShimmiePHPUnitTestCase extends TestCase { $img = Image::by_id($image_id); if ($img) { - $ide = new ImageDeletionEvent($img, true); - send_event($ide); + send_event(new ImageDeletionEvent($img, true)); } } } diff --git a/tests/phpstan.neon b/tests/phpstan.neon index 0b5b4f23..2a379a7f 100644 --- a/tests/phpstan.neon +++ b/tests/phpstan.neon @@ -6,5 +6,4 @@ parameters: - ../tests - ../themes/default ignoreErrors: - - '#Attribute class GQLA\\#' - '#Access to an undefined property Shimmie2\\Image::\$#' diff --git a/themes/danbooru/comment.theme.php b/themes/danbooru/comment.theme.php index 73eaf8dd..ec3fb85d 100644 --- a/themes/danbooru/comment.theme.php +++ b/themes/danbooru/comment.theme.php @@ -95,8 +95,7 @@ class CustomCommentListTheme extends CommentListTheme { global $user; - $tfe = new TextFormattingEvent($comment->comment); - send_event($tfe); + $tfe = send_event(new TextFormattingEvent($comment->comment)); //$i_uid = $comment->owner_id; $h_name = html_escape($comment->owner_name); diff --git a/themes/danbooru/user.theme.php b/themes/danbooru/user.theme.php index c4c851ba..276dd53f 100644 --- a/themes/danbooru/user.theme.php +++ b/themes/danbooru/user.theme.php @@ -62,9 +62,7 @@ class CustomUserPageTheme extends UserPageTheme global $config; $tac = $config->get_string("login_tac", ""); - $tfe = new TextFormattingEvent($tac); - send_event($tfe); - $tac = $tfe->formatted; + $tac = send_event(new TextFormattingEvent($tac))->formatted; $reca = "".captcha_get_html().""; diff --git a/themes/danbooru2/comment.theme.php b/themes/danbooru2/comment.theme.php index 43598e59..d61b0786 100644 --- a/themes/danbooru2/comment.theme.php +++ b/themes/danbooru2/comment.theme.php @@ -96,8 +96,7 @@ class CustomCommentListTheme extends CommentListTheme { global $user; - $tfe = new TextFormattingEvent($comment->comment); - send_event($tfe); + $tfe = send_event(new TextFormattingEvent($comment->comment)); //$i_uid = $comment->owner_id; $h_name = html_escape($comment->owner_name); diff --git a/themes/danbooru2/user.theme.php b/themes/danbooru2/user.theme.php index c4c851ba..276dd53f 100644 --- a/themes/danbooru2/user.theme.php +++ b/themes/danbooru2/user.theme.php @@ -62,9 +62,7 @@ class CustomUserPageTheme extends UserPageTheme global $config; $tac = $config->get_string("login_tac", ""); - $tfe = new TextFormattingEvent($tac); - send_event($tfe); - $tac = $tfe->formatted; + $tac = send_event(new TextFormattingEvent($tac))->formatted; $reca = "".captcha_get_html().""; diff --git a/themes/futaba/comment.theme.php b/themes/futaba/comment.theme.php index 1a948b81..ae30fed1 100644 --- a/themes/futaba/comment.theme.php +++ b/themes/futaba/comment.theme.php @@ -69,8 +69,7 @@ class CustomCommentListTheme extends CommentListTheme $inner_id = $this->inner_id; // because custom themes can't add params, because PHP global $user; - $tfe = new TextFormattingEvent($comment->comment); - send_event($tfe); + $tfe = send_event(new TextFormattingEvent($comment->comment)); //$i_uid = $comment->owner_id; $h_name = html_escape($comment->owner_name); diff --git a/themes/rule34v2/user.theme.php b/themes/rule34v2/user.theme.php index 81592bd8..ae04e44f 100644 --- a/themes/rule34v2/user.theme.php +++ b/themes/rule34v2/user.theme.php @@ -64,9 +64,7 @@ class CustomUserPageTheme extends UserPageTheme $tac = $config->get_string("login_tac", ""); if ($config->get_bool("login_tac_bbcode")) { - $tfe = new TextFormattingEvent($tac); - send_event($tfe); - $tac = $tfe->formatted; + $tac = send_event(new TextFormattingEvent($tac))->formatted; } $form = SHM_SIMPLE_FORM(