Clean up get_class($this) -> static::class in /includes/cache and /includes/libs
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:06:06 +0000 (21:06 +0000)
* get_class()        -> __CLASS__ (same as self::class)
* get_called_class() -> static::class
* get_class($this)   -> static::class

Change-Id: I22c62851bcc88405f4bdd77258d6e28ec1a14924

includes/cache/FileCacheBase.php
includes/cache/localisation/LocalisationCache.php
includes/libs/filebackend/FileBackendMultiWrite.php
includes/libs/filebackend/FileBackendStore.php
includes/libs/filebackend/fileop/FileOp.php
includes/libs/objectcache/BagOStuff.php
includes/libs/rdbms/database/Database.php
includes/libs/rdbms/database/resultwrapper/ResultWrapper.php
includes/libs/virtualrest/VirtualRESTService.php

index 6d5f8c3..0a302b6 100644 (file)
@@ -242,7 +242,7 @@ abstract class FileCacheBase {
                                : IP::sanitizeRange( "$ip/16" );
 
                        # Bail out if a request already came from this range...
                                : IP::sanitizeRange( "$ip/16" );
 
                        # Bail out if a request already came from this range...
-                       $key = wfMemcKey( get_class( $this ), 'attempt', $this->mType, $this->mKey, $ip );
+                       $key = wfMemcKey( static::class, 'attempt', $this->mType, $this->mKey, $ip );
                        if ( $cache->get( $key ) ) {
                                return; // possibly the same user
                        }
                        if ( $cache->get( $key ) ) {
                                return; // possibly the same user
                        }
@@ -272,6 +272,6 @@ abstract class FileCacheBase {
         * @return string
         */
        protected function cacheMissKey() {
         * @return string
         */
        protected function cacheMissKey() {
-               return wfMemcKey( get_class( $this ), 'misses', $this->mType, $this->mKey );
+               return wfMemcKey( static::class, 'misses', $this->mType, $this->mKey );
        }
 }
        }
 }
index 90b3de1..cbff113 100644 (file)
@@ -228,7 +228,7 @@ class LocalisationCache {
                        }
                }
 
                        }
                }
 
-               wfDebugLog( 'caches', get_class( $this ) . ": using store $storeClass" );
+               wfDebugLog( 'caches', static::class . ": using store $storeClass" );
                if ( !empty( $conf['storeDirectory'] ) ) {
                        $storeConf['directory'] = $conf['storeDirectory'];
                }
                if ( !empty( $conf['storeDirectory'] ) ) {
                        $storeConf['directory'] = $conf['storeDirectory'];
                }
index 212e84f..53bce33 100644 (file)
@@ -167,7 +167,7 @@ class FileBackendMultiWrite extends FileBackend {
                // Do a consistency check to see if the backends are consistent...
                $syncStatus = $this->consistencyCheck( $relevantPaths );
                if ( !$syncStatus->isOK() ) {
                // Do a consistency check to see if the backends are consistent...
                $syncStatus = $this->consistencyCheck( $relevantPaths );
                if ( !$syncStatus->isOK() ) {
-                       wfDebugLog( 'FileOperation', get_class( $this ) .
+                       wfDebugLog( 'FileOperation', static::class .
                                " failed sync check: " . FormatJson::encode( $relevantPaths ) );
                        // Try to resync the clone backends to the master on the spot...
                        if ( $this->autoResync === false
                                " failed sync check: " . FormatJson::encode( $relevantPaths ) );
                        // Try to resync the clone backends to the master on the spot...
                        if ( $this->autoResync === false
@@ -378,7 +378,7 @@ class FileBackendMultiWrite extends FileBackend {
                }
 
                if ( !$status->isOK() ) {
                }
 
                if ( !$status->isOK() ) {
-                       wfDebugLog( 'FileOperation', get_class( $this ) .
+                       wfDebugLog( 'FileOperation', static::class .
                                " failed to resync: " . FormatJson::encode( $paths ) );
                }
 
                                " failed to resync: " . FormatJson::encode( $paths ) );
                }
 
index 5179477..7cb26c6 100644 (file)
@@ -360,7 +360,7 @@ abstract class FileBackendStore extends FileBackend {
                        $status->merge( $this->doConcatenate( $params ) );
                        $sec = microtime( true ) - $start_time;
                        if ( !$status->isOK() ) {
                        $status->merge( $this->doConcatenate( $params ) );
                        $sec = microtime( true ) - $start_time;
                        if ( !$status->isOK() ) {
-                               $this->logger->error( get_class( $this ) . "-{$this->name}" .
+                               $this->logger->error( static::class . "-{$this->name}" .
                                        " failed to concatenate " . count( $params['srcs'] ) . " file(s) [$sec sec]" );
                        }
                }
                                        " failed to concatenate " . count( $params['srcs'] ) . " file(s) [$sec sec]" );
                        }
                }
@@ -1123,7 +1123,7 @@ abstract class FileBackendStore extends FileBackend {
                                $subStatus->success[$i] = false;
                                ++$subStatus->failCount;
                        }
                                $subStatus->success[$i] = false;
                                ++$subStatus->failCount;
                        }
-                       $this->logger->error( get_class( $this ) . "-{$this->name} " .
+                       $this->logger->error( static::class . "-{$this->name} " .
                                " stat failure; aborted operations: " . FormatJson::encode( $ops ) );
                }
 
                                " stat failure; aborted operations: " . FormatJson::encode( $ops ) );
                }
 
index fab5a37..79af194 100644 (file)
@@ -461,7 +461,7 @@ abstract class FileOp {
                $params = $this->params;
                $params['failedAction'] = $action;
                try {
                $params = $this->params;
                $params['failedAction'] = $action;
                try {
-                       $this->logger->error( get_class( $this ) .
+                       $this->logger->error( static::class .
                                " failed (batch #{$this->batchId}): " . FormatJson::encode( $params ) );
                } catch ( Exception $e ) {
                        // bad config? debug log error?
                                " failed (batch #{$this->batchId}): " . FormatJson::encode( $params ) );
                } catch ( Exception $e ) {
                        // bad config? debug log error?
index d0b68bc..77c4259 100644 (file)
@@ -679,7 +679,7 @@ abstract class BagOStuff implements IExpiringStore, LoggerAwareInterface {
        protected function debug( $text ) {
                if ( $this->debugMode ) {
                        $this->logger->debug( "{class} debug: $text", [
        protected function debug( $text ) {
                if ( $this->debugMode ) {
                        $this->logger->debug( "{class} debug: $text", [
-                               'class' => get_class( $this ),
+                               'class' => static::class,
                        ] );
                }
        }
                        ] );
                }
        }
index c5afe1e..e807bc8 100644 (file)
@@ -3412,7 +3412,7 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware
         */
        public function __clone() {
                $this->connLogger->warning(
         */
        public function __clone() {
                $this->connLogger->warning(
-                       "Cloning " . get_class( $this ) . " is not recomended; forking connection:\n" .
+                       "Cloning " . static::class . " is not recomended; forking connection:\n" .
                        ( new RuntimeException() )->getTraceAsString()
                );
 
                        ( new RuntimeException() )->getTraceAsString()
                );
 
index a76d66a..d658c96 100644 (file)
@@ -82,7 +82,7 @@ class ResultWrapper implements IResultWrapper {
         */
        private function getDB() {
                if ( !$this->db ) {
         */
        private function getDB() {
                if ( !$this->db ) {
-                       throw new RuntimeException( get_class( $this ) . ' needs a DB handle for iteration.' );
+                       throw new RuntimeException( static::class . ' needs a DB handle for iteration.' );
                }
 
                return $this->db;
                }
 
                return $this->db;
index ccb14db..2f16078 100644 (file)
@@ -51,8 +51,7 @@ abstract class VirtualRESTService {
         * @return string The name of the service behind this VRS object.
         */
        public function getName() {
         * @return string The name of the service behind this VRS object.
         */
        public function getName() {
-               return isset( $this->params['name'] ) ? $this->params['name'] :
-                       get_class( $this );
+               return isset( $this->params['name'] ) ? $this->params['name'] : static::class;
        }
 
        /**
        }
 
        /**