From daa41d319b4f8a41167afc7943925814d7e61529 Mon Sep 17 00:00:00 2001 From: Sam Reed Date: Fri, 18 Feb 2011 23:56:08 +0000 Subject: [PATCH] More function level documentation --- includes/filerepo/ArchivedFile.php | 6 +++++- includes/filerepo/File.php | 21 ++++++++++++++++++--- includes/filerepo/FileRepo.php | 8 +++++++- includes/filerepo/FileRepoStatus.php | 3 +++ includes/filerepo/ForeignAPIFile.php | 8 +++++++- includes/filerepo/LocalFile.php | 18 ++++++++++++++++-- includes/filerepo/LocalRepo.php | 1 + includes/filerepo/OldLocalFile.php | 9 ++++++++- includes/filerepo/RepoGroup.php | 8 +++++++- includes/filerepo/UnregisteredLocalFile.php | 14 +++++++++++++- includes/media/Generic.php | 2 ++ 11 files changed, 87 insertions(+), 11 deletions(-) diff --git a/includes/filerepo/ArchivedFile.php b/includes/filerepo/ArchivedFile.php index b4e1cc5fb5..be9d3f1e09 100644 --- a/includes/filerepo/ArchivedFile.php +++ b/includes/filerepo/ArchivedFile.php @@ -16,7 +16,6 @@ class ArchivedFile { * @private */ var $id, # filearchive row ID - $title, # image title $name, # image name $group, # FileStore storage group $key, # FileStore sha1 key @@ -34,6 +33,11 @@ class ArchivedFile { $dataLoaded, # Whether or not all this has been loaded from the database (loadFromXxx) $deleted; # Bitfield akin to rev_deleted + /** + * @var Title + */ + var $title; # image title + /**#@-*/ function __construct( $title, $id=0, $key='' ) { diff --git a/includes/filerepo/File.php b/includes/filerepo/File.php index b9e1db7b33..6dfb634f25 100644 --- a/includes/filerepo/File.php +++ b/includes/filerepo/File.php @@ -52,7 +52,18 @@ abstract class File { /** * The following member variables are not lazy-initialised */ - var $repo, $title, $lastError, $redirected, $redirectedTitle; + + /** + * @var LocalRepo + */ + var $repo; + + /** + * @var Title + */ + var $title; + + var $lastError, $redirected, $redirectedTitle; /** * Call this constructor from child classes @@ -1117,9 +1128,13 @@ abstract class File { if( $this->isLocal() ) { global $wgParser; $revision = Revision::newFromTitle( $this->title ); - if ( !$revision ) return false; + if ( !$revision ) { + return false; + } $text = $revision->getText(); - if ( !$text ) return false; + if ( !$text ) { + return false; + } $pout = $wgParser->parse( $text, $this->title, new ParserOptions() ); return $pout->getText(); } diff --git a/includes/filerepo/FileRepo.php b/includes/filerepo/FileRepo.php index e5e9f6b51c..6077722a27 100644 --- a/includes/filerepo/FileRepo.php +++ b/includes/filerepo/FileRepo.php @@ -66,6 +66,8 @@ abstract class FileRepo { * instance of the repository's old file class instead of a * current file. Repositories not supporting version control * should return false if this parameter is set. + * + * @return File */ function newFile( $title, $time = false ) { if ( !($title instanceof Title) ) { @@ -140,7 +142,7 @@ abstract class FileRepo { return false; } $redir = $this->checkRedirect( $title ); - if( $redir && $redir->getNamespace() == NS_FILE) { + if( $redir && $title->getNamespace() == NS_FILE) { $img = $this->newFile( $redir ); if( !$img ) { return false; @@ -189,6 +191,8 @@ abstract class FileRepo { * of the repository's old file class instead of a current * file. Repositories not supporting version control should * return false if this parameter is set. + * + * @return File */ function newFileFromKey( $sha1, $time = false ) { if ( $time ) { @@ -265,6 +269,7 @@ abstract class FileRepo { /** * Get the name of an image from its title object + * @param $title Title */ function getNameFromTitle( $title ) { if ( $this->initialCapital != MWNamespace::isCapitalized( NS_FILE ) ) { @@ -624,6 +629,7 @@ abstract class FileRepo { * STUB * * @param $title Title of image + * @return Bool */ function checkRedirect( $title ) { return false; diff --git a/includes/filerepo/FileRepoStatus.php b/includes/filerepo/FileRepoStatus.php index 161284c01c..24d7331562 100644 --- a/includes/filerepo/FileRepoStatus.php +++ b/includes/filerepo/FileRepoStatus.php @@ -28,6 +28,9 @@ class FileRepoStatus extends Status { return $result; } + /** + * @param $repo FileRepo + */ function __construct( $repo = false ) { if ( $repo ) { $this->cleanCallback = $repo->getErrorCleanupFunction(); diff --git a/includes/filerepo/ForeignAPIFile.php b/includes/filerepo/ForeignAPIFile.php index 193dde029a..daf2149159 100644 --- a/includes/filerepo/ForeignAPIFile.php +++ b/includes/filerepo/ForeignAPIFile.php @@ -15,7 +15,13 @@ class ForeignAPIFile extends File { private $mExists; - + + /** + * @param $title + * @param $repo ForeignApiRepo + * @param $info + * @param bool $exists + */ function __construct( $title, $repo, $info, $exists = false ) { parent::__construct( $title, $repo ); $this->mInfo = $info; diff --git a/includes/filerepo/LocalFile.php b/includes/filerepo/LocalFile.php index 8a61a25d91..328951c05b 100644 --- a/includes/filerepo/LocalFile.php +++ b/includes/filerepo/LocalFile.php @@ -83,6 +83,9 @@ class LocalFile extends File { /** * Create a LocalFile from a SHA-1 key * Do not call this except from inside a repo class. + * @param $sha1 + * @param $repo LocalRepo + * @param $timestamp */ static function newFromKey( $sha1, $repo, $timestamp = false ) { $conds = array( 'img_sha1' => $sha1 ); @@ -1292,7 +1295,13 @@ class LocalFile extends File { * @ingroup FileRepo */ class LocalFileDeleteBatch { - var $file, $reason, $srcRels = array(), $archiveUrls = array(), $deletionBatch, $suppress; + + /** + * @var LocalFile + */ + var $file; + + var $reason, $srcRels = array(), $archiveUrls = array(), $deletionBatch, $suppress; var $status; function __construct( File $file, $reason = '', $suppress = false ) { @@ -1603,7 +1612,12 @@ class LocalFileDeleteBatch { * @ingroup FileRepo */ class LocalFileRestoreBatch { - var $file, $cleanupBatch, $ids, $all, $unsuppress = false; + /** + * @var LocalFile + */ + var $file; + + var $cleanupBatch, $ids, $all, $unsuppress = false; function __construct( File $file, $unsuppress = false ) { $this->file = $file; diff --git a/includes/filerepo/LocalRepo.php b/includes/filerepo/LocalRepo.php index 0ad1947d51..ab728ba78e 100644 --- a/includes/filerepo/LocalRepo.php +++ b/includes/filerepo/LocalRepo.php @@ -133,6 +133,7 @@ class LocalRepo extends FSRepo { /** * Function link Title::getArticleID(). * We can't say Title object, what database it should use, so we duplicate that function here. + * @param $title Title */ protected function getArticleID( $title ) { if( !$title instanceof Title ) { diff --git a/includes/filerepo/OldLocalFile.php b/includes/filerepo/OldLocalFile.php index 9efe998fa8..0d224fcf0d 100644 --- a/includes/filerepo/OldLocalFile.php +++ b/includes/filerepo/OldLocalFile.php @@ -34,7 +34,14 @@ class OldLocalFile extends LocalFile { $file->loadFromRow( $row, 'oi_' ); return $file; } - + + /** + * @static + * @param $sha1 + * @param $repo LocalRepo + * @param bool $timestamp + * @return bool|OldLocalFile + */ static function newFromKey( $sha1, $repo, $timestamp = false ) { $conds = array( 'oi_sha1' => $sha1 ); if( $timestamp ) { diff --git a/includes/filerepo/RepoGroup.php b/includes/filerepo/RepoGroup.php index 65de63bd9f..4c712fd5e4 100644 --- a/includes/filerepo/RepoGroup.php +++ b/includes/filerepo/RepoGroup.php @@ -16,7 +16,13 @@ * @ingroup FileRepo */ class RepoGroup { - var $localRepo, $foreignRepos, $reposInitialised = false; + + /** + * @var LocalRepo + */ + var $localRepo; + + var $foreignRepos, $reposInitialised = false; var $localInfo, $foreignInfo; var $cache; diff --git a/includes/filerepo/UnregisteredLocalFile.php b/includes/filerepo/UnregisteredLocalFile.php index 990a218c22..71001bd325 100644 --- a/includes/filerepo/UnregisteredLocalFile.php +++ b/includes/filerepo/UnregisteredLocalFile.php @@ -19,7 +19,12 @@ * @ingroup FileRepo */ class UnregisteredLocalFile extends File { - var $title, $path, $mime, $handler, $dims; + var $title, $path, $mime, $dims; + + /** + * @var MediaHandler + */ + var $handler; static function newFromPath( $path, $mime ) { return new UnregisteredLocalFile( false, false, $path, $mime ); @@ -29,6 +34,13 @@ class UnregisteredLocalFile extends File { return new UnregisteredLocalFile( $title, $repo, false, false ); } + /** + * @throws MWException + * @param bool $title + * @param $repo FSRepo + * @param bool $path + * @param bool $mime + */ function __construct( $title = false, $repo = false, $path = false, $mime = false ) { if ( !( $title && $repo ) && !$path ) { throw new MWException( __METHOD__.': not enough parameters, must specify title and repo, or a full path' ); diff --git a/includes/media/Generic.php b/includes/media/Generic.php index 58bd674eda..88b5543b4b 100644 --- a/includes/media/Generic.php +++ b/includes/media/Generic.php @@ -21,6 +21,8 @@ abstract class MediaHandler { /** * Get a MediaHandler for a given MIME type from the instance cache + * + * @return MediaHandler */ static function getHandler( $type ) { global $wgMediaHandlers; -- 2.20.1