From a73791be7490de54ab5808c5bf55e12bead78017 Mon Sep 17 00:00:00 2001 From: Happy-melon Date: Thu, 6 Oct 2011 13:22:53 +0000 Subject: [PATCH] Documentation and type hinting. --- includes/Pager.php | 30 +++++++++++++++++++++++++----- includes/UserArray.php | 3 +++ includes/cache/LinkBatch.php | 16 ++++++++++++++-- 3 files changed, 42 insertions(+), 7 deletions(-) diff --git a/includes/Pager.php b/includes/Pager.php index b91b061752..99dbd1c8e0 100644 --- a/includes/Pager.php +++ b/includes/Pager.php @@ -95,6 +95,9 @@ abstract class IndexPager extends ContextSource implements Pager { /** True if the current result set is the first one */ public $mIsFirst; + public $mIsLast; + + protected $mLastShown, $mFirstShown, $mPastTheEndIndex, $mDefaultQuery, $mNavigationBar; /** * Result object for the query. Warning: seek before use. @@ -190,12 +193,16 @@ abstract class IndexPager extends ContextSource implements Pager { /** * Set the offset from an other source than the request + * + * @param $offset Int|String */ function setOffset( $offset ) { $this->mOffset = $offset; } /** * Set the limit from an other source than the request + * + * @param $limit Int|String */ function setLimit( $limit ) { $this->mLimit = $limit; @@ -497,6 +504,8 @@ abstract class IndexPager extends ContextSource implements Pager { * $linkTexts will be used. Both $linkTexts and $disabledTexts are arrays * of HTML. * + * @param $linkTexts Array + * @param $disabledTexts Array * @return Array */ function getPagingLinks( $linkTexts, $disabledTexts = array() ) { @@ -619,9 +628,12 @@ abstract class IndexPager extends ContextSource implements Pager { * @ingroup Pager */ abstract class AlphabeticPager extends IndexPager { + /** * Shamelessly stolen bits from ReverseChronologicalPager, * didn't want to do class magic as may be still revamped + * + * @return String HTML */ function getNavigationBar() { if ( !$this->isNavigationBarShown() ) return ''; @@ -884,9 +896,13 @@ abstract class TablePager extends IndexPager { return "$msgEmpty\n"; } + /** + * @param $row Array + * @return String HTML + */ function formatRow( $row ) { $this->mCurrentRow = $row; # In case formatValue etc need to know - $s = Xml::openElement( 'tr', $this->getRowAttrs($row) ); + $s = Xml::openElement( 'tr', $this->getRowAttrs( $row ) ); $fieldNames = $this->getFieldNames(); foreach ( $fieldNames as $field => $name ) { $value = isset( $row->$field ) ? $row->$field : null; @@ -914,7 +930,7 @@ abstract class TablePager extends IndexPager { * Get attributes to be applied to the given row. * * @param $row Object: the database result row - * @return Associative array + * @return Array of => */ function getRowAttrs( $row ) { $class = $this->getRowClass( $row ); @@ -931,9 +947,9 @@ abstract class TablePager extends IndexPager { * take this as an excuse to hardcode styles; use classes and * CSS instead. Row context is available in $this->mCurrentRow * - * @param $field The column - * @param $value The cell contents - * @return Associative array + * @param $field String The column + * @param $value String The cell contents + * @return Array of attr => value */ function getCellAttrs( $field, $value ) { return array( 'class' => 'TablePager_col_' . $field ); @@ -957,6 +973,7 @@ abstract class TablePager extends IndexPager { /** * A navigation bar with images + * @return String HTML */ function getNavigationBar() { global $wgStylePath; @@ -1044,6 +1061,7 @@ abstract class TablePager extends IndexPager { * Resubmits all defined elements of the query string, except for a * blacklist, passed in the $blacklist parameter. * + * @param $blacklist Array parameters from the request query which should not be resubmitted * @return String: HTML fragment */ function getHiddenFields( $blacklist = array() ) { @@ -1120,6 +1138,8 @@ abstract class TablePager extends IndexPager { * An array mapping database field names to a textual description of the * field name, for use in the table header. The description should be plain * text, it will be HTML-escaped later. + * + * @return Array */ abstract function getFieldNames(); } diff --git a/includes/UserArray.php b/includes/UserArray.php index 6cce48c04f..c5ba0b2b35 100644 --- a/includes/UserArray.php +++ b/includes/UserArray.php @@ -77,6 +77,9 @@ class UserArrayFromResult extends UserArray { return $this->res->numRows(); } + /** + * @return User + */ function current() { return $this->current; } diff --git a/includes/cache/LinkBatch.php b/includes/cache/LinkBatch.php index 738dc2dc85..9b19ef1686 100644 --- a/includes/cache/LinkBatch.php +++ b/includes/cache/LinkBatch.php @@ -86,7 +86,8 @@ class LinkBatch { /** * Do the query and add the results to the LinkCache object - * Return an array mapping PDBK to ID + * + * @return Array mapping PDBK to ID */ public function execute() { $linkCache = LinkCache::singleton(); @@ -96,6 +97,9 @@ class LinkBatch { /** * Do the query and add the results to a given LinkCache object * Return an array mapping PDBK to ID + * + * @param $cache LinkCache + * @return Array remaining IDs */ protected function executeInto( &$cache ) { wfProfileIn( __METHOD__ ); @@ -112,8 +116,9 @@ class LinkBatch { * This function *also* stores extra fields of the title used for link * parsing to avoid extra DB queries. * - * @param $cache + * @param $cache LinkCache * @param $res + * @return Array of remaining titles */ public function addResultToCache( $cache, $res ) { if ( !$res ) { @@ -144,6 +149,7 @@ class LinkBatch { /** * Perform the existence test query, return a ResultWrapper with page_id fields + * @return Bool|ResultWrapper */ public function doQuery() { if ( $this->isEmpty() ) { @@ -168,6 +174,11 @@ class LinkBatch { return $res; } + /** + * Do (and cache) {{GENDER:...}} information for userpages in this LinkBatch + * + * @return bool whether the query was successful + */ public function doGenderQuery() { if ( $this->isEmpty() ) { return false; @@ -180,6 +191,7 @@ class LinkBatch { $genderCache = GenderCache::singleton(); $genderCache->dolinkBatch( $this->data, $this->caller ); + return true; } /** -- 2.20.1