From 8a2eb4b12172c2cb0e7d569417b2d612635c0a5d Mon Sep 17 00:00:00 2001 From: jgen Date: Sun, 27 Apr 2014 19:29:36 -0400 Subject: [PATCH] Fixing more PHP Doc related issues. --- core/userclass.class.php | 2 +- ext/admin/main.php | 17 +++++++++++--- ext/admin/theme.php | 6 +++++ ext/index/main.php | 36 +++++++++++++++++++++++++----- ext/resize/main.php | 17 +++++++++----- ext/simpletest/main.php | 2 +- ext/upload/main.php | 16 ++++++++++---- ext/view/main.php | 48 ++++++++++++++++++++++++++++++++++------ 8 files changed, 117 insertions(+), 27 deletions(-) diff --git a/core/userclass.class.php b/core/userclass.class.php index cf2e09e2..1dac7f41 100644 --- a/core/userclass.class.php +++ b/core/userclass.class.php @@ -12,7 +12,7 @@ class UserClass { public $name = null; /** - * @var null|string + * @var \UserClass|null */ public $parent = null; diff --git a/ext/admin/main.php b/ext/admin/main.php index dc8be5f0..25187267 100644 --- a/ext/admin/main.php +++ b/ext/admin/main.php @@ -24,15 +24,26 @@ * Sent when the admin page is ready to be added to */ class AdminBuildingEvent extends Event { - var $page; + /** @var \Page */ + public $page; + + /** + * @param Page $page + */ public function __construct(Page $page) { $this->page = $page; } } class AdminActionEvent extends Event { - var $action; - var $redirect = true; + /** @var string */ + public $action; + /** @var bool */ + public $redirect = true; + + /** + * @param string $action + */ public function __construct(/*string*/ $action) { $this->action = $action; } diff --git a/ext/admin/theme.php b/ext/admin/theme.php index d1f8c71b..5f1a3c5c 100644 --- a/ext/admin/theme.php +++ b/ext/admin/theme.php @@ -12,6 +12,12 @@ class AdminPageTheme extends Themelet { $page->add_block(new NavBlock()); } + /** + * @param string $name + * @param string $action + * @param bool $protected + * @return string + */ protected function button(/*string*/ $name, /*string*/ $action, /*boolean*/ $protected=false) { $c_protected = $protected ? " protected" : ""; $html = make_form(make_link("admin/$action"), "POST", false, null, null, "admin$c_protected"); diff --git a/ext/index/main.php b/ext/index/main.php index 1c00bdad..c3250bf7 100644 --- a/ext/index/main.php +++ b/ext/index/main.php @@ -159,23 +159,39 @@ * Signal that a search term needs parsing */ class SearchTermParseEvent extends Event { - var $term = null; - var $context = null; - var $querylets = array(); + /** @var null|string */ + public $term = null; + /** @var null|array */ + public $context = null; + /** @var \Querylet[] */ + public $querylets = array(); + /** + * @param string|null $term + * @param array|null $context + */ public function __construct($term, $context) { $this->term = $term; $this->context = $context; } + /** + * @return bool + */ public function is_querylet_set() { return (count($this->querylets) > 0); } + /** + * @return \Querylet[] + */ public function get_querylets() { return $this->querylets; } + /** + * @param \Querylet $q + */ public function add_querylet($q) { $this->querylets[] = $q; } @@ -185,13 +201,23 @@ class SearchTermParseException extends SCoreException { } class PostListBuildingEvent extends Event { - var $search_terms = null; - var $parts = array(); + /** @var null|array */ + public $search_terms = null; + /** @var array */ + public $parts = array(); + + /** + * @param array|null $search + */ public function __construct($search) { $this->search_terms = $search; } + /** + * @param string $html + * @param int $position + */ public function add_control(/*string*/ $html, /*int*/ $position=50) { while(isset($this->parts[$position])) $position++; $this->parts[$position] = $html; diff --git a/ext/resize/main.php b/ext/resize/main.php index 72b29231..6e1c1cb1 100644 --- a/ext/resize/main.php +++ b/ext/resize/main.php @@ -33,7 +33,7 @@ class ResizeImage extends Extension { $config->set_default_bool('resize_enabled', true); $config->set_default_bool('resize_upload', false); $config->set_default_int('resize_default_width', 0); - $config->set_default_int('resize_default_height', 0); + $config->set_default_int('resize_default_height', 0); } public function onImageAdminBlockBuilding(ImageAdminBlockBuildingEvent $event) { @@ -153,11 +153,16 @@ class ResizeImage extends Extension { // Private functions /* ----------------------------- */ - - /* - This function could be made much smaller by using the ImageReplaceEvent - ie: Pretend that we are replacing the image with a resized copy. - */ + + /** + * This function could be made much smaller by using the ImageReplaceEvent + * ie: Pretend that we are replacing the image with a resized copy. + * + * @param Image $image_obj + * @param int $width + * @param int $height + * @throws ImageResizeException + */ private function resize_image(Image $image_obj, /*int*/ $width, /*int*/ $height) { global $config, $user, $page, $database; diff --git a/ext/simpletest/main.php b/ext/simpletest/main.php index 2ff0abf0..01f17e2c 100644 --- a/ext/simpletest/main.php +++ b/ext/simpletest/main.php @@ -19,7 +19,7 @@ * For Shimmie2 specific extensions, there is a ShimmieWebTestCase class which * includes functions to upload and delete images. * - * For a quick guide on the spcifics of how to write tests, see \ref wut + * For a quick guide on the specifics of how to write tests, see \ref wut * * * \page wut Writing Unit Tests diff --git a/ext/upload/main.php b/ext/upload/main.php index 7ad79a0c..a247b804 100644 --- a/ext/upload/main.php +++ b/ext/upload/main.php @@ -54,7 +54,11 @@ class Upload extends Extension { /** @var bool */ public $is_full; - // early, so it can stop the DataUploadEvent before any data handlers see it + /** + * Early, so it can stop the DataUploadEvent before any data handlers see it. + * + * @return int + */ public function get_priority() {return 40;} public function onInitExt(InitExtEvent $event) { @@ -118,7 +122,7 @@ class Upload extends Extension { } } - public function onPageRequest($event) { + public function onPageRequest(PageRequestEvent $event) { global $config, $page, $user; if($event->page_matches("upload/replace")) { @@ -224,6 +228,10 @@ class Upload extends Extension { } } + /** + * @param string|int $id + * @return array + */ private function tags_for_upload_slot($id) { if(isset($_POST["tags$id"])) { # merge then explode, not explode then merge - else @@ -246,8 +254,8 @@ class Upload extends Extension { * * TODO: Make these messages user/admin editable * - * @param $error_code integer PHP error code - * @return String + * @param int $error_code PHP error code + * @return string */ private function upload_error_message($error_code) { switch ($error_code) { diff --git a/ext/view/main.php b/ext/view/main.php index 35bb8081..db9e7422 100644 --- a/ext/view/main.php +++ b/ext/view/main.php @@ -15,27 +15,46 @@ * which only appears when an image actually exists. */ class DisplayingImageEvent extends Event { - var $image, $page, $context; + /** @var \Image */ + public $image; + public $page, $context; + /** + * @param Image $image + */ public function __construct(Image $image) { $this->image = $image; } + /** + * @return Image + */ public function get_image() { return $this->image; } } class ImageInfoBoxBuildingEvent extends Event { - var $parts = array(); - var $image; - var $user; + /** @var array */ + public $parts = array(); + /** @var \Image */ + public $image; + /** @var \User */ + public $user; + /** + * @param Image $image + * @param User $user + */ public function __construct(Image $image, User $user) { $this->image = $image; $this->user = $user; } + /** + * @param string $html + * @param int $position + */ public function add_part($html, $position=50) { while(isset($this->parts[$position])) $position++; $this->parts[$position] = $html; @@ -43,23 +62,38 @@ class ImageInfoBoxBuildingEvent extends Event { } class ImageInfoSetEvent extends Event { - var $image; + /** @var \Image */ + public $image; + /** + * @param Image $image + */ public function __construct(Image $image) { $this->image = $image; } } class ImageAdminBlockBuildingEvent extends Event { + /** @var array */ var $parts = array(); - var $image = null; - var $user = null; + /** @var \Image|null */ + public $image = null; + /** @var null|\User */ + public $user = null; + /** + * @param Image $image + * @param User $user + */ public function __construct(Image $image, User $user) { $this->image = $image; $this->user = $user; } + /** + * @param string $html + * @param int $position + */ public function add_part(/*string*/ $html, /*int*/ $position=50) { while(isset($this->parts[$position])) $position++; $this->parts[$position] = $html;