From 52cd34acf590e5be946b7885ffdc13a157c1c6cf Mon Sep 17 00:00:00 2001 From: Sam Reed Date: Sat, 29 Oct 2011 01:53:28 +0000 Subject: [PATCH] More documentation --- includes/Article.php | 22 +++++++-- includes/CategoryViewer.php | 27 +++++++++++ includes/Cdb_PHP.php | 22 +++++---- includes/FileDeleteForm.php | 14 ++++++ includes/HttpFunctions.php | 27 +++++++++++ includes/ImagePage.php | 64 +++++++++++++++++++++++-- includes/Import.php | 37 +++++++++++++-- includes/LinksUpdate.php | 76 +++++++++++++++++++++++------- includes/cache/CacheDependency.php | 13 +++++ 9 files changed, 266 insertions(+), 36 deletions(-) diff --git a/includes/Article.php b/includes/Article.php index 46d26bce70..b75f4da9bd 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -33,7 +33,6 @@ class Article extends Page { protected $mPage; /** - * @protected * @var ParserOptions: ParserOptions object for $wgUser articles */ public $mParserOptions; @@ -1091,6 +1090,10 @@ class Article extends Page { } // the loop prepends the arrow image before the link, so the first case needs to be outside + + /** + * @var $title Title + */ $title = array_shift( $target ); if ( $forceKnown ) { @@ -1521,6 +1524,8 @@ class Article extends Page { /** * Perform a deletion and output success or failure messages + * @param $reason + * @param $suppress bool */ public function doDelete( $reason, $suppress = false ) { global $wgOut; @@ -2044,21 +2049,21 @@ class Article extends Page { * @param $title Title */ public static function onArticleCreate( $title ) { - return WikiPage::onArticleCreate( $title ); + WikiPage::onArticleCreate( $title ); } /** * @param $title Title */ public static function onArticleDelete( $title ) { - return WikiPage::onArticleDelete( $title ); + WikiPage::onArticleDelete( $title ); } /** * @param $title Title */ public static function onArticleEdit( $title ) { - return WikiPage::onArticleEdit( $title ); + WikiPage::onArticleEdit( $title ); } /** @@ -2087,10 +2092,16 @@ class PoolWorkArticleView extends PoolCounterWork { $this->parserOptions = $parserOptions; } + /** + * @return bool + */ function doWork() { return $this->mArticle->doViewParse(); } + /** + * @return bool + */ function getCachedWork() { global $wgOut; @@ -2108,6 +2119,9 @@ class PoolWorkArticleView extends PoolCounterWork { return false; } + /** + * @return bool + */ function fallback() { return $this->mArticle->tryDirtyCache(); } diff --git a/includes/CategoryViewer.php b/includes/CategoryViewer.php index b66beaed67..c64bb7389d 100644 --- a/includes/CategoryViewer.php +++ b/includes/CategoryViewer.php @@ -133,6 +133,9 @@ class CategoryViewer extends ContextSource { /** * Add a subcategory to the internal lists, using a Category object + * @param $cat Category + * @param $sortkey + * @param $pageLength */ function addSubcategoryObject( Category $cat, $sortkey, $pageLength ) { // Subcategory; strip the 'Category' namespace from the link text. @@ -185,6 +188,10 @@ class CategoryViewer extends ContextSource { /** * Add a page in the image namespace + * @param $title Title + * @param $sortkey + * @param $pageLength + * @param $isRedirect bool */ function addImage( Title $title, $sortkey, $pageLength, $isRedirect = false ) { global $wgContLang; @@ -211,6 +218,10 @@ class CategoryViewer extends ContextSource { /** * Add a miscellaneous page + * @param $title + * @param $sortkey + * @param $pageLength + * @param $isRedirect bool */ function addPage( $title, $sortkey, $pageLength, $isRedirect = false ) { global $wgContLang; @@ -316,6 +327,9 @@ class CategoryViewer extends ContextSource { } } + /** + * @return string + */ function getCategoryTop() { $r = $this->getCategoryBottom(); return $r === '' @@ -323,6 +337,9 @@ class CategoryViewer extends ContextSource { : "
\n" . $r; } + /** + * @return string + */ function getSubcategorySection() { # Don't show subcategories section if there are none. $r = ''; @@ -343,6 +360,9 @@ class CategoryViewer extends ContextSource { return $r; } + /** + * @return string + */ function getPagesSection() { $ti = htmlspecialchars( $this->title->getText() ); # Don't show articles section if there are none. @@ -369,6 +389,9 @@ class CategoryViewer extends ContextSource { return $r; } + /** + * @return string + */ function getImageSection() { $r = ''; $rescnt = $this->showGallery ? $this->gallery->count() : count( $this->imgsNoGallery ); @@ -408,6 +431,9 @@ class CategoryViewer extends ContextSource { } } + /** + * @return string + */ function getCategoryBottom() { return ''; } @@ -567,6 +593,7 @@ class CategoryViewer extends ContextSource { * * @param Title $title: The title (usually $this->title) * @param String $section: Which section + * @return Title */ private function addFragmentToTitle( $title, $section ) { switch ( $section ) { diff --git a/includes/Cdb_PHP.php b/includes/Cdb_PHP.php index f4029ba5e6..aaaf33a184 100644 --- a/includes/Cdb_PHP.php +++ b/includes/Cdb_PHP.php @@ -1,6 +1,6 @@ handle = fopen( $fileName, 'rb' ); if ( !$this->handle ) { @@ -257,8 +260,11 @@ class CdbWriter_PHP extends CdbWriter { var $handle, $realFileName, $tmpFileName; var $hplist; - var $numEntries, $pos; + var $numentries, $pos; + /** + * @param $fileName string + */ function __construct( $fileName ) { $this->realFileName = $fileName; $this->tmpFileName = $fileName . '.tmp.' . mt_rand( 0, 0x7fffffff ); @@ -391,7 +397,7 @@ class CdbWriter_PHP extends CdbWriter { } // Excessively clever and indulgent code to simultaneously fill $packedTables - // with the packed hashtables, and adjust the elements of $starts + // with the packed hashtables, and adjust the elements of $starts // to actually point to the starts instead of the ends. $packedTables = array_fill( 0, $this->numentries, false ); foreach ( $this->hplist as $item ) { @@ -416,7 +422,7 @@ class CdbWriter_PHP extends CdbWriter { // is taken. for ( $u = 0; $u < $count; ++$u ) { $hp = $packedTables[$starts[$i] + $u]; - $where = CdbFunctions::unsignedMod( + $where = CdbFunctions::unsignedMod( CdbFunctions::unsignedShiftRight( $hp['h'], 8 ), $len ); while ( $hashtable[$where]['p'] ) if ( ++$where == $len ) @@ -426,7 +432,7 @@ class CdbWriter_PHP extends CdbWriter { // Write the hashtable for ( $u = 0; $u < $len; ++$u ) { - $buf = pack( 'vvV', + $buf = pack( 'vvV', $hashtable[$u]['h'] & 0xffff, CdbFunctions::unsignedShiftRight( $hashtable[$u]['h'], 16 ), $hashtable[$u]['p'] ); diff --git a/includes/FileDeleteForm.php b/includes/FileDeleteForm.php index 97ac28eebc..0c5e232246 100644 --- a/includes/FileDeleteForm.php +++ b/includes/FileDeleteForm.php @@ -8,12 +8,23 @@ */ class FileDeleteForm { + /** + * @var Title + */ private $title = null; + + /** + * @var File + */ private $file = null; + /** + * @var File + */ private $oldfile = null; private $oldimage = ''; + private $DeleteReason, $DeleteReasonList; /** * Constructor * @@ -295,6 +306,9 @@ class FileDeleteForm { * value was provided, does it correspond to an * existing, local, old version of this file? * + * @param $file File + * @param $oldfile File + * @param $oldimage File * @return bool */ public static function haveDeletableFile(&$file, &$oldfile, $oldimage) { diff --git a/includes/HttpFunctions.php b/includes/HttpFunctions.php index 47dc682574..2ec7ea19f2 100644 --- a/includes/HttpFunctions.php +++ b/includes/HttpFunctions.php @@ -53,6 +53,9 @@ class Http { * Simple wrapper for Http::request( 'GET' ) * @see Http::request() * + * @param $url + * @param $timeout string + * @param $options array * @return string */ public static function get( $url, $timeout = 'default', $options = array() ) { @@ -64,6 +67,8 @@ class Http { * Simple wrapper for Http::request( 'POST' ) * @see Http::request() * + * @param $url + * @param $options array * @return string */ public static function post( $url, $options = array() ) { @@ -221,6 +226,7 @@ class MWHttpRequest { * Generate a new request object * @param $url String: url to use * @param $options Array: (optional) extra params to pass (see Http::request()) + * @return \CurlHttpRequest|\PhpHttpRequest * @see MWHttpRequest::__construct */ public static function factory( $url, $options = null ) { @@ -295,6 +301,7 @@ class MWHttpRequest { /** * Set the user agent + * @param $UA string */ public function setUserAgent( $UA ) { $this->setHeader( 'User-Agent', $UA ); @@ -302,6 +309,8 @@ class MWHttpRequest { /** * Set an arbitrary header + * @param $name + * @param $value */ public function setHeader( $name, $value ) { // I feel like I should normalize the case here... @@ -310,6 +319,7 @@ class MWHttpRequest { /** * Get an array of the headers + * @return array */ public function getHeaderList() { $list = array(); @@ -540,6 +550,9 @@ class MWHttpRequest { * cookies. Used internally after a request to parse the * Set-Cookie headers. * @see Cookie::set + * @param $name + * @param $value null + * @param $attr null */ public function setCookie( $name, $value = null, $attr = null ) { if ( !$this->cookieJar ) { @@ -614,6 +627,7 @@ class MWHttpRequest { /** * Returns true if the backend can follow redirects. Overridden by the * child classes. + * @return bool */ public function canFollowRedirects() { return true; @@ -634,6 +648,11 @@ class CurlHttpRequest extends MWHttpRequest { protected $curlOptions = array(); protected $headerText = ""; + /** + * @param $fh + * @param $content + * @return int + */ protected function readHeader( $fh, $content ) { $this->headerText .= $content; return strlen( $content ); @@ -725,6 +744,9 @@ class CurlHttpRequest extends MWHttpRequest { return $this->status; } + /** + * @return bool + */ public function canFollowRedirects() { if ( strval( ini_get( 'open_basedir' ) ) !== '' || wfIniGetBool( 'safe_mode' ) ) { wfDebug( "Cannot follow redirects in safe mode\n" ); @@ -741,6 +763,11 @@ class CurlHttpRequest extends MWHttpRequest { } class PhpHttpRequest extends MWHttpRequest { + + /** + * @param $url string + * @return string + */ protected function urlToTcp( $url ) { $parsedUrl = parse_url( $url ); diff --git a/includes/ImagePage.php b/includes/ImagePage.php index 8bd94eeaf3..fb25284f49 100644 --- a/includes/ImagePage.php +++ b/includes/ImagePage.php @@ -188,6 +188,9 @@ class ImagePage extends Article { $wgOut->addModuleStyles( 'filepage' ); } + /** + * @return File + */ public function getDisplayedFile() { $this->loadFile(); return $this->displayImg; @@ -247,6 +250,7 @@ class ImagePage extends Article { * * Omit noarticletext if sharedupload; text will be fetched from the * shared upload server if possible. + * @return string */ public function getContent() { $this->loadFile(); @@ -398,7 +402,7 @@ class ImagePage extends Article { 'action' => $wgScript, 'onchange' => 'document.pageselector.submit();', ); - + $options = array(); for ( $i = 1; $i <= $count; $i++ ) { $options[] = Xml::option( $wgLang->formatNum( $i ), $i, $i == $page ); } @@ -484,9 +488,10 @@ EOT /** * Creates an thumbnail of specified size and returns an HTML link to it - * @param array $params Scaler parameters - * @param int $width - * @param int $height + * @param $params array Scaler parameters + * @param $width int + * @param $height int + * @return string */ private function makeSizeLink( $params, $width, $height ) { $params['width'] = $width; @@ -615,6 +620,11 @@ EOT } } + /** + * @param $target + * @param $limit + * @return ResultWrapper + */ protected function queryImageLinks( $target, $limit ) { $dbr = wfGetDB( DB_SLAVE ); @@ -747,6 +757,9 @@ EOT ); $wgOut->addHTML( "