r99099 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r99098‎ | r99099 | r99100 >
Date:13:22, 6 October 2011
Author:happy-melon
Status:ok
Tags:
Comment:
Documentation and type hinting.
Modified paths:
  • /trunk/phase3/includes/Pager.php (modified) (history)
  • /trunk/phase3/includes/UserArray.php (modified) (history)
  • /trunk/phase3/includes/cache/LinkBatch.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/cache/LinkBatch.php
@@ -86,7 +86,8 @@
8787
8888 /**
8989 * Do the query and add the results to the LinkCache object
90 - * Return an array mapping PDBK to ID
 90+ *
 91+ * @return Array mapping PDBK to ID
9192 */
9293 public function execute() {
9394 $linkCache = LinkCache::singleton();
@@ -96,6 +97,9 @@
9798 /**
9899 * Do the query and add the results to a given LinkCache object
99100 * Return an array mapping PDBK to ID
 101+ *
 102+ * @param $cache LinkCache
 103+ * @return Array remaining IDs
100104 */
101105 protected function executeInto( &$cache ) {
102106 wfProfileIn( __METHOD__ );
@@ -112,8 +116,9 @@
113117 * This function *also* stores extra fields of the title used for link
114118 * parsing to avoid extra DB queries.
115119 *
116 - * @param $cache
 120+ * @param $cache LinkCache
117121 * @param $res
 122+ * @return Array of remaining titles
118123 */
119124 public function addResultToCache( $cache, $res ) {
120125 if ( !$res ) {
@@ -144,6 +149,7 @@
145150
146151 /**
147152 * Perform the existence test query, return a ResultWrapper with page_id fields
 153+ * @return Bool|ResultWrapper
148154 */
149155 public function doQuery() {
150156 if ( $this->isEmpty() ) {
@@ -168,6 +174,11 @@
169175 return $res;
170176 }
171177
 178+ /**
 179+ * Do (and cache) {{GENDER:...}} information for userpages in this LinkBatch
 180+ *
 181+ * @return bool whether the query was successful
 182+ */
172183 public function doGenderQuery() {
173184 if ( $this->isEmpty() ) {
174185 return false;
@@ -180,6 +191,7 @@
181192
182193 $genderCache = GenderCache::singleton();
183194 $genderCache->dolinkBatch( $this->data, $this->caller );
 195+ return true;
184196 }
185197
186198 /**
Index: trunk/phase3/includes/UserArray.php
@@ -77,6 +77,9 @@
7878 return $this->res->numRows();
7979 }
8080
 81+ /**
 82+ * @return User
 83+ */
8184 function current() {
8285 return $this->current;
8386 }
Index: trunk/phase3/includes/Pager.php
@@ -95,7 +95,10 @@
9696
9797 /** True if the current result set is the first one */
9898 public $mIsFirst;
 99+ public $mIsLast;
99100
 101+ protected $mLastShown, $mFirstShown, $mPastTheEndIndex, $mDefaultQuery, $mNavigationBar;
 102+
100103 /**
101104 * Result object for the query. Warning: seek before use.
102105 *
@@ -190,12 +193,16 @@
191194
192195 /**
193196 * Set the offset from an other source than the request
 197+ *
 198+ * @param $offset Int|String
194199 */
195200 function setOffset( $offset ) {
196201 $this->mOffset = $offset;
197202 }
198203 /**
199204 * Set the limit from an other source than the request
 205+ *
 206+ * @param $limit Int|String
200207 */
201208 function setLimit( $limit ) {
202209 $this->mLimit = $limit;
@@ -497,6 +504,8 @@
498505 * $linkTexts will be used. Both $linkTexts and $disabledTexts are arrays
499506 * of HTML.
500507 *
 508+ * @param $linkTexts Array
 509+ * @param $disabledTexts Array
501510 * @return Array
502511 */
503512 function getPagingLinks( $linkTexts, $disabledTexts = array() ) {
@@ -619,9 +628,12 @@
620629 * @ingroup Pager
621630 */
622631 abstract class AlphabeticPager extends IndexPager {
 632+
623633 /**
624634 * Shamelessly stolen bits from ReverseChronologicalPager,
625635 * didn't want to do class magic as may be still revamped
 636+ *
 637+ * @return String HTML
626638 */
627639 function getNavigationBar() {
628640 if ( !$this->isNavigationBarShown() ) return '';
@@ -884,9 +896,13 @@
885897 return "<tr><td colspan=\"$colspan\">$msgEmpty</td></tr>\n";
886898 }
887899
 900+ /**
 901+ * @param $row Array
 902+ * @return String HTML
 903+ */
888904 function formatRow( $row ) {
889905 $this->mCurrentRow = $row; # In case formatValue etc need to know
890 - $s = Xml::openElement( 'tr', $this->getRowAttrs($row) );
 906+ $s = Xml::openElement( 'tr', $this->getRowAttrs( $row ) );
891907 $fieldNames = $this->getFieldNames();
892908 foreach ( $fieldNames as $field => $name ) {
893909 $value = isset( $row->$field ) ? $row->$field : null;
@@ -914,7 +930,7 @@
915931 * Get attributes to be applied to the given row.
916932 *
917933 * @param $row Object: the database result row
918 - * @return Associative array
 934+ * @return Array of <attr> => <value>
919935 */
920936 function getRowAttrs( $row ) {
921937 $class = $this->getRowClass( $row );
@@ -931,9 +947,9 @@
932948 * take this as an excuse to hardcode styles; use classes and
933949 * CSS instead. Row context is available in $this->mCurrentRow
934950 *
935 - * @param $field The column
936 - * @param $value The cell contents
937 - * @return Associative array
 951+ * @param $field String The column
 952+ * @param $value String The cell contents
 953+ * @return Array of attr => value
938954 */
939955 function getCellAttrs( $field, $value ) {
940956 return array( 'class' => 'TablePager_col_' . $field );
@@ -957,6 +973,7 @@
958974
959975 /**
960976 * A navigation bar with images
 977+ * @return String HTML
961978 */
962979 function getNavigationBar() {
963980 global $wgStylePath;
@@ -1044,6 +1061,7 @@
10451062 * Resubmits all defined elements of the query string, except for a
10461063 * blacklist, passed in the $blacklist parameter.
10471064 *
 1065+ * @param $blacklist Array parameters from the request query which should not be resubmitted
10481066 * @return String: HTML fragment
10491067 */
10501068 function getHiddenFields( $blacklist = array() ) {
@@ -1120,6 +1138,8 @@
11211139 * An array mapping database field names to a textual description of the
11221140 * field name, for use in the table header. The description should be plain
11231141 * text, it will be HTML-escaped later.
 1142+ *
 1143+ * @return Array
11241144 */
11251145 abstract function getFieldNames();
11261146 }

Status & tagging log