Clean up get_class() in /includes/filerepo and /includes/resourceloader
authorTimo Tijhof <krinklemail@gmail.com>
Tue, 7 Mar 2017 02:14:14 +0000 (18:14 -0800)
committerReedy <reedy@wikimedia.org>
Tue, 7 Mar 2017 21:30:29 +0000 (21:30 +0000)
* get_class()        -> __CLASS__ (same as self::class)
* get_called_class() -> static::class
* get_class($this)   -> static::class

Change-Id: Ic4f9b150ddc35e25f51297de7fc12410d421be4d

includes/filerepo/ForeignAPIRepo.php
includes/filerepo/ForeignDBRepo.php
includes/filerepo/ForeignDBViaLBRepo.php
includes/filerepo/NullRepo.php
includes/filerepo/file/File.php
includes/filerepo/file/LocalFile.php
includes/resourceloader/ResourceLoaderModule.php

index ca41718..43f1d21 100644 (file)
@@ -571,7 +571,7 @@ class ForeignAPIRepo extends FileRepo {
 
                $cache = ObjectCache::getMainWANInstance();
                return $cache->getWithSetCallback(
-                       $this->getLocalCacheKey( get_class( $this ), $target, md5( $url ) ),
+                       $this->getLocalCacheKey( static::class, $target, md5( $url ) ),
                        $cacheTTL,
                        function ( $curValue, &$ttl ) use ( $url, $cache ) {
                                $html = self::httpGet( $url, 'default', [], $mtime );
@@ -593,13 +593,13 @@ class ForeignAPIRepo extends FileRepo {
         * @throws MWException
         */
        function enumFiles( $callback ) {
-               throw new MWException( 'enumFiles is not supported by ' . get_class( $this ) );
+               throw new MWException( 'enumFiles is not supported by ' . static::class );
        }
 
        /**
         * @throws MWException
         */
        protected function assertWritableRepo() {
-               throw new MWException( get_class( $this ) . ': write operations are not supported.' );
+               throw new MWException( static::class . ': write operations are not supported.' );
        }
 }
index f49ef88..3e88508 100644 (file)
@@ -138,7 +138,7 @@ class ForeignDBRepo extends LocalRepo {
        }
 
        protected function assertWritableRepo() {
-               throw new MWException( get_class( $this ) . ': write operations are not supported.' );
+               throw new MWException( static::class . ': write operations are not supported.' );
        }
 
        /**
index a9cd030..f83fd1c 100644 (file)
@@ -100,7 +100,7 @@ class ForeignDBViaLBRepo extends LocalRepo {
        }
 
        protected function assertWritableRepo() {
-               throw new MWException( get_class( $this ) . ': write operations are not supported.' );
+               throw new MWException( static::class . ': write operations are not supported.' );
        }
 
        public function getInfo() {
index f2b7395..1c12e02 100644 (file)
@@ -33,6 +33,6 @@ class NullRepo extends FileRepo {
        }
 
        protected function assertWritableRepo() {
-               throw new MWException( get_class( $this ) . ': write operations are not supported.' );
+               throw new MWException( static::class . ': write operations are not supported.' );
        }
 }
index 3b873ea..f7e85a8 100644 (file)
@@ -1766,7 +1766,7 @@ abstract class File implements IDBAccessObject {
         * @throws MWException
         */
        function readOnlyError() {
-               throw new MWException( get_class( $this ) . ': write operations are not supported' );
+               throw new MWException( static::class . ': write operations are not supported' );
        }
 
        /**
index a1cb0a2..a633fd2 100644 (file)
@@ -391,7 +391,7 @@ class LocalFile extends File {
         * @param int $flags
         */
        function loadFromDB( $flags = 0 ) {
-               $fname = get_class( $this ) . '::' . __FUNCTION__;
+               $fname = static::class . '::' . __FUNCTION__;
 
                # Unconditionally set loaded=true, we don't want the accessors constantly rechecking
                $this->dataLoaded = true;
@@ -416,7 +416,7 @@ class LocalFile extends File {
         * This covers fields that are sometimes not cached.
         */
        protected function loadExtraFromDB() {
-               $fname = get_class( $this ) . '::' . __FUNCTION__;
+               $fname = static::class . '::' . __FUNCTION__;
 
                # Unconditionally set loaded=true, we don't want the accessors constantly rechecking
                $this->extraDataLoaded = true;
@@ -1100,7 +1100,7 @@ class LocalFile extends File {
         */
        public function nextHistoryLine() {
                # Polymorphic function name to distinguish foreign and local fetches
-               $fname = get_class( $this ) . '::' . __FUNCTION__;
+               $fname = static::class . '::' . __FUNCTION__;
 
                $dbr = $this->repo->getReplicaDB();
 
index d4dabe7..a2b4b1d 100644 (file)
@@ -843,7 +843,7 @@ abstract class ResourceLoaderModule implements LoggerAwareInterface {
         */
        public function getDefinitionSummary( ResourceLoaderContext $context ) {
                return [
-                       '_class' => get_class( $this ),
+                       '_class' => static::class,
                        '_cacheEpoch' => $this->getConfig()->get( 'CacheEpoch' ),
                ];
        }