From cc8f1f35a515fe7a6838923b70b86905a2e98d64 Mon Sep 17 00:00:00 2001 From: Shish Date: Thu, 2 Feb 2012 14:14:33 +0000 Subject: [PATCH] more type hints --- ext/alias_editor/main.php | 4 ++-- ext/bbcode/main.php | 12 ++++++------ ext/comment/main.php | 14 +++++++------- ext/ext_manager/main.php | 6 +++--- ext/setup/main.php | 6 +++--- ext/tag_edit/main.php | 4 ++-- ext/tag_list/main.php | 10 +++++----- ext/upload/main.php | 2 +- ext/user/main.php | 22 +++++++++++----------- ext/view/main.php | 2 +- 10 files changed, 41 insertions(+), 41 deletions(-) diff --git a/ext/alias_editor/main.php b/ext/alias_editor/main.php index 88e22433..e095c483 100644 --- a/ext/alias_editor/main.php +++ b/ext/alias_editor/main.php @@ -120,7 +120,7 @@ class AliasEditor extends SimpleExtension { } } - private function get_alias_csv($database) { + private function get_alias_csv(Database $database) { $csv = ""; $aliases = $database->get_pairs("SELECT oldtag, newtag FROM aliases"); foreach($aliases as $old => $new) { @@ -129,7 +129,7 @@ class AliasEditor extends SimpleExtension { return $csv; } - private function add_alias_csv($database, $csv) { + private function add_alias_csv(Database $database, /*string*/ $csv) { $csv = str_replace("\r", "\n", $csv); foreach(explode("\n", $csv) as $line) { $parts = explode(",", $line); diff --git a/ext/bbcode/main.php b/ext/bbcode/main.php index 72eec4e8..4a2eeff2 100644 --- a/ext/bbcode/main.php +++ b/ext/bbcode/main.php @@ -24,7 +24,7 @@ */ class BBCode extends FormatterExtension { - public function format($text) { + public function format(/*string*/ $text) { global $config; if($config->get_bool("word_wrap", true)) { $text = wordwrap($text, 80, " ", true); @@ -73,7 +73,7 @@ class BBCode extends FormatterExtension { return str_replace(' ', '', $matches[1]); } - public function strip($text) { + public function strip(/*string*/ $text) { global $config; if($config->get_bool("word_wrap", true)) { $text = wordwrap($text, 80, " ", true); @@ -103,14 +103,14 @@ class BBCode extends FormatterExtension { } - private function filter_spoiler($text) { + private function filter_spoiler(/*string*/ $text) { return str_replace( array("[spoiler]","[/spoiler]"), array("",""), $text); } - private function strip_spoiler($text) { + private function strip_spoiler(/*string*/ $text) { $l1 = strlen("[spoiler]"); $l2 = strlen("[/spoiler]"); while(true) { @@ -129,7 +129,7 @@ class BBCode extends FormatterExtension { return $text; } - private function extract_code($text) { + private function extract_code(/*string*/ $text) { # at the end of this function, the only code! blocks should be # the ones we've added -- others may contain malicious content, # which would only appear after decoding @@ -154,7 +154,7 @@ class BBCode extends FormatterExtension { return $text; } - private function insert_code($text) { + private function insert_code(/*string*/ $text) { $l1 = strlen("[code!]"); $l2 = strlen("[/code!]"); while(true) { diff --git a/ext/comment/main.php b/ext/comment/main.php index 0c364d57..2bc376f9 100644 --- a/ext/comment/main.php +++ b/ext/comment/main.php @@ -195,7 +195,7 @@ class CommentList extends SimpleExtension { // TODO: split akismet into a separate class, which can veto the event public function onCommentPosting(CommentPostingEvent $event) { - $this->add_comment_wrapper($event->image_id, $event->user, $event->comment, $event); + $this->add_comment_wrapper($event->image_id, $event->user, $event->comment); } public function onCommentDeletion(CommentDeletionEvent $event) { @@ -248,7 +248,7 @@ class CommentList extends SimpleExtension { } // page building {{{ - private function build_page($current_page) { + private function build_page(/*int*/ $current_page) { global $page; global $config; global $database; @@ -318,7 +318,7 @@ class CommentList extends SimpleExtension { return $comments; } - private function get_user_recent_comments($user_id, $count) { + private function get_user_recent_comments(/*int*/ $user_id, /*int*/ $count) { global $config; global $database; $rows = $database->get_all(" @@ -340,7 +340,7 @@ class CommentList extends SimpleExtension { return $comments; } - private function get_comments($image_id) { + private function get_comments(/*int*/ $image_id) { global $config; global $database; $i_image_id = int_escape($image_id); @@ -397,7 +397,7 @@ class CommentList extends SimpleExtension { return md5($_SERVER['REMOTE_ADDR'] . date("%Y%m%d")); } - private function is_spam_akismet($text) { + private function is_spam_akismet(/*string*/ $text) { global $config, $user; if(strlen($config->get_string('comment_wordpress_key')) > 0) { $comment = array( @@ -441,12 +441,12 @@ class CommentList extends SimpleExtension { return ($config->get_bool('comment_anon') || !$user->is_anonymous()); } - private function is_dupe($image_id, $comment) { + private function is_dupe(/*int*/ $image_id, /*string*/ $comment) { global $database; return ($database->get_row("SELECT * FROM comments WHERE image_id=:image_id AND comment=:comment", array("image_id"=>$image_id, "comment"=>$comment))); } - private function add_comment_wrapper($image_id, $user, $comment, $event) { + private function add_comment_wrapper(/*int*/ $image_id, User $user, /*string*/ $comment) { global $database; global $config; diff --git a/ext/ext_manager/main.php b/ext/ext_manager/main.php index b1763f2a..0213a612 100644 --- a/ext/ext_manager/main.php +++ b/ext/ext_manager/main.php @@ -79,7 +79,7 @@ class ExtensionInfo { } } - private function is_enabled($fname) { + private function is_enabled(/*string*/ $fname) { if(file_exists("ext/$fname") && file_exists("contrib/$fname")) return true; // both if(file_exists("contrib/$fname")) return false; // only disabled (optional) return null; // only active (core) @@ -138,7 +138,7 @@ class ExtManager extends SimpleExtension { } - private function get_extensions($all) { + private function get_extensions(/*bool*/ $all) { $extensions = array(); if($all) { $exts = glob("ext/*/main.php"); @@ -169,7 +169,7 @@ class ExtManager extends SimpleExtension { } } - private function set_enabled($fname, $enabled) { + private function set_enabled(/*string*/ $fname, /*bool*/ $enabled) { if($enabled) { // enable if currently disabled if(!file_exists("ext/$fname")) { diff --git a/ext/setup/main.php b/ext/setup/main.php index c2f47f73..32e3ebad 100644 --- a/ext/setup/main.php +++ b/ext/setup/main.php @@ -14,7 +14,7 @@ class ConfigSaveEvent extends Event { var $config; - public function ConfigSaveEvent($config) { + public function ConfigSaveEvent(Config $config) { $this->config = $config; } } @@ -26,7 +26,7 @@ class ConfigSaveEvent extends Event { class SetupBuildingEvent extends Event { var $panel; - public function SetupBuildingEvent($panel) { + public function SetupBuildingEvent(SetupPanel $panel) { $this->panel = $panel; } @@ -41,7 +41,7 @@ class SetupBuildingEvent extends Event { class SetupPanel { var $blocks = array(); - public function add_block($block) { + public function add_block(SetupBlock $block) { $this->blocks[] = $block; } } diff --git a/ext/tag_edit/main.php b/ext/tag_edit/main.php index e909d179..23a806a2 100644 --- a/ext/tag_edit/main.php +++ b/ext/tag_edit/main.php @@ -143,7 +143,7 @@ class TagEdit extends SimpleExtension { } - private function can_tag($image) { + private function can_tag(Image $image) { global $config, $user; return ( ($config->get_bool("tag_edit_anon") || !$user->is_anonymous()) && @@ -151,7 +151,7 @@ class TagEdit extends SimpleExtension { ); } - private function can_source($image) { + private function can_source(Image $image) { global $config, $user; return ( ($config->get_bool("source_edit_anon") || !$user->is_anonymous()) && diff --git a/ext/tag_list/main.php b/ext/tag_list/main.php index 6edab5e8..89dbffd8 100644 --- a/ext/tag_list/main.php +++ b/ext/tag_list/main.php @@ -102,7 +102,7 @@ class TagList extends SimpleExtension { } // }}} // misc {{{ - private function tag_link($tag) { + private function tag_link(/*string*/ $tag) { $u_tag = url_escape($tag); return make_link("post/list/$u_tag/1"); } @@ -294,7 +294,7 @@ class TagList extends SimpleExtension { } // }}} // blocks {{{ - private function add_related_block($page, $image) { + private function add_related_block(Page $page, Image $image) { global $database; global $config; @@ -326,7 +326,7 @@ class TagList extends SimpleExtension { } } - private function add_tags_block($page, $image) { + private function add_tags_block(Page $page, Image $image) { global $database; global $config; @@ -345,7 +345,7 @@ class TagList extends SimpleExtension { } } - private function add_popular_block($page) { + private function add_popular_block(Page $page) { global $database; global $config; @@ -368,7 +368,7 @@ class TagList extends SimpleExtension { } } - private function add_refine_block($page, $search) { + private function add_refine_block(Page $page, /*string*/ $search) { global $database; global $config; diff --git a/ext/upload/main.php b/ext/upload/main.php index 8090a08e..e6cd3d7c 100644 --- a/ext/upload/main.php +++ b/ext/upload/main.php @@ -218,7 +218,7 @@ class Upload extends SimpleExtension { } // }}} // do things {{{ - private function can_upload($user) { + private function can_upload(User $user) { global $config; return ($config->get_bool("upload_anon") || !$user->is_anonymous()); } diff --git a/ext/user/main.php b/ext/user/main.php index 33a1d4a5..2a74da4e 100644 --- a/ext/user/main.php +++ b/ext/user/main.php @@ -263,7 +263,7 @@ class UserPage extends SimpleExtension { } // }}} // Things done *with* the user {{{ - private function login($page) { + private function login(Page $page) { global $user; $name = $_POST['user']; @@ -289,7 +289,7 @@ class UserPage extends SimpleExtension { } } - private function check_user_creation($event) { + private function check_user_creation($event) { // FIXME type $name = $event->username; $pass = $event->password; $email = $event->email; @@ -309,7 +309,7 @@ class UserPage extends SimpleExtension { } } - private function create_user($event) { + private function create_user($event) { // FIXME type global $database; $hash = md5(strtolower($event->username) . $event->password); @@ -326,7 +326,7 @@ class UserPage extends SimpleExtension { log_info("user", "Created User #$uid ({$event->username})"); } - private function set_login_cookie($name, $pass) { + private function set_login_cookie(/*string*/ $name, /*string*/ $pass) { global $config; $addr = get_session_ip($config); @@ -339,7 +339,7 @@ class UserPage extends SimpleExtension { } //}}} // Things done *to* the user {{{ - private function change_password_wrapper($page) { + private function change_password_wrapper(Page $page) { global $user; global $config; global $database; @@ -378,7 +378,7 @@ class UserPage extends SimpleExtension { } } - private function change_email_wrapper($page) { + private function change_email_wrapper(Page $page) { global $user; global $config; global $database; @@ -411,7 +411,7 @@ class UserPage extends SimpleExtension { } } - private function set_more_wrapper($page) { + private function set_more_wrapper(Page $page) { global $user; global $config; global $database; @@ -443,7 +443,7 @@ class UserPage extends SimpleExtension { } // }}} // ips {{{ - private function count_upload_ips($duser) { + private function count_upload_ips(User $duser) { global $database; $rows = $database->get_pairs(" SELECT @@ -456,7 +456,7 @@ class UserPage extends SimpleExtension { ORDER BY most_recent DESC", array("id"=>$duser->id)); return $rows; } - private function count_comment_ips($duser) { + private function count_comment_ips(User $duser) { global $database; $rows = $database->get_pairs(" SELECT @@ -470,7 +470,7 @@ class UserPage extends SimpleExtension { return $rows; } - private function delete_user($page) { + private function delete_user(Page $page) { global $user; global $config; global $database; @@ -501,7 +501,7 @@ class UserPage extends SimpleExtension { } } - private function delete_user_with_images($page) { + private function delete_user_with_images(Page $page) { global $user; global $config; global $database; diff --git a/ext/view/main.php b/ext/view/main.php index 58399b1c..3fa700f6 100644 --- a/ext/view/main.php +++ b/ext/view/main.php @@ -60,7 +60,7 @@ class ImageAdminBlockBuildingEvent extends Event { $this->user = $user; } - public function add_part($html, $position=50) { + public function add_part(/*string*/ $html, /*int*/ $position=50) { while(isset($this->parts[$position])) $position++; $this->parts[$position] = $html; }