From 4c29198850d2d751211f14b23c159d37aa2bf687 Mon Sep 17 00:00:00 2001 From: Sam Reed Date: Sat, 28 May 2011 17:51:33 +0000 Subject: [PATCH] And some more.... --- includes/Cdb_PHP.php | 17 +++++++++++++++ includes/HTMLForm.php | 2 +- includes/HistoryBlob.php | 17 +++++++++++++++ includes/db/LBFactory_Single.php | 17 +++++++++++++++ includes/filerepo/ForeignDBFile.php | 23 +++++++++++++++++++- includes/media/Tiff.php | 10 ++++++--- includes/parser/ParserOutput.php | 33 ++++++++++++++++++----------- includes/parser/Preprocessor.php | 22 +++++++++++++++++-- 8 files changed, 122 insertions(+), 19 deletions(-) diff --git a/includes/Cdb_PHP.php b/includes/Cdb_PHP.php index 70dccdf9ad..f4029ba5e6 100644 --- a/includes/Cdb_PHP.php +++ b/includes/Cdb_PHP.php @@ -16,6 +16,10 @@ class CdbFunctions { /** * Take a modulo of a signed integer as if it were an unsigned integer. * $b must be less than 0x40000000 and greater than 0 + * + * @param $a + * @param $b + * * @return int */ public static function unsignedMod( $a, $b ) { @@ -48,6 +52,7 @@ class CdbFunctions { * The CDB hash function. * * @param $s + * * @return */ public static function hash( $s ) { @@ -116,6 +121,10 @@ class CdbReader_PHP extends CdbReader { unset( $this->handle ); } + /** + * @param $key + * @return bool|string + */ public function get( $key ) { // strval is required if ( $this->find( strval( $key ) ) ) { @@ -327,6 +336,11 @@ class CdbWriter_PHP extends CdbWriter { $this->pos = $newpos; } + /** + * @param $keylen + * @param $datalen + * @param $h + */ protected function addend( $keylen, $datalen, $h ) { $this->hplist[] = array( 'h' => $h, @@ -355,6 +369,9 @@ class CdbWriter_PHP extends CdbWriter { $this->write( $buf ); } + /** + * @throws MWException + */ protected function finish() { // Hack for DBA cross-check $this->hplist = array_reverse( $this->hplist ); diff --git a/includes/HTMLForm.php b/includes/HTMLForm.php index ec038c90f7..98800545e3 100644 --- a/includes/HTMLForm.php +++ b/includes/HTMLForm.php @@ -861,7 +861,7 @@ abstract class HTMLFormField { /** * Initialise the object - * @param $params Associative Array. See HTMLForm doc for syntax. + * @param $params array Associative Array. See HTMLForm doc for syntax. */ function __construct( $params ) { $this->mParams = $params; diff --git a/includes/HistoryBlob.php b/includes/HistoryBlob.php index 3fc27a2944..fdc55a5d5c 100644 --- a/includes/HistoryBlob.php +++ b/includes/HistoryBlob.php @@ -290,6 +290,8 @@ class HistoryBlobCurStub { /** * Sets the location (cur_id) of the main object to which this object * points + * + * @param $id int */ function setLocation( $id ) { $this->mCurId = $id; @@ -482,6 +484,11 @@ class DiffHistoryBlob implements HistoryBlob { } } + /** + * @param $t1 + * @param $t2 + * @return string + */ function diff( $t1, $t2 ) { # Need to do a null concatenation with warnings off, due to bugs in the current version of xdiff # "String is not zero-terminated" @@ -491,6 +498,11 @@ class DiffHistoryBlob implements HistoryBlob { return $diff; } + /** + * @param $base + * @param $diff + * @return bool|string + */ function patch( $base, $diff ) { if ( function_exists( 'xdiff_string_bpatch' ) ) { wfSuppressWarnings(); @@ -561,6 +573,9 @@ class DiffHistoryBlob implements HistoryBlob { } } + /** + * @return array + */ function __sleep() { $this->compress(); if ( !count( $this->mItems ) ) { @@ -626,6 +641,8 @@ class DiffHistoryBlob implements HistoryBlob { /** * Helper function for compression jobs * Returns true until the object is "full" and ready to be committed + * + * @return bool */ function isHappy() { return $this->mSize < $this->mMaxSize diff --git a/includes/db/LBFactory_Single.php b/includes/db/LBFactory_Single.php index 17b348d801..cf5ea7cf6f 100644 --- a/includes/db/LBFactory_Single.php +++ b/includes/db/LBFactory_Single.php @@ -15,6 +15,8 @@ class LBFactory_Single extends LBFactory { } /** + * @param $wiki + * * @return LoadBalancer_Single */ function newMainLB( $wiki = false ) { @@ -22,6 +24,8 @@ class LBFactory_Single extends LBFactory { } /** + * @param $wiki + * * @return LoadBalancer_Single */ function getMainLB( $wiki = false ) { @@ -29,6 +33,9 @@ class LBFactory_Single extends LBFactory { } /** + * @param $cluster + * @param $wiki + * * @return LoadBalancer_Single */ function newExternalLB( $cluster, $wiki = false ) { @@ -36,12 +43,19 @@ class LBFactory_Single extends LBFactory { } /** + * @param $cluster + * @param $wiki + * * @return LoadBalancer_Single */ function &getExternalLB( $cluster, $wiki = false ) { return $this->lb; } + /** + * @param $callback string|array + * @param $params array + */ function forEachLB( $callback, $params = array() ) { call_user_func_array( $callback, array_merge( array( $this->lb ), $params ) ); } @@ -57,6 +71,9 @@ class LoadBalancer_Single extends LoadBalancer { */ var $db; + /** + * @param $params array + */ function __construct( $params ) { $this->db = $params['connection']; parent::__construct( array( 'servers' => array( array( diff --git a/includes/filerepo/ForeignDBFile.php b/includes/filerepo/ForeignDBFile.php index 5f04ea731b..09bee39c0a 100644 --- a/includes/filerepo/ForeignDBFile.php +++ b/includes/filerepo/ForeignDBFile.php @@ -12,6 +12,13 @@ * @ingroup FileRepo */ class ForeignDBFile extends LocalFile { + + /** + * @param $title + * @param $repo + * @param $unused + * @return ForeignDBFile + */ static function newFromTitle( $title, $repo, $unused = null ) { return new self( $title, $repo ); } @@ -19,6 +26,11 @@ class ForeignDBFile extends LocalFile { /** * Create a ForeignDBFile from a title * Do not call this except from inside a repo class. + * + * @param $row + * @param $repo + * + * @return ForeignDBFile */ static function newFromRow( $row, $repo ) { $title = Title::makeTitle( NS_FILE, $row->img_name ); @@ -35,21 +47,30 @@ class ForeignDBFile extends LocalFile { $watch = false, $timestamp = false ) { $this->readOnlyError(); } + function restore( $versions = array(), $unsuppress = false ) { $this->readOnlyError(); } + function delete( $reason, $suppress = false ) { $this->readOnlyError(); } + function move( $target ) { $this->readOnlyError(); } - + + /** + * @return string + */ function getDescriptionUrl() { // Restore remote behaviour return File::getDescriptionUrl(); } + /** + * @return string + */ function getDescriptionText() { // Restore remote behaviour return File::getDescriptionText(); diff --git a/includes/media/Tiff.php b/includes/media/Tiff.php index 51e3194d6f..64710ce3d1 100644 --- a/includes/media/Tiff.php +++ b/includes/media/Tiff.php @@ -17,6 +17,8 @@ class TiffHandler extends JpegOrTiffHandler { * Conversion to PNG for inline display can be disabled here... * Note scaling should work with ImageMagick, but may not with GD scaling. * + * @param $file + * * @return bool */ function canRender( $file ) { @@ -28,6 +30,8 @@ class TiffHandler extends JpegOrTiffHandler { * Browsers don't support TIFF inline generally... * For inline display, we need to convert to PNG. * + * @param $file + * * @return bool */ function mustRender( $file ) { @@ -35,9 +39,9 @@ class TiffHandler extends JpegOrTiffHandler { } /** - * @param $ext - * @param $mime - * @param null $params + * @param $ext + * @param $mime + * @param $params * @return bool */ function getThumbType( $ext, $mime, $params = null ) { diff --git a/includes/parser/ParserOutput.php b/includes/parser/ParserOutput.php index 21bbe47453..39da818f47 100644 --- a/includes/parser/ParserOutput.php +++ b/includes/parser/ParserOutput.php @@ -26,9 +26,8 @@ class CacheTime { * setCacheTime() sets the timestamp expressing when the page has been rendered. * This doesn not control expiry, see updateCacheExpiry() for that! */ - function setCacheTime( $t ) { return wfSetVar( $this->mCacheTime, $t ); } + function setCacheTime( $t ) { return wfSetVar( $this->mCacheTime, $t ); } - /** * Sets the number of seconds after which this object should expire. * This value is used with the ParserCache. @@ -40,12 +39,14 @@ class CacheTime { function updateCacheExpiry( $seconds ) { $seconds = (int)$seconds; - if ( $this->mCacheExpiry === null || $this->mCacheExpiry > $seconds ) - $this->mCacheExpiry = $seconds; + if ( $this->mCacheExpiry === null || $this->mCacheExpiry > $seconds ) { + $this->mCacheExpiry = $seconds; + } // hack: set old-style marker for uncacheable entries. - if ( $this->mCacheExpiry !== null && $this->mCacheExpiry <= 0 ) + if ( $this->mCacheExpiry !== null && $this->mCacheExpiry <= 0 ) { $this->mCacheTime = -1; + } } /** @@ -59,28 +60,36 @@ class CacheTime { function getCacheExpiry() { global $wgParserCacheExpireTime; - if ( $this->mCacheTime < 0 ) return 0; // old-style marker for "not cachable" + if ( $this->mCacheTime < 0 ) { + return 0; + } // old-style marker for "not cachable" $expire = $this->mCacheExpiry; - if ( $expire === null ) + if ( $expire === null ) { $expire = $wgParserCacheExpireTime; - else + } else { $expire = min( $expire, $wgParserCacheExpireTime ); + } if( $this->containsOldMagic() ) { //compatibility hack $expire = min( $expire, 3600 ); # 1 hour } - if ( $expire <= 0 ) return 0; // not cachable - else return $expire; + if ( $expire <= 0 ) { + return 0; // not cachable + } else { + return $expire; + } } - + /** + * @return bool + */ function isCacheable() { return $this->getCacheExpiry() > 0; } - + /** * Return true if this cached output object predates the global or * per-article cache invalidation timestamps, or if it comes from diff --git a/includes/parser/Preprocessor.php b/includes/parser/Preprocessor.php index 8eac6f0f3d..1e9343b56d 100644 --- a/includes/parser/Preprocessor.php +++ b/includes/parser/Preprocessor.php @@ -9,7 +9,11 @@ * @ingroup Parser */ interface Preprocessor { - /** Create a new preprocessor object based on an initialised Parser object */ + /** + * Create a new preprocessor object based on an initialised Parser object + * + * @param $parser Parser + */ function __construct( $parser ); /** @@ -28,12 +32,19 @@ interface Preprocessor { */ function newCustomFrame( $args ); - /** Create a new custom node for programmatic use of parameter replacement as used in some extensions */ + /** + * Create a new custom node for programmatic use of parameter replacement as used in some extensions + * + * @param $values + */ function newPartNodeArray( $values ); /** * Preprocess text to a PPNode * + * @param $text + * @param $flags + * * @return PPNode */ function preprocessToObj( $text, $flags = 0 ); @@ -54,6 +65,9 @@ interface PPFrame { /** * Create a child frame * + * @param $args array + * @param $title Title + * * @return PPFrame */ function newChild( $args = false, $title = false ); @@ -86,6 +100,8 @@ interface PPFrame { /** * Returns true if there are no arguments in this frame + * + * @return bool */ function isEmpty(); @@ -111,6 +127,8 @@ interface PPFrame { /** * Returns true if the infinite loop check is OK, false if a loop is detected + * + * @return bool */ function loopCheck( $title ); -- 2.20.1