more type hints
This commit is contained in:
parent
52ff412b38
commit
cc8f1f35a5
@ -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);
|
||||
|
@ -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("<span style=\"background-color:#000; color:#000;\">","</span>"),
|
||||
$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) {
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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")) {
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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()) &&
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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());
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user