From 50a035cd6bea9a40014b0dd9ad344fdd9abf46b6 Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Mon, 6 Mar 2017 18:14:14 -0800 Subject: [PATCH] Clean up get_class($this) -> static::class in /includes/cache and /includes/libs * get_class() -> __CLASS__ (same as self::class) * get_called_class() -> static::class * get_class($this) -> static::class Change-Id: I22c62851bcc88405f4bdd77258d6e28ec1a14924 --- includes/cache/FileCacheBase.php | 4 ++-- includes/cache/localisation/LocalisationCache.php | 2 +- includes/libs/filebackend/FileBackendMultiWrite.php | 4 ++-- includes/libs/filebackend/FileBackendStore.php | 4 ++-- includes/libs/filebackend/fileop/FileOp.php | 2 +- includes/libs/objectcache/BagOStuff.php | 2 +- includes/libs/rdbms/database/Database.php | 2 +- includes/libs/rdbms/database/resultwrapper/ResultWrapper.php | 2 +- includes/libs/virtualrest/VirtualRESTService.php | 3 +-- 9 files changed, 12 insertions(+), 13 deletions(-) diff --git a/includes/cache/FileCacheBase.php b/includes/cache/FileCacheBase.php index 6d5f8c3e55..0a302b6ec1 100644 --- a/includes/cache/FileCacheBase.php +++ b/includes/cache/FileCacheBase.php @@ -242,7 +242,7 @@ abstract class FileCacheBase { : 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 } @@ -272,6 +272,6 @@ abstract class FileCacheBase { * @return string */ protected function cacheMissKey() { - return wfMemcKey( get_class( $this ), 'misses', $this->mType, $this->mKey ); + return wfMemcKey( static::class, 'misses', $this->mType, $this->mKey ); } } diff --git a/includes/cache/localisation/LocalisationCache.php b/includes/cache/localisation/LocalisationCache.php index 90b3de1ac1..cbff113761 100644 --- a/includes/cache/localisation/LocalisationCache.php +++ b/includes/cache/localisation/LocalisationCache.php @@ -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']; } diff --git a/includes/libs/filebackend/FileBackendMultiWrite.php b/includes/libs/filebackend/FileBackendMultiWrite.php index 212e84f026..53bce33dad 100644 --- a/includes/libs/filebackend/FileBackendMultiWrite.php +++ b/includes/libs/filebackend/FileBackendMultiWrite.php @@ -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() ) { - 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 @@ -378,7 +378,7 @@ class FileBackendMultiWrite extends FileBackend { } if ( !$status->isOK() ) { - wfDebugLog( 'FileOperation', get_class( $this ) . + wfDebugLog( 'FileOperation', static::class . " failed to resync: " . FormatJson::encode( $paths ) ); } diff --git a/includes/libs/filebackend/FileBackendStore.php b/includes/libs/filebackend/FileBackendStore.php index 5179477e28..7cb26c6c65 100644 --- a/includes/libs/filebackend/FileBackendStore.php +++ b/includes/libs/filebackend/FileBackendStore.php @@ -360,7 +360,7 @@ abstract class FileBackendStore extends FileBackend { $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]" ); } } @@ -1123,7 +1123,7 @@ abstract class FileBackendStore extends FileBackend { $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 ) ); } diff --git a/includes/libs/filebackend/fileop/FileOp.php b/includes/libs/filebackend/fileop/FileOp.php index fab5a3743c..79af194483 100644 --- a/includes/libs/filebackend/fileop/FileOp.php +++ b/includes/libs/filebackend/fileop/FileOp.php @@ -461,7 +461,7 @@ abstract class FileOp { $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? diff --git a/includes/libs/objectcache/BagOStuff.php b/includes/libs/objectcache/BagOStuff.php index d0b68bcbd7..77c4259a0d 100644 --- a/includes/libs/objectcache/BagOStuff.php +++ b/includes/libs/objectcache/BagOStuff.php @@ -679,7 +679,7 @@ abstract class BagOStuff implements IExpiringStore, LoggerAwareInterface { protected function debug( $text ) { if ( $this->debugMode ) { $this->logger->debug( "{class} debug: $text", [ - 'class' => get_class( $this ), + 'class' => static::class, ] ); } } diff --git a/includes/libs/rdbms/database/Database.php b/includes/libs/rdbms/database/Database.php index c5afe1e73c..e807bc84ad 100644 --- a/includes/libs/rdbms/database/Database.php +++ b/includes/libs/rdbms/database/Database.php @@ -3412,7 +3412,7 @@ abstract class Database implements IDatabase, IMaintainableDatabase, LoggerAware */ 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() ); diff --git a/includes/libs/rdbms/database/resultwrapper/ResultWrapper.php b/includes/libs/rdbms/database/resultwrapper/ResultWrapper.php index a76d66aa29..d658c96b3a 100644 --- a/includes/libs/rdbms/database/resultwrapper/ResultWrapper.php +++ b/includes/libs/rdbms/database/resultwrapper/ResultWrapper.php @@ -82,7 +82,7 @@ class ResultWrapper implements IResultWrapper { */ 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; diff --git a/includes/libs/virtualrest/VirtualRESTService.php b/includes/libs/virtualrest/VirtualRESTService.php index ccb14db020..2f160787e1 100644 --- a/includes/libs/virtualrest/VirtualRESTService.php +++ b/includes/libs/virtualrest/VirtualRESTService.php @@ -51,8 +51,7 @@ abstract class VirtualRESTService { * @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; } /** -- 2.20.1