Update documentation
[lhc/web/wiklou.git] / includes / filerepo / RepoGroup.php
index f9e5759..62e9cc0 100644 (file)
@@ -53,6 +53,7 @@ class RepoGroup {
                }
                global $wgLocalFileRepo, $wgForeignFileRepos;
                self::$instance = new RepoGroup( $wgLocalFileRepo, $wgForeignFileRepos );
+
                return self::$instance;
        }
 
@@ -79,8 +80,8 @@ class RepoGroup {
        /**
         * Construct a group of file repositories.
         *
-        * @param $localInfo array Associative array for local repo's info
-        * @param $foreignInfo Array of repository info arrays.
+        * @param array $localInfo Associative array for local repo's info
+        * @param array $foreignInfo of repository info arrays.
         *     Each info array is an associative array with the 'class' member
         *     giving the class name. The entire array is passed to the repository
         *     constructor as the first parameter.
@@ -96,7 +97,7 @@ class RepoGroup {
         * You can also use wfFindFile() to do this.
         *
         * @param $title Title|string Title object or string
-        * @param $options array Associative array of options:
+        * @param array $options Associative array of options:
         *     time:           requested time for an archived image, or false for the
         *                     current version. An image object will be returned which was
         *                     created at the specified time.
@@ -126,14 +127,15 @@ class RepoGroup {
                # Check the cache
                if ( empty( $options['ignoreRedirect'] )
                        && empty( $options['private'] )
-                       && empty( $options['bypassCache'] ) )
-               {
+                       && empty( $options['bypassCache'] )
+               {
                        $time = isset( $options['time'] ) ? $options['time'] : '';
                        $dbkey = $title->getDBkey();
                        if ( isset( $this->cache[$dbkey][$time] ) ) {
-                               wfDebug( __METHOD__.": got File:$dbkey from process cache\n" );
+                               wfDebug( __METHOD__ . ": got File:$dbkey from process cache\n" );
                                # Move it to the end of the list so that we can delete the LRU entry later
                                $this->pingCache( $dbkey );
+
                                # Return the entry
                                return $this->cache[$dbkey][$time];
                        }
@@ -195,6 +197,7 @@ class RepoGroup {
 
                        $images = array_merge( $images, $repo->findFiles( $items ) );
                }
+
                return $images;
        }
 
@@ -209,7 +212,7 @@ class RepoGroup {
                }
 
                $redir = $this->localRepo->checkRedirect( $title );
-               if( $redir ) {
+               if ( $redir ) {
                        return $redir;
                }
                foreach ( $this->foreignRepos as $repo ) {
@@ -218,6 +221,7 @@ class RepoGroup {
                                return $redir;
                        }
                }
+
                return false;
        }
 
@@ -225,8 +229,8 @@ class RepoGroup {
         * Find an instance of the file with this key, created at the specified time
         * Returns false if the file does not exist.
         *
-        * @param $hash String base 36 SHA-1 hash
-        * @param $options array Option array, same as findFile()
+        * @param string $hash base 36 SHA-1 hash
+        * @param array $options Option array, same as findFile()
         * @return File object or false if it is not found
         */
        function findFileFromKey( $hash, $options = array() ) {
@@ -238,16 +242,19 @@ class RepoGroup {
                if ( !$file ) {
                        foreach ( $this->foreignRepos as $repo ) {
                                $file = $repo->findFileFromKey( $hash, $options );
-                               if ( $file ) break;
+                               if ( $file ) {
+                                       break;
+                               }
                        }
                }
+
                return $file;
        }
 
        /**
         * Find all instances of files with this key
         *
-        * @param $hash String base 36 SHA-1 hash
+        * @param string $hash base 36 SHA-1 hash
         * @return Array of File objects
         */
        function findBySha1( $hash ) {
@@ -260,13 +267,14 @@ class RepoGroup {
                        $result = array_merge( $result, $repo->findBySha1( $hash ) );
                }
                usort( $result, 'File::compare' );
+
                return $result;
        }
 
        /**
         * Find all instances of files with this keys
         *
-        * @param $hashes Array base 36 SHA-1 hashes
+        * @param array $hashes base 36 SHA-1 hashes
         * @return Array of array of File objects
         */
        function findBySha1s( array $hashes ) {
@@ -279,9 +287,10 @@ class RepoGroup {
                        $result = array_merge_recursive( $result, $repo->findBySha1s( $hashes ) );
                }
                //sort the merged (and presorted) sublist of each hash
-               foreach( $result as $hash => $files ) {
+               foreach ( $result as $hash => $files ) {
                        usort( $result[$hash], 'File::compare' );
                }
+
                return $result;
        }
 
@@ -317,6 +326,7 @@ class RepoGroup {
                                return $repo;
                        }
                }
+
                return false;
        }
 
@@ -335,16 +345,17 @@ class RepoGroup {
         * first parameter.
         *
         * @param $callback Callback: the function to call
-        * @param $params Array: optional additional parameters to pass to the function
+        * @param array $params optional additional parameters to pass to the function
         * @return bool
         */
        function forEachForeignRepo( $callback, $params = array() ) {
-               foreach( $this->foreignRepos as $repo ) {
+               foreach ( $this->foreignRepos as $repo ) {
                        $args = array_merge( array( $repo ), $params );
-                       if( call_user_func_array( $callback, $args ) ) {
+                       if ( call_user_func_array( $callback, $args ) ) {
                                return true;
                        }
                }
+
                return false;
        }
 
@@ -377,6 +388,7 @@ class RepoGroup {
         */
        protected function newRepo( $info ) {
                $class = $info['class'];
+
                return new $class( $info );
        }
 
@@ -388,13 +400,14 @@ class RepoGroup {
         */
        function splitVirtualUrl( $url ) {
                if ( substr( $url, 0, 9 ) != 'mwrepo://' ) {
-                       throw new MWException( __METHOD__.': unknown protocol' );
+                       throw new MWException( __METHOD__ . ': unknown protocol' );
                }
 
                $bits = explode( '/', substr( $url, 9 ), 3 );
                if ( count( $bits ) != 3 ) {
-                       throw new MWException( __METHOD__.": invalid mwrepo URL: $url" );
+                       throw new MWException( __METHOD__ . ": invalid mwrepo URL: $url" );
                }
+
                return $bits;
        }
 
@@ -409,6 +422,7 @@ class RepoGroup {
                                $repoName = 'local';
                        }
                        $repo = $this->getRepo( $repoName );
+
                        return $repo->getFileProps( $fileName );
                } else {
                        return FSFile::getPropsFromPath( $fileName );
@@ -433,7 +447,7 @@ class RepoGroup {
                while ( count( $this->cache ) >= self::MAX_CACHE_SIZE ) {
                        reset( $this->cache );
                        $key = key( $this->cache );
-                       wfDebug( __METHOD__.": evicting $key\n" );
+                       wfDebug( __METHOD__ . ": evicting $key\n" );
                        unset( $this->cache[$key] );
                }
        }