More function level documentation
authorSam Reed <reedy@users.mediawiki.org>
Fri, 18 Feb 2011 23:56:08 +0000 (23:56 +0000)
committerSam Reed <reedy@users.mediawiki.org>
Fri, 18 Feb 2011 23:56:08 +0000 (23:56 +0000)
includes/filerepo/ArchivedFile.php
includes/filerepo/File.php
includes/filerepo/FileRepo.php
includes/filerepo/FileRepoStatus.php
includes/filerepo/ForeignAPIFile.php
includes/filerepo/LocalFile.php
includes/filerepo/LocalRepo.php
includes/filerepo/OldLocalFile.php
includes/filerepo/RepoGroup.php
includes/filerepo/UnregisteredLocalFile.php
includes/media/Generic.php

index b4e1cc5..be9d3f1 100644 (file)
@@ -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='' ) {
index b9e1db7..6dfb634 100644 (file)
@@ -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();
                }
index e5e9f6b..6077722 100644 (file)
@@ -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;
index 161284c..24d7331 100644 (file)
@@ -28,6 +28,9 @@ class FileRepoStatus extends Status {
                return $result;
        }
 
+       /**
+        * @param $repo FileRepo
+        */
        function __construct( $repo = false ) {
                if ( $repo ) {
                        $this->cleanCallback = $repo->getErrorCleanupFunction();
index 193dde0..daf2149 100644 (file)
 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;
index 8a61a25..328951c 100644 (file)
@@ -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;
index 0ad1947..ab728ba 100644 (file)
@@ -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 ) {
index 9efe998..0d224fc 100644 (file)
@@ -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 ) {
index 65de63b..4c712fd 100644 (file)
  * @ingroup FileRepo
  */
 class RepoGroup {
-       var $localRepo, $foreignRepos, $reposInitialised = false;
+
+       /**
+        * @var LocalRepo
+        */
+       var $localRepo;
+
+       var $foreignRepos, $reposInitialised = false;
        var $localInfo, $foreignInfo;
        var $cache;
 
index 990a218..71001bd 100644 (file)
  * @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' );
index 58bd674..88b5543 100644 (file)
@@ -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;