From ba0cbdeeff9397c94acf7e6280a26839b8cac843 Mon Sep 17 00:00:00 2001 From: Sam Reed Date: Sat, 28 May 2011 15:59:57 +0000 Subject: [PATCH] More parameter documentation!! --- includes/HttpFunctions.old.php | 1 + includes/TitleArray.php | 18 +++++- includes/UserArray.php | 27 +++++++-- includes/cache/CacheDependency.php | 29 +++++++++- includes/objectcache/BagOStuff.php | 5 ++ .../objectcache/MemcachedPhpBagOStuff.php | 58 ++++++++++++++++++- includes/parser/Tidy.php | 27 ++++++++- 7 files changed, 154 insertions(+), 11 deletions(-) diff --git a/includes/HttpFunctions.old.php b/includes/HttpFunctions.old.php index 6d28abc6ab..ddfa608eec 100644 --- a/includes/HttpFunctions.old.php +++ b/includes/HttpFunctions.old.php @@ -7,6 +7,7 @@ * http://www.php.net/manual/en/class.httprequest.php * * This is for backwards compatibility. + * @since 1.17 */ class HttpRequest extends MWHttpRequest { } diff --git a/includes/TitleArray.php b/includes/TitleArray.php index 7274a19d0b..969600897c 100644 --- a/includes/TitleArray.php +++ b/includes/TitleArray.php @@ -11,7 +11,7 @@ */ abstract class TitleArray implements Iterator { /** - * @param $res result A MySQL result including at least page_namespace and + * @param $res ResultWrapper A SQL result including at least page_namespace and * page_title -- also can have page_id, page_len, page_is_redirect, * page_latest (if those will be used). See Title::newFromRow. * @return TitleArrayFromResult @@ -28,7 +28,7 @@ abstract class TitleArray implements Iterator { } /** - * @param $res + * @param $res ResultWrapper * @return TitleArrayFromResult */ protected static function newFromResult_internal( $res ) { @@ -38,6 +38,10 @@ abstract class TitleArray implements Iterator { } class TitleArrayFromResult extends TitleArray { + + /** + * @var ResultWrapper + */ var $res; var $key, $current; @@ -47,6 +51,10 @@ class TitleArrayFromResult extends TitleArray { $this->setCurrent( $this->res->current() ); } + /** + * @param $row ResultWrapper + * @return void + */ protected function setCurrent( $row ) { if ( $row === false ) { $this->current = false; @@ -55,6 +63,9 @@ class TitleArrayFromResult extends TitleArray { } } + /** + * @return int + */ public function count() { return $this->res->numRows(); } @@ -79,6 +90,9 @@ class TitleArrayFromResult extends TitleArray { $this->setCurrent( $this->res->current() ); } + /** + * @return bool + */ function valid() { return $this->current !== false; } diff --git a/includes/UserArray.php b/includes/UserArray.php index a69df41ef1..6cce48c04f 100644 --- a/includes/UserArray.php +++ b/includes/UserArray.php @@ -1,9 +1,8 @@ res = $res; $this->key = 0; $this->setCurrent( $this->res->current() ); } + /** + * @param $row + * @return void + */ protected function setCurrent( $row ) { if ( $row === false ) { $this->current = false; @@ -57,6 +70,9 @@ class UserArrayFromResult extends UserArray { } } + /** + * @return int + */ public function count() { return $this->res->numRows(); } @@ -81,6 +97,9 @@ class UserArrayFromResult extends UserArray { $this->setCurrent( $this->res->current() ); } + /** + * @return bool + */ function valid() { return $this->current !== false; } diff --git a/includes/cache/CacheDependency.php b/includes/cache/CacheDependency.php index 74ca2864e2..aa0206643b 100644 --- a/includes/cache/CacheDependency.php +++ b/includes/cache/CacheDependency.php @@ -58,6 +58,10 @@ class DependencyWrapper { /** * Store the wrapper to a cache + * + * @param $cache BagOStuff + * @param $key + * @param $expiry */ function storeToCache( $cache, $key, $expiry = 0 ) { $this->initialiseDeps(); @@ -69,7 +73,7 @@ class DependencyWrapper { * it will be generated with the callback function (if present), and the newly * calculated value will be stored to the cache in a wrapper. * - * @param $cache Object: a cache object such as $wgMemc + * @param $cache BagOStuff a cache object such as $wgMemc * @param $key String: the cache key * @param $expiry Integer: the expiry timestamp or interval in seconds * @param $callback Mixed: the callback for generating the value, or false @@ -156,6 +160,9 @@ class FileDependency extends CacheDependency { } } + /** + * @return bool + */ function isExpired() { if ( !file_exists( $this->filename ) ) { if ( $this->timestamp === false ) { @@ -204,11 +211,16 @@ class TitleDependency extends CacheDependency { /** * Get rid of bulky Title object for sleep + * + * @return array */ function __sleep() { return array( 'ns', 'dbk', 'touched' ); } + /** + * @return Title + */ function getTitle() { if ( !isset( $this->titleObj ) ) { $this->titleObj = Title::makeTitle( $this->ns, $this->dbk ); @@ -217,6 +229,9 @@ class TitleDependency extends CacheDependency { return $this->titleObj; } + /** + * @return bool + */ function isExpired() { $touched = $this->getTitle()->getTouched(); @@ -292,6 +307,9 @@ class TitleListDependency extends CacheDependency { $this->timestamps = $this->calculateTimestamps(); } + /** + * @return array + */ function __sleep() { return array( 'timestamps' ); } @@ -304,6 +322,9 @@ class TitleListDependency extends CacheDependency { return $this->linkBatch; } + /** + * @return bool + */ function isExpired() { $newTimestamps = $this->calculateTimestamps(); @@ -345,6 +366,9 @@ class GlobalDependency extends CacheDependency { $this->value = $GLOBALS[$name]; } + /** + * @return bool + */ function isExpired() { return $GLOBALS[$this->name] != $this->value; } @@ -361,6 +385,9 @@ class ConstantDependency extends CacheDependency { $this->value = constant( $name ); } + /** + * @return bool + */ function isExpired() { return constant( $this->name ) != $this->value; } diff --git a/includes/objectcache/BagOStuff.php b/includes/objectcache/BagOStuff.php index fd0f621312..634eff35f7 100644 --- a/includes/objectcache/BagOStuff.php +++ b/includes/objectcache/BagOStuff.php @@ -43,6 +43,9 @@ abstract class BagOStuff { private $debugMode = false; + /** + * @param $bool bool + */ public function setDebug( $bool ) { $this->debugMode = $bool; } @@ -53,6 +56,8 @@ abstract class BagOStuff { /** * Get an item with the given key. Returns false if it does not exist. * @param $key string + * + * @return bool|Object */ abstract public function get( $key ); diff --git a/includes/objectcache/MemcachedPhpBagOStuff.php b/includes/objectcache/MemcachedPhpBagOStuff.php index 17d1292e35..1401668399 100644 --- a/includes/objectcache/MemcachedPhpBagOStuff.php +++ b/includes/objectcache/MemcachedPhpBagOStuff.php @@ -21,7 +21,7 @@ class MemcachedPhpBagOStuff extends BagOStuff { * - timeout: The read timeout in microseconds * - connect_timeout: The connect timeout in seconds * - * @params $params array + * @param $params array */ function __construct( $params ) { if ( !isset( $params['servers'] ) ) { @@ -48,42 +48,90 @@ class MemcachedPhpBagOStuff extends BagOStuff { $this->client->set_debug( $params['debug'] ); } + /** + * @param $debug bool + */ public function setDebug( $debug ) { $this->client->set_debug( $debug ); } + /** + * @param $key string + * @return Mixed + */ public function get( $key ) { return $this->client->get( $this->encodeKey( $key ) ); } - + + /** + * @param $key string + * @param $value + * @param $exptime int + * @return bool + */ public function set( $key, $value, $exptime = 0 ) { return $this->client->set( $this->encodeKey( $key ), $value, $exptime ); } + /** + * @param $key string + * @param $time int + * @return bool + */ public function delete( $key, $time = 0 ) { return $this->client->delete( $this->encodeKey( $key ), $time ); } + /** + * @param $key + * @param $timeout int + * @return + */ public function lock( $key, $timeout = 0 ) { return $this->client->lock( $this->encodeKey( $key ), $timeout ); } + /** + * @param $key string + * @return Mixed + */ public function unlock( $key ) { return $this->client->unlock( $this->encodeKey( $key ) ); } + /** + * @param $key string + * @param $value int + * @return Mixed + */ public function add( $key, $value, $exptime = 0 ) { return $this->client->add( $this->encodeKey( $key ), $value, $exptime ); } + /** + * @param $key string + * @param $value int + * @param $exptime + * @return Mixed + */ public function replace( $key, $value, $exptime = 0 ) { return $this->client->replace( $this->encodeKey( $key ), $value, $exptime ); } + /** + * @param $key string + * @param $value int + * @return Mixed + */ public function incr( $key, $value = 1 ) { return $this->client->incr( $this->encodeKey( $key ), $value ); } + /** + * @param $key string + * @param $value int + * @return Mixed + */ public function decr( $key, $value = 1 ) { return $this->client->decr( $this->encodeKey( $key ), $value ); } @@ -91,6 +139,8 @@ class MemcachedPhpBagOStuff extends BagOStuff { /** * Get the underlying client object. This is provided for debugging * purposes. + * + * @return MemCachedClientforWiki */ public function getClient() { return $this->client; @@ -116,6 +166,10 @@ class MemcachedPhpBagOStuff extends BagOStuff { /** * Decode a key encoded with encodeKey(). This is provided as a convenience * function for debugging. + * + * @param $key string + * + * @return string */ public function decodeKey( $key ) { return urldecode( $key ); diff --git a/includes/parser/Tidy.php b/includes/parser/Tidy.php index a745eac039..e434db782b 100644 --- a/includes/parser/Tidy.php +++ b/includes/parser/Tidy.php @@ -17,13 +17,24 @@ */ class MWTidyWrapper { - protected $mTokens, $mUniqPrefix; + /** + * @var ReplacementArray + */ + protected $mTokens; + + protected $mUniqPrefix; + + protected $mMarkerIndex; public function __construct() { $this->mTokens = null; $this->mUniqPrefix = null; } + /** + * @param $text string + * @return string + */ public function getWrapped( $text ) { $this->mTokens = new ReplacementArray; $this->mUniqPrefix = "\x7fUNIQ" . @@ -40,7 +51,9 @@ class MWTidyWrapper { } /** - * @private + * @param $m array + * + * @return string */ function replaceEditSectionLinksCallback( $m ) { $marker = "{$this->mUniqPrefix}-item-{$this->mMarkerIndex}" . Parser::MARKER_SUFFIX; @@ -49,6 +62,10 @@ class MWTidyWrapper { return $marker; } + /** + * @param $text string + * @return string + */ public function postprocess( $text ) { return $this->mTokens->replace( $text ); } @@ -187,6 +204,12 @@ class MWTidy { * saving the overhead of spawning a new process. * * 'pear install tidy' should be able to compile the extension module. + * + * @param $text + * @param $stderr + * @param $retval + * + * @return string */ private static function execInternalTidy( $text, $stderr = false, &$retval = null ) { global $wgTidyConf, $wgDebugTidy; -- 2.20.1