* Added some Title type hinting
authorAaron Schulz <aaron@users.mediawiki.org>
Fri, 4 Nov 2011 23:33:53 +0000 (23:33 +0000)
committerAaron Schulz <aaron@users.mediawiki.org>
Fri, 4 Nov 2011 23:33:53 +0000 (23:33 +0000)
* Used 'self' in some class construction instances

includes/filerepo/FileRepo.php
includes/filerepo/ForeignAPIFile.php
includes/filerepo/LocalFile.php
includes/filerepo/LocalRepo.php

index 2d7a50f..4efd42e 100644 (file)
@@ -249,7 +249,7 @@ abstract class FileRepo {
         * Get the name of an image from its title object
         * @param $title Title
         */
-       function getNameFromTitle( $title ) {
+       function getNameFromTitle( Title $title ) {
                if ( $this->initialCapital != MWNamespace::isCapitalized( NS_FILE ) ) {
                        global $wgContLang;
                        $name = $title->getUserCaseDBKey();
index ba699be..2e48517 100644 (file)
@@ -33,13 +33,13 @@ class ForeignAPIFile extends File {
         * @param $repo ForeignApiRepo
         * @return ForeignAPIFile|null
         */
-       static function newFromTitle( $title, $repo ) {
+       static function newFromTitle( Title $title, $repo ) {
                $data = $repo->fetchImageQuery( array(
-                        'titles' => 'File:' . $title->getDBKey(),
-                        'iiprop' => self::getProps(),
-                        'prop' => 'imageinfo',
+                       'titles' => 'File:' . $title->getDBKey(),
+                       'iiprop' => self::getProps(),
+                       'prop'   => 'imageinfo',
                        'iimetadataversion' => MediaHandler::getMetadataVersion()
-                        ) );
+               ) );
 
                $info = $repo->getImageInfo( $data );
 
@@ -49,12 +49,12 @@ class ForeignAPIFile extends File {
                                : -1;
                        if( $lastRedirect >= 0 ) {
                                $newtitle = Title::newFromText( $data['query']['redirects'][$lastRedirect]['to']);
-                               $img = new ForeignAPIFile( $newtitle, $repo, $info, true );
+                               $img = new self( $newtitle, $repo, $info, true );
                                if( $img ) {
                                        $img->redirectedFrom( $title->getDBkey() );
                                }
                        } else {
-                               $img = new ForeignAPIFile( $title, $repo, $info, true );
+                               $img = new self( $title, $repo, $info, true );
                        }
                        return $img;
                } else {
index c3f0452..b14966a 100644 (file)
@@ -144,7 +144,7 @@ class LocalFile extends File {
         * Do not call this except from inside a repo class.
         */
        function __construct( $title, $repo ) {
-               if ( !is_object( $title ) ) {
+               if ( !is_object( $title ) ) { // LocalFile requires a title object
                        throw new MWException( __CLASS__ . ' constructor given bogus title.' );
                }
 
index e29bca0..373fda1 100644 (file)
@@ -258,7 +258,7 @@ class LocalRepo extends FSRepo {
         *
         * @param $title Title of page
         */
-       function invalidateImageRedirect( $title ) {
+       function invalidateImageRedirect( Title $title ) {
                global $wgMemc;
                $memcKey = $this->getSharedCacheKey( 'image_redirect', md5( $title->getDBkey() ) );
                if ( $memcKey ) {