r89040 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r89039‎ | r89040 | r89041 >
Date:15:59, 28 May 2011
Author:reedy
Status:ok
Tags:
Comment:
More parameter documentation!!
Modified paths:
  • /trunk/phase3/includes/HttpFunctions.old.php (modified) (history)
  • /trunk/phase3/includes/TitleArray.php (modified) (history)
  • /trunk/phase3/includes/UserArray.php (modified) (history)
  • /trunk/phase3/includes/cache/CacheDependency.php (modified) (history)
  • /trunk/phase3/includes/objectcache/BagOStuff.php (modified) (history)
  • /trunk/phase3/includes/objectcache/MemcachedPhpBagOStuff.php (modified) (history)
  • /trunk/phase3/includes/parser/Tidy.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/objectcache/MemcachedPhpBagOStuff.php
@@ -21,7 +21,7 @@
2222 * - timeout: The read timeout in microseconds
2323 * - connect_timeout: The connect timeout in seconds
2424 *
25 - * @params $params array
 25+ * @param $params array
2626 */
2727 function __construct( $params ) {
2828 if ( !isset( $params['servers'] ) ) {
@@ -48,42 +48,90 @@
4949 $this->client->set_debug( $params['debug'] );
5050 }
5151
 52+ /**
 53+ * @param $debug bool
 54+ */
5255 public function setDebug( $debug ) {
5356 $this->client->set_debug( $debug );
5457 }
5558
 59+ /**
 60+ * @param $key string
 61+ * @return Mixed
 62+ */
5663 public function get( $key ) {
5764 return $this->client->get( $this->encodeKey( $key ) );
5865 }
59 -
 66+
 67+ /**
 68+ * @param $key string
 69+ * @param $value
 70+ * @param $exptime int
 71+ * @return bool
 72+ */
6073 public function set( $key, $value, $exptime = 0 ) {
6174 return $this->client->set( $this->encodeKey( $key ), $value, $exptime );
6275 }
6376
 77+ /**
 78+ * @param $key string
 79+ * @param $time int
 80+ * @return bool
 81+ */
6482 public function delete( $key, $time = 0 ) {
6583 return $this->client->delete( $this->encodeKey( $key ), $time );
6684 }
6785
 86+ /**
 87+ * @param $key
 88+ * @param $timeout int
 89+ * @return
 90+ */
6891 public function lock( $key, $timeout = 0 ) {
6992 return $this->client->lock( $this->encodeKey( $key ), $timeout );
7093 }
7194
 95+ /**
 96+ * @param $key string
 97+ * @return Mixed
 98+ */
7299 public function unlock( $key ) {
73100 return $this->client->unlock( $this->encodeKey( $key ) );
74101 }
75102
 103+ /**
 104+ * @param $key string
 105+ * @param $value int
 106+ * @return Mixed
 107+ */
76108 public function add( $key, $value, $exptime = 0 ) {
77109 return $this->client->add( $this->encodeKey( $key ), $value, $exptime );
78110 }
79111
 112+ /**
 113+ * @param $key string
 114+ * @param $value int
 115+ * @param $exptime
 116+ * @return Mixed
 117+ */
80118 public function replace( $key, $value, $exptime = 0 ) {
81119 return $this->client->replace( $this->encodeKey( $key ), $value, $exptime );
82120 }
83121
 122+ /**
 123+ * @param $key string
 124+ * @param $value int
 125+ * @return Mixed
 126+ */
84127 public function incr( $key, $value = 1 ) {
85128 return $this->client->incr( $this->encodeKey( $key ), $value );
86129 }
87130
 131+ /**
 132+ * @param $key string
 133+ * @param $value int
 134+ * @return Mixed
 135+ */
88136 public function decr( $key, $value = 1 ) {
89137 return $this->client->decr( $this->encodeKey( $key ), $value );
90138 }
@@ -91,6 +139,8 @@
92140 /**
93141 * Get the underlying client object. This is provided for debugging
94142 * purposes.
 143+ *
 144+ * @return MemCachedClientforWiki
95145 */
96146 public function getClient() {
97147 return $this->client;
@@ -116,6 +166,10 @@
117167 /**
118168 * Decode a key encoded with encodeKey(). This is provided as a convenience
119169 * function for debugging.
 170+ *
 171+ * @param $key string
 172+ *
 173+ * @return string
120174 */
121175 public function decodeKey( $key ) {
122176 return urldecode( $key );
Index: trunk/phase3/includes/objectcache/BagOStuff.php
@@ -43,6 +43,9 @@
4444 abstract class BagOStuff {
4545 private $debugMode = false;
4646
 47+ /**
 48+ * @param $bool bool
 49+ */
4750 public function setDebug( $bool ) {
4851 $this->debugMode = $bool;
4952 }
@@ -53,6 +56,8 @@
5457 /**
5558 * Get an item with the given key. Returns false if it does not exist.
5659 * @param $key string
 60+ *
 61+ * @return bool|Object
5762 */
5863 abstract public function get( $key );
5964
Index: trunk/phase3/includes/parser/Tidy.php
@@ -17,13 +17,24 @@
1818 */
1919 class MWTidyWrapper {
2020
21 - protected $mTokens, $mUniqPrefix;
 21+ /**
 22+ * @var ReplacementArray
 23+ */
 24+ protected $mTokens;
2225
 26+ protected $mUniqPrefix;
 27+
 28+ protected $mMarkerIndex;
 29+
2330 public function __construct() {
2431 $this->mTokens = null;
2532 $this->mUniqPrefix = null;
2633 }
2734
 35+ /**
 36+ * @param $text string
 37+ * @return string
 38+ */
2839 public function getWrapped( $text ) {
2940 $this->mTokens = new ReplacementArray;
3041 $this->mUniqPrefix = "\x7fUNIQ" .
@@ -40,7 +51,9 @@
4152 }
4253
4354 /**
44 - * @private
 55+ * @param $m array
 56+ *
 57+ * @return string
4558 */
4659 function replaceEditSectionLinksCallback( $m ) {
4760 $marker = "{$this->mUniqPrefix}-item-{$this->mMarkerIndex}" . Parser::MARKER_SUFFIX;
@@ -49,6 +62,10 @@
5063 return $marker;
5164 }
5265
 66+ /**
 67+ * @param $text string
 68+ * @return string
 69+ */
5370 public function postprocess( $text ) {
5471 return $this->mTokens->replace( $text );
5572 }
@@ -187,6 +204,12 @@
188205 * saving the overhead of spawning a new process.
189206 *
190207 * 'pear install tidy' should be able to compile the extension module.
 208+ *
 209+ * @param $text
 210+ * @param $stderr
 211+ * @param $retval
 212+ *
 213+ * @return string
191214 */
192215 private static function execInternalTidy( $text, $stderr = false, &$retval = null ) {
193216 global $wgTidyConf, $wgDebugTidy;
Index: trunk/phase3/includes/TitleArray.php
@@ -11,7 +11,7 @@
1212 */
1313 abstract class TitleArray implements Iterator {
1414 /**
15 - * @param $res result A MySQL result including at least page_namespace and
 15+ * @param $res ResultWrapper A SQL result including at least page_namespace and
1616 * page_title -- also can have page_id, page_len, page_is_redirect,
1717 * page_latest (if those will be used). See Title::newFromRow.
1818 * @return TitleArrayFromResult
@@ -28,7 +28,7 @@
2929 }
3030
3131 /**
32 - * @param $res
 32+ * @param $res ResultWrapper
3333 * @return TitleArrayFromResult
3434 */
3535 protected static function newFromResult_internal( $res ) {
@@ -38,6 +38,10 @@
3939 }
4040
4141 class TitleArrayFromResult extends TitleArray {
 42+
 43+ /**
 44+ * @var ResultWrapper
 45+ */
4246 var $res;
4347 var $key, $current;
4448
@@ -47,6 +51,10 @@
4852 $this->setCurrent( $this->res->current() );
4953 }
5054
 55+ /**
 56+ * @param $row ResultWrapper
 57+ * @return void
 58+ */
5159 protected function setCurrent( $row ) {
5260 if ( $row === false ) {
5361 $this->current = false;
@@ -55,6 +63,9 @@
5664 }
5765 }
5866
 67+ /**
 68+ * @return int
 69+ */
5970 public function count() {
6071 return $this->res->numRows();
6172 }
@@ -79,6 +90,9 @@
8091 $this->setCurrent( $this->res->current() );
8192 }
8293
 94+ /**
 95+ * @return bool
 96+ */
8397 function valid() {
8498 return $this->current !== false;
8599 }
Index: trunk/phase3/includes/cache/CacheDependency.php
@@ -58,6 +58,10 @@
5959
6060 /**
6161 * Store the wrapper to a cache
 62+ *
 63+ * @param $cache BagOStuff
 64+ * @param $key
 65+ * @param $expiry
6266 */
6367 function storeToCache( $cache, $key, $expiry = 0 ) {
6468 $this->initialiseDeps();
@@ -69,7 +73,7 @@
7074 * it will be generated with the callback function (if present), and the newly
7175 * calculated value will be stored to the cache in a wrapper.
7276 *
73 - * @param $cache Object: a cache object such as $wgMemc
 77+ * @param $cache BagOStuff a cache object such as $wgMemc
7478 * @param $key String: the cache key
7579 * @param $expiry Integer: the expiry timestamp or interval in seconds
7680 * @param $callback Mixed: the callback for generating the value, or false
@@ -156,6 +160,9 @@
157161 }
158162 }
159163
 164+ /**
 165+ * @return bool
 166+ */
160167 function isExpired() {
161168 if ( !file_exists( $this->filename ) ) {
162169 if ( $this->timestamp === false ) {
@@ -204,11 +211,16 @@
205212
206213 /**
207214 * Get rid of bulky Title object for sleep
 215+ *
 216+ * @return array
208217 */
209218 function __sleep() {
210219 return array( 'ns', 'dbk', 'touched' );
211220 }
212221
 222+ /**
 223+ * @return Title
 224+ */
213225 function getTitle() {
214226 if ( !isset( $this->titleObj ) ) {
215227 $this->titleObj = Title::makeTitle( $this->ns, $this->dbk );
@@ -217,6 +229,9 @@
218230 return $this->titleObj;
219231 }
220232
 233+ /**
 234+ * @return bool
 235+ */
221236 function isExpired() {
222237 $touched = $this->getTitle()->getTouched();
223238
@@ -292,6 +307,9 @@
293308 $this->timestamps = $this->calculateTimestamps();
294309 }
295310
 311+ /**
 312+ * @return array
 313+ */
296314 function __sleep() {
297315 return array( 'timestamps' );
298316 }
@@ -304,6 +322,9 @@
305323 return $this->linkBatch;
306324 }
307325
 326+ /**
 327+ * @return bool
 328+ */
308329 function isExpired() {
309330 $newTimestamps = $this->calculateTimestamps();
310331
@@ -345,6 +366,9 @@
346367 $this->value = $GLOBALS[$name];
347368 }
348369
 370+ /**
 371+ * @return bool
 372+ */
349373 function isExpired() {
350374 return $GLOBALS[$this->name] != $this->value;
351375 }
@@ -361,6 +385,9 @@
362386 $this->value = constant( $name );
363387 }
364388
 389+ /**
 390+ * @return bool
 391+ */
365392 function isExpired() {
366393 return constant( $this->name ) != $this->value;
367394 }
Index: trunk/phase3/includes/HttpFunctions.old.php
@@ -7,6 +7,7 @@
88 * http://www.php.net/manual/en/class.httprequest.php
99 *
1010 * This is for backwards compatibility.
 11+ * @since 1.17
1112 */
1213
1314 class HttpRequest extends MWHttpRequest { }
Index: trunk/phase3/includes/UserArray.php
@@ -1,9 +1,8 @@
22 <?php
33
44 abstract class UserArray implements Iterator {
5 -
65 /**
7 - * @param $res
 6+ * @param $res ResultWrapper
87 * @return UserArrayFromResult
98 */
109 static function newFromResult( $res ) {
@@ -33,22 +32,36 @@
3433 return self::newFromResult( $res );
3534 }
3635
 36+ /**
 37+ * @param $res
 38+ * @return UserArrayFromResult
 39+ */
3740 protected static function newFromResult_internal( $res ) {
38 - $userArray = new UserArrayFromResult( $res );
39 - return $userArray;
 41+ return new UserArrayFromResult( $res );
4042 }
4143 }
4244
4345 class UserArrayFromResult extends UserArray {
 46+
 47+ /**
 48+ * @var ResultWrapper
 49+ */
4450 var $res;
4551 var $key, $current;
4652
 53+ /**
 54+ * @param $res ResultWrapper
 55+ */
4756 function __construct( $res ) {
4857 $this->res = $res;
4958 $this->key = 0;
5059 $this->setCurrent( $this->res->current() );
5160 }
5261
 62+ /**
 63+ * @param $row
 64+ * @return void
 65+ */
5366 protected function setCurrent( $row ) {
5467 if ( $row === false ) {
5568 $this->current = false;
@@ -57,6 +70,9 @@
5871 }
5972 }
6073
 74+ /**
 75+ * @return int
 76+ */
6177 public function count() {
6278 return $this->res->numRows();
6379 }
@@ -81,6 +97,9 @@
8298 $this->setCurrent( $this->res->current() );
8399 }
84100
 101+ /**
 102+ * @return bool
 103+ */
85104 function valid() {
86105 return $this->current !== false;
87106 }

Status & tagging log